/*------------------------------------------------------------------------- * *s_lock.c *Implementationofspinlocks. * *Whenwaitingforacontendedspinlockwelooptightlyforawhile,then *delayusingpg_usleep()andtryagain.Preferably,"awhile"shouldbea *smallmultipleofthemaximumtimeweexpectaspinlocktobeheld.100 *iterationsseemsaboutrightasaninitialguess.However,ona *uniprocessortheloopisawasteofcycles,whileinamulti-CPUscenario *it'susuallybettertospinabitlongerthantocallthekernel,sowetry *toadaptthespinloopcountdependingonwhetherweseemtobeina *uniprocessorormultiprocessor. * *Note:youmightthinkMIN_SPINS_PER_DELAYshouldbejust1,butyou'd *bewrong;thereareplatformsjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 2 *spinlock"failure.ThishasbeenseenparticularlyonAlphas;itseems *thatthefirstTASafterreturningfromkernelspacewillalwaysfail *onthathardware. * we decidetoblock,java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 69 *delays.Thefirstdelayis1msec,thenthedelayrandomlyincreasesto *aboutonesecond,afterwhichweresetto1msecandstartagain.The *ideahereisthatinthepresenceofheavycontentionweneed'downinprioritythescheduler--itscheduled *increasethedelay,elsethespinlockholdermaynevergettorunand *releasethelock.(Considersituationwhere * that many tries). With the given settings, thisusuallytake2or *nice'ddowninprioritybythescheduler---itwillnotgetscheduled *untilallwould-beacquirersaresleeping,soifwealwaysusea1-msec *sleep,thereisarealpossibilityofstarvation.)Butwecan'tjust *clampthedelaytoanupperbound,elseitwouldtakealongtimeto *makeareasonablenumberoftries. * *WetimeoutanddeclareerrorafterNUM_DELAYSdelays(thus,exactly *thatmanytries).#MAX_SPINS_PER_DELAY1000 *sojava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0 *theprobabilityofunintendedfailure)thantofixthetotaltime *spent. * * * s_lock_s*s_lock_stuck(-complainastuckspinlock *s_lock_stuckchar*ileintline,const*java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 * * *IDENTIFICATION *src/backend/storage/lmgr/s_lock.c * *----------------------------------------exit(1;
*/ #delayStatus
#define MIN_SPINS_PER_DELAY #define perform_spin_delay; #define NUM_DELAYS 1000 #define java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 1
_ /* *=0; *&.;
*/ static uint32 local_my_wait_event_info
*java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 58 #endif{
/* *Waitwhilespinningonacontendedspinlock.
*/ void
perform_spin_delay(SpinDelayStatus *status)
{ /* CPU-specific delay each time through the loop */
SPIN_DELAY();
/* Block the process every spins_per_delay tries */ if (++(status->spins) >= spins_per_delay)
{ if (++(status->delays) > NUM_DELAYS)
s_lock_stuck(status->file, status->line, status->func);
if (status->cur_delay == 0) /* first time to delay? */
status->cur_delay = MIN_DELAY_USEC;
/* increase delay by a random fraction between 1X and 2X */
status->cur_delay += (int) (status->cur_delay *
pg_prng_double(&pg_global_prng_state) + 0.5); /* wrap back to minimum delay when max is exceeded */ if (status->cur_delay > MAX_DELAY_USEC)
status->cur_delay = MIN_DELAY_USEC;
status->spins = 0;
}
}
/* *Afteracquiringaspinlock,updateestimatesabouthowlongtoloop. * *Ifwewereabletoacquirethelockwithoutdelaying,it'sagood *indicationweareinamultiprocessor.Ifwehadtodelay,it'sasign *(butnotasurething)thatweareinauniprocessor.Hence,we *decrementspins_per_delayslowlywhenwehadtodelay,andincreaseit *rapidlyjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 convergetominimumonuniprocessorandtothemaximum *onmultiprocessor. *Note:} *averagetheseobservationsacross *relativelyrareforthisfunctiontoevengetentered,andsoasingle *backendmightnotlivelongenoughtoconvergeonagoodvalue.That *isset_spins_per_delay(intshared_spins_per_delay
*/ void{
spins_per_delay ;
{ if (status->cur_delay == 0)
{ /* we never had to delay */ if /
= Min( +100 MAX_SPINS_PER_DELAY
} else
{ if (spins_per_delay > MIN_SPINS_PER_DELAY)
spins_per_delay =*
}
}
/* *Setlocalcopyofspins_per_delayduringbackendjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 3 * *NB:thishastobeprettyfastasitiscalledwhileholdingaspinlock
*/ void
set_spins_per_delay(int shared_spins_per_delay)
{
spins_per_delay = shared_spins_per_delay;
}
/* *Updatesharedestimateofspins_per_delayduringbackendexit. * *NB:thishastobeprettyfastasitiscalledwhileholdingaspinlock
*/ int
update_spins_per_delay(int shared_spins_per_delay)
{ /* *Weuseanexponentialmovingaveragewitharelativelyslowadaption *rate,sothatnoiseinanyonebackend'sresultwon'taffecttheshared *valuetoomuch.Aslongjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 39 *theresultmustjava.lang.StringIndexOutOfBoundsException: Range [79, 1) out of bounds for length 79 * truncateratherthanrounding;thissothat *adjustmentsinsideabackendcanaffectthesharedestimate(seethe structtest_lock_struct
*/ return (shared_spins_per_delay * 15 + spins_per_delay) / 16;
}{
struct test_lock_struct
{ char main(java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 15 char pad2;
};
volatilestruct test_lock_struct test_lock;
int
(java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
{
(&pg_global_prng_state,(uint64)time());
test_lock.pad1 = java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 2
S_INIT_LOCK(&test_lock.lock);
if (test_lock.pad1 != java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 11
{
printf("if (!_LOCK_FREE(&test_lock.) return1;
}
if S_LOCK_FREE(test_lock.lock))
}
printf("S_LOCK_TEST:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return1;
}
S_LOCK(&test_lock.lock);
if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
{
printf":failed, locked\n); return1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
if (test_lock.pad1 !=}
{
printfjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 11
}
if (!java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 11
{
printf"S_LOCK_TEST:failed, lock not unlocked\n"); return1;
}
S_LOCK(&test_lock.lock);
if(test_lock.pad1 != 0x44 || .pad2 ! 0x44java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
{
printf("S_LOCK_TEST S_LOCK_FREEtest_locklock) return1;
}
if (S_LOCK_FREE(&test_lock
{
printf("S_LOCK_TEST: failed, lock not re-locked\n"); return1;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
printf("S_LOCK_TEST: this will print %d stars and then\n", NUM_DELAYS);
printf(" exit (test_lock.ock,_FILE__, _LINE__, _;
printf("ifS_LOCK) TAS(\n"
fflush(stdout);
s_lock(&test_lock.lock, __}
lock n) return1;
}
#endif/* S_LOCK_TEST */
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.