October25,2006AnewMonoGCPaoloMolarolupus@novell.
com2CurrentGC:whyBoehmPortedtothemajorarchitecturesandsystemsFeaturefullVeryeasytointegrateHandlesmanagedpointersinunmanagedlandSomesupportfortypedobjectsFinalizationsemanticsmostlymatchWeakreferencesHightlytunedThread-localalloc3CurrentGC:whynotWedon'tneedorusesomeofthefeaturesIncremental(handlingofsignals.
.
.
)Resourceusage(publicAPI)FinalizationsemanticsnotthesameasneededFinalizationofobjectsinvolvedincycles(whichorder)WeakreferencesupportTrackresurrectionHeapfragmentationZeroingoverhead(atomicalloc.
.
.
)Pausetimes4NewGC:needsExactfinalizationandweakreferencesemanticsSmallheapsizesandlow-pausetime(desktopapps)Objectpinning(automaticandAPI-controlled)Fastallocation(bump-pointerandinlinableinmanagedcode)LargeobjecthandlingPrecisetypetracking5NewGC:needs(continued)InteriorpointersonthestackAppdomainunloadissues(freealltheobjectsintheappdomain)Allocationofnon-movingobjects(internedstrings.
.
.
)Nicetotheuser(nobigmemorychunk)StillalloweasyembeddingofMonoKeepingtheonlyreferencetoamanagedobjectintheCstackisfineThreadsupport6ImplementationGenerationalOldgenerationandnursery(thenewgeneration)MovingFromthenurserytotheoldgenerationCompactingoftheoldgenerationStoptheworldcollectionLargeobjectspaceCollectedwithmark&sweepduringmajorcollectionsFixedheapForinternedstrings(andmaybelaterothertypes)Collectedwithmark&sweepduringmajorcollections7GetHashCode()Objectsnowcanmove,can'tusetheobjectaddressashashcodeDatastoredinthelockwordoftheheaderWhentheobjectislocked,thehashcodeismovedinsidethefatlockstructureLoad+check+shiftinthefastpathAdditionalcheck+loadotherwiseInterlockedopwhenfirstsettingthehashmono_object_hash()forruntimehashtables8PinnedobjectsHowtocreatethem:corlibAPI:GCHandleembeddingAPI:mono_gchandle_new(obj,TRUE)fixedC#statement(PINNEDflagforlocalILvars)duringP/InvokecallsAdditionalcasesobjectsandpointersfoundintheuntypedCstackoftheruntimeandembeddingapplicationsobjectstheruntimesdoesn'twanttomove(internedstrings,Threadobjects,currentlyTypehandles)Fewoftheminpractice9PinnedobjectissuesWillfragmenttheheapWillcausemorecollectionsWillslowdownallocationsandcollectionsMakesureyoupinobjectsonlywhenreallyneededandforaslittletimeaspossibleRuntimeenhancements:TypeinformationaboutregistersandmanagedstackframeswillallowtoconsiderthereferencedobjectsnotpinnedUnmanagedstackframeswillstillpinreferencedobjectsforhassle-freeruntimecodeandmonoembedding10Pinnedobjects:findingthemGivena(possiblyinterior)pointerObjectsareallocatedsequentiallyNeedtostartfromthebeginningofanheaparea,visitingeachobjectuntilthecorrectoneisfoundDuringallocation,every4KBsavetheobjectstart–Needtoscanatmost4KBofmemorytofindobject–4KBsizeissubjecttochange–ThepinningaddressesaresortedandthelastpinnedobjectiscachedsousuallythisscanningisveryfastWhenfoundsetthePINflagoraddtopinnedobjectsarray11ThenurseryMostobjectsbornhereTypically512KB-2MBforcommonappsServersmightwantseveralMbsBump-pointerallocationstyleFastandcanbeinlinedinmanagedcodeWhenfull,triggeraminorcollectionUnlessamajorcollectionisneeded(oldgenerationisfull,too)Dividedinsmallerchunksduetofragmentationorthread-localallocation12NurseryandpinningPinnedobjectsfragmentthenurseryChunksoffreenurseryspacebetweenpinnedobjectsusedforallocationsWhenthenurseryiscompletelypinned,allocateobjectsintheoldgenerationAlternativesinclude:enlargethenursery,allocateanewnurseryPinobjectsonlywhenaboslutelyneededforshortamoutsoftimeTrackreferencespreciselyonthestack13MinorcollectionStoptheworldIdentifypinningobjectsScantheroots(includingpinnedobjects)CopytooldgenerationasyougoPlacepointertonewcopyintheoldobject'splaceScanthecopiedobjects(theyareroots,too)Checkthefinalizationandweak-reflistsPreparefornewallocsRestarttheworldPokethefinalizerthread14StoppingtheworldNeededtonotallowthemutatorstoseenon-coherentdatainobjectsforwardingpointersflagsintheobjectheadertwocopiesofthesameobjectNosupportforsafepoints(yet)Implementedwithsignalswin32/OSXhaveproperOSsupportLessthan1msforheapsupto100MBon1.
6PMParallelizemajorcollectionlater15TherootsStaticmanagedvariablesRegisteredroots(runtimeandembeddingdatastrutcures)HandletablesRememberedsetsOld-generationobjectsreferencingnurseryobjectsPinnedobjectsRuntimestackNeedtypeinfoforregistersandmanagedstackframes16HowtocopyanobjectEnsurewehaveenoughroomintheoldgenerationWeneedtoensureeveryreferencepointstothenewobjectForeachpointerfieldobj.
field=copy_object(obj.
field);Placeaforwardingpointerintheheader–It'sthepointertothenewhomeoftheobjectIfanobjecthasaforwardingpointerit'salreadycopiedPinnedobjectsreturnthesamepointerincopy_object()17ThemarkingstackWeneedtorecursivelycopytheobjectsreferencedbycopiedobjectRecursionnotasafethingintheGCTheruntimestackcouldbeverysmallandtherecursionverydeepThecopiedobjectsareaisanexplicitstackOncetherootsarescanned,scanthecopiedarea,untilnomoreobjectsarecopiedGrayobjectsaremarkedbutthefieldshavenotbeentraced18FinalizationWhentherootsarescanned,thenon-copiedobjectsaregarbageunlesstheyarepinnedorneedfinalizationCopyfinalizableobjectstotheoldgenerationsotheysurviveRecursivelycopyfromtheirfields,tooLoopuntilnomorefinalizableobjectsarefounddeadPutfinalizableobjectsinaseparatelistWeak-refsdon'tneedcopyinghandledimmediately19PreparefornewallocsCreatelistoffreefragmentsinnurserymemsetthememoryto0bytestoomuchoverheaddoingitateachobjectalloctoomuchoverheaddoingitforthewholenursery–touchestoomuchmemoryandtrashesthedatacache–doitonlyafragmentatatimeweneedunusednurseryareastobezeroedbeforecollectionsforthepinned-objectsfindingalgorithmAssignfragmentstothreadstoeachasmuchastheyneed(andresourcesallow)20MajorcollectionCurrentlycopy-basedLaterusemark/copytoreducememoryrequirementsIdentifypinnedobjectsinthewholeheapRememberedsetsareclearedScantherootsasusualLargeandfixedobjectsarejustmarkedbysettingaflagintheobjectheaderSweepunmarkedobjectsFreeunusedsectionsFinalize/Prepare/Restart21ObjectsweepingWalkthelistoflargeobjectsandfreetheunmarkedonesUnsetthemarkflagfortheothersFixedobjectsareinpinnedchunksfreedbyputtinginafree-listunmarkedaswellBoththelargeobjectlistandthenumberoffixedobjectsshouldbesmall22MemorysectionsHeapdividedinsectionsMoreflexiblethanusingabigvirtualareaEasierfortheuserExpandsasneededFairtoothercodeinthesameprogramcompetingforvirtualaddressspaceOfcourseit'shardertoimplementsomeperformanceissueslikelythedefaulton64bitsystems(hugevirtualmemoryspace)23PinnedchunksDatastructureforGC-internaldataandforfixedobjectallocationOnlyforsmallobjectsEachpagehasobjectsofsamesizeAllocationusingfreelistsPageassignedtoasizeasneededLimitedfragmentationissues(fewsizes,mostlyruntimeandGC-controlled)Mini-BoehmGCincluded24LargeobjectsExpensivetomoveCurrentlyusedforobjectsize>=64KBCollectedonlyduringmajorcollectionsusingmarkandsweepAllocatedwithmmapalreadycleared,noneedtotouchpagesNeedfortuningknobshowmuchmemorydoweallowinlargeobjectsbeforeamajorcollection25ObjectlayoutKeepreferencesclosetoeachotherBettercachelocalityBetterencodingofreferencebitmapsDegeneratecases.
.
.
Doctor,ithurtsWeshouldsetreasonablelimitsforuntrustedcodeTheJVMdoeshaveamuchbettertimewiththis.
.
.
nostructsnofixedorsequentiallayout26GCdescriptorsSeveraltypesneeded:stringsvectorsbitmapsrun-lengthencodinglargebitmapsFasthandlingofptrfreeobjectsandarraysStoredinMonoVTable27WritebarriersKeeptrackofreferencestonurseryobjectsfromtheoldgeneration:theybecomerootsforaminorcollectionComplicatedbystructsareferencecanbestoredintheheaporonthestackcopyofstructsCustomonesoptimizedforeachcasearraycopystructhandling28API/ABIchangesAfewsimplechangesneededforruntimehackersandembeddersObjectscanmove,sotheGCneedstoknowaboutallreferencesortheymustbepinnedsomeway–NomorevalidtoknowanobjectiskeptaliveandstoreareferenceinmallocmemoryFieldandarrayelementsettingmustgothroughwritebarriers–OnlyreferencesorvaluetypeswithreferencesInteriorpointerissues–ApointertotheendofanobjectisnotavalidinteriorpointerNewAPI:–MONO_OBJECT_SETREF(object,fieldname,value)–mono_array_setref(array,index,value)29TODOlistUsemark-compactforoldgenerationcollectionReducesmemoryrequiredforoldgencollectionUsemark-tablebasedwritebarriersFasterandinlineableThread-localallocationRemoveslockoverheadInlineallocationinjittedmanagedcodeNomanagedunmanagedtransitionsPrecisestackwalkReduceriskoffalsepositiveGCreferencesFixtheruntime30PreliminaryresultsStilluntuned,soexpectimprovementswritebarriers,thread-localalloc,alloccodeinliningSome(rare:-)testcases:5-7xspeedupUsually(withthread-local-alloc):10-50%speedupUsuallysmallerheap(butminimumislarger)Degeneratecases:manypinnedobjectsmanyreferencestores(writebarriers)longlinkedlists31KernelhelpThreadstart/stopneedtobeabletogetcontextofstoppedthreadmprotect(addr,size,MAP_DISCARD);dropthepagesfrommemorywillbeclearedwhenreadagainPagetablesdirtybitaccessMorecoarsewritebarriersupportNoneedforwritebarriersFixed(andpossiblytoolarge)markwindow32CompactingGarbageCollector.
33CompactingCollector34Nursery.
35NurseryandPinnedObjects.
在前面的文章中就有介绍到半月湾Half Moon Bay Cloud服务商有提供洛杉矶DC5数据中心云服务器,这个堪比我们可能熟悉的某服务商,如果我们有用过的话会发现这个服务商的价格比较贵,而且一直缺货。这里,于是半月湾服务商看到机会来了,于是有新增同机房的CN2 GIA优化线路。在之前的文章中介绍到Half Moon Bay Cloud DC5机房且进行过测评。这次的变化是从原来基础的年付49....
BuyVM商家属于比较老牌的服务商,早年有提供低价年付便宜VPS主机还记得曾经半夜的时候抢购的。但是由于这个商家风控非常严格,即便是有些是正常的操作也会导致被封账户,所以后来陆续无人去理睬,估计被我们风控的抢购低价VPS主机已经手足无措。这两年商家重新调整,而且风控也比较规范,比如才入手他们新上线的流媒体优化VPS主机也没有不适的提示。目前,BuyVM商家有提供新泽西、迈阿密等四个机房的VPS主机...
特网云特网云为您提供高速、稳定、安全、弹性的云计算服务计算、存储、监控、安全,完善的云产品满足您的一切所需,深耕云计算领域10余年;我们拥有前沿的核心技术,始终致力于为政府机构、企业组织和个人开发者提供稳定、安全、可靠、高性价比的云计算产品与服务。官方网站:https://www.56dr.com/ 10年老品牌 值得信赖 有需要的请联系======================特网云美国高防御...
uctools为你推荐
aspweb服务器web服务器怎样才能支持.asp重庆网络公司一九互联网络公司做一个网站大概需要多少钱filezillaserver如何使用filezilla server波音737起飞爆胎飞机会爆胎?netshwinsockreset开始-运行-输入CMD-确定-输入netsh winsock reset,按Enter确定。然后重启。 是什么意思flashfxp注册码谁有~FLASHfxp V3.0.2的注册码~~谢谢哦!!要现在能用的!!!!文档下载手机下载的文件在哪里能找到传奇域名谁能帮忙查查传奇的IP和域名3g手机有哪些现在有哪些比较适用的3g手机?佛山海虹广东海虹药通电子商务有限公司怎么样?
国外免费vps 北京vps主机 域名备案流程 主机评测 fdcservers hawkhost siteground windows主机 wavecom mobaxterm typecho 镇江联通宽带 html空间 福建天翼加速 ntfs格式分区 秒杀汇 美国免费空间 流媒体加速 中国电信测速器 lick 更多