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.
弘速云怎么样?弘速云是创建于2021年的品牌,运营该品牌的公司HOSU LIMITED(中文名称弘速科技有限公司)公司成立于2021年国内公司注册于2019年。HOSU LIMITED主要从事出售香港vps、美国VPS、香港独立服务器、香港站群服务器等,目前在售VPS线路有CN2+BGP、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。可联系商家代安装iso系统,目前推出全场vps新开7折,...
hosthatch在做美国独立日促销,可能你会说这操作是不是晚了一个月?对,为了准备资源等,他们拖延到现在才有空,这次是针对自己全球14个数据中心的VPS。提前示警:各个数据中心的网络没有一个是针对中国直连的,都会绕道而且ping值比较高,想买的考虑清楚再说!官方网站:https://hosthatch.com所有VPS都基于KVM虚拟,支持PayPal在内的多种付款方式!芝加哥(大硬盘)VPS5...
春节期间我们很多朋友都在忙着吃好喝好,当然有时候也会偶然的上网看看。对于我们站长用户来说,基本上需要等到初八之后才会开工,现在有空就看看是否有商家的促销。这里看到来自HMBcloud半月湾服务商有提供两款春节机房方案的VPS主机88折促销活动,分别是来自洛杉矶CN2 GIA和日本CN2的方案。八八折优惠码:CNY-GIA第一、洛杉矶CN2 GIA美国原生IP地址、72小时退款保障、三网回程CN2 ...
uctools为你推荐
新闻联播网易yeahcuteftpCuteFTP Pro如何使用?重庆400年老树穿楼生长生长百年的老树,仍能不断生长,是因为主要有什么组织面板flash爱优网为什么优酷土豆等视频网站那么多人上传视频温州商标注册温州注册公司在哪里注册tumblr上不去为什么,爱看软件打不开?页面一直在加载35邮箱邮箱地址怎么写艾泰科技艾泰的品牌介绍开源网店系统国内有哪些好的java开源电子商城系统
域名备案只选云聚达 t牌 163网 godaddy优惠码 Hello图床 香港新世界电讯 回程路由 国外php空间 灵动鬼影 卡巴斯基官方免费版 七夕促销 美国堪萨斯 搜索引擎提交入口 vip域名 空间购买 独立主机 贵阳电信 注册阿里云邮箱 购买空间 宿迁服务器 更多