\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@skddlmZddlZddlZddlZddlZddlZddlZyddlZej Wn!e k rddl m ZnXddl mZddlmZmZmZmZmZdZdZejsejrd ZejZn d ZeZed Zed Zd ZdZ dZ!ejrRe!Z"n eZ"e Z#dZ$dS(i(tabsolute_importNi(t selectors2(t_(tencodingterrortpycompattscmutiltutilcC@sy)ttjd}|dkr(|SWnttfk rBnXy'ttjd}|dkri|SWnttfk rnXdS(s-try to count the number of CPUs on the systemtSC_NPROCESSORS_ONLNitNUMBER_OF_PROCESSORSi(tinttostsysconftAttributeErrort ValueErrorRtenvirontKeyError(tn((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt countcpus s  cC@s}|jdd}|rdy t|}|dkr7|SWqdtk r`tjtdqdXntttddS(Ntworkertnumcpusis!number of cpus must be an integerii ( tconfigR RRtAbortRtmintmaxR(tuitsR((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt _numworkers5s   g{Gz?gꌠ9Y>)FcC@sG| rtrtS||}t|}|t|||}|dkS(setry to determine whether the benefit of multiple processes can outweigh the cost of starting themg333333?(t_DISALLOW_THREAD_UNSAFEtFalseRt _STARTUP_COST(Rt costperoptnopst threadsafetlineartworkerstbenefit((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt worthwhileJs    cC@sZ|jdd}|rIt||t|d|rIt||||S|||fS(srun a function, possibly in parallel in multiple worker processes. returns a progress iterator costperarg - cost of a single task func - function to run staticargs - arguments to pass to every invocation of the function args - arguments to split into chunks, to pass to individual workers threadsafe - whether work items are thread safe and can be executed using a thread-based worker. Should be disabled for CPU heavy tasks that don't release the GIL. RtenabledR!(t configboolR%tlent_platformworker(Rt costperargtfunct staticargstargsR!R&((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyRVs$c #@st|}tjtjtjtjtjtdgfdtfd  fd}tjtj||jt j }gxdt ||D]St j \ j  fd}zyut j}|dkrltjtjtjtj fd} tj|| }nWnOt j |krntjd} t| t } |jd| nXWdt j |kr zy|jWnnXWdt j|d@XnXj|qWtj xCD];\ t j  jt jd dtjq.W fd } yt} x| dkrFx jD]\}}yt j!j"|j#VWqt$k r j%|j#|j#j| d 8} qt&k r>}|j't'j(kr8qnqXqWqWWn| nX| }|r|dkrt j)t j | ntj*|ndS( Nic@smtjtjxSD]K}ytj|tjWqtk rd}|jtjkreqeqXqWdS(N(tsignaltSIGCHLDR tkilltSIGTERMtOSErrorterrnotESRCH(tpterr(toldchldhandlertpids(s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt killworkersss c@sxjD]}d}}xtry,tj||r>dntj\}}PWq tk r}|jtjkr|q q|jtjkrj |Pqq Xq W|sq nj |t |}|r d r |dR0texit(RR+R,R-R#RJt parentpidtretRCRVtexctypeRWR\t openpipestkeyteventsREtstatus(( R+R9R7RZRRR8RSRFRTR[R,RGRUs6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt _posixworkerns         &      cC@s=tj|rtj|Stj|r9tj| SdS(sconvert a posix exit status into the same form returned by os.spawnv returns None if the process was stopped instead of exitingN(R t WIFEXITEDt WEXITSTATUSt WIFSIGNALEDtWTERMSIG(tcode((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt_posixexitstatuss c#@sdtjfdY}gfd}t}tjj}tjj}x(t||dD]} |j| qoWx@t|D]2} |||||} j | | j qWyxt dkrqx|j s|j VqWdjdgD]} | js| ^q} x6| D].} | jdk r]| jnj| q<WqWWn!ttfk r|nXx|j s|j VqWdS(NtWorkercB@s/eZdddddZdZdZRS(c S@sktjj|d|d|d|d|||_||_||_||_t|_t |_ d|_ dS(Ntgroupttargettnametverbose( t threadingtThreadt__init__t _taskqueuet _resultqueuet_funct _staticargsRt _interruptedR;tdaemontNonet exception( tselft taskqueuet resultqueueR+R,RRRR((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyRs       cS@s t|_dS(N(R;R(R((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt interrupt scS@syx|jjsyT|jj}x>|j|j|fD]#}|jj||jrAdSqAWWqtj j k rPqXqWWnt k r}||_ nXdS(N( Rtemptyt get_nowaitRRRtputRRtqueuetEmptyt ExceptionR(RR-tresRE((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pytrun s     N(t__name__t __module__RRRR(((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyRs c@stjd}xD]}|jqWxND]F}|tj}|j||jr2jtddSq2WdS(Nis:failed to kill worker threads while handling an exception (ttimeRtjointis_alivetwarnR(t cleanupendttt remainingtime(tthreadsR(s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyttrykillworkers!s    iig?(RRRRRtQueueRbRtrangeRdtstartR(RtgetRRRRtremoveRRj(RR+R,R-RRR#RRRRt_iRt_ttfinishedthreads((RRs6/usr/lib64/python2.7/site-packages/mercurial/worker.pyt_windowsworkers6$  %  cc@s-x&t|D]}||d|Vq WdS(spartition a list into N slices of roughly equal size The current strategy takes every Nth element from the input. If we ever write workers that need to preserve grouping in input we should consider allowing callers to specify a partition strategy. mpm is not a fan of this partitioning strategy when files are involved. In his words: Single-threaded Mercurial makes a point of creating and visiting files in a fixed order (alphabetical). When creating files in order, a typical filesystem is likely to allocate them on nearby regions on disk. Thus, when revisiting in the same order, locality is maximized and various forms of OS and disk-level caching and read-ahead get a chance to work. This effect can be quite significant on spinning disks. I discovered it circa Mercurial v0.4 when revlogs were named by hashes of filenames. Tarring a repo and copying it to another disk effectively randomized the revlog ordering on disk by sorting the revlogs by hash and suddenly performance of my kernel checkout benchmark dropped by ~10x because the "working set" of sectors visited no longer fit in the drive's cache and the workload switched from streaming to random I/O. What we should really be doing is have workers read filenames from a ordered queue. This preserves locality and also keeps any worker from getting more than one file out of balance. N(R(tlsttnslicesti((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyRbSs(%t __future__RR3R R.RgRRRnt BaseSelectort ImportErrort thirdpartyRti18nRtRRRRRRRtisposixt iswindowsRRRR;R%RRRRR)RARb(((s6/usr/lib64/python2.7/site-packages/mercurial/worker.pyts<         (     R