Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. in 6 era 2020 Februar 26. Wien, erun:A.nvPo.Dp.Ig rtcn nra Krall Andreas Dr.techn. Dipl.-Ing. Ao.Univ.Prof. Betreuung: Wien Universität Technischen der Informatik für Fakultät der an atal eeec one Heap Counted Reference Partially fcetCceDtcino a on Detection Cycle Efficient -00Wien A-1040 otaeEgneig&Itre Computing Internet & Engineering Software u ragn e kdmshnGrades akademischen des Erlangung zur alpaz13 Karlsplatz arklumr01225423 Matrikelnummer Diplom-Ingenieur mRhe e Studiums des Rahmen im ehiceUiesttWien Universität Technische DIPLOMARBEIT tfnByr BSc Beyer, Stefan igrih von eingereicht tfnBeyer Stefan e.+43-1-58801-0 Tel. www.tuwien.at nra Krall Andreas Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ina 26 Vienna, dio:A.nvPo.Dp.Ig rtcn nra Krall Andreas Dr.techn. Dipl.-Ing. Ao.Univ.Prof. Advisor: Wien TU the at Informatics of Faculty the to atal eeec one Heap Counted Reference Partially fcetCceDtcino a on Detection Cycle Efficient th eray 2020 February, umte nprilfllmn fterqieet o h ereof degree the for requirements the of fulfillment partial in submitted -00Wien A-1040 otaeEgneig&Itre Computing Internet & Engineering Software alpaz13 Karlsplatz eitainNme 01225423 Number Registration ILM THESIS DIPLOMA Diplom-Ingenieur ehiceUiesttWien Universität Technische tfnByr BSc Beyer, Stefan tfnBeyer Stefan e.+43-1-58801-0 Tel. by in www.tuwien.at nra Krall Andreas Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. in 6 era 2020 Februar 26. Wien, naedrQel l nlhugkntihgmcthabe. gemacht kenntlich Entlehnung als oder Werken Quelle anderen der die Angabe –, Abbildungen und Karten Tabellen, einschließlich – Arbeit e nenti otatoe e innc nnme id u ee alunter Fall jeden auf sind, entnommen nach Sinn dem der oder Stellen Wortlaut die im verwen- ich Internet die dass dem ich und dass habe habe, angegeben verfasst vollständig selbständig Hilfsmittel Arbeit und diese Quellen ich deten dass ich, erkläre Hiermit BSc Beyer, Stefan rlrn u efsugder Verfassung zur Erklärung tfnBeyer Stefan Arbeit v Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ri ioudRcadPage.Iral atmc ih u ezihtWillkommen herzlichst nur nicht mich habt alle Ihr Plangger. Richard und Rigo Armin bedanke Bemühung ununterbrochene ihre für meiner bei mich ich will Außerdem ene olrFae a,hb c ergshtt erwrvl ae uhdetollen die auch waren wertvoll Sehr geschätzt. sehr ich habe war, Fragen voller er wenn Frage eine ich immer auch wann Rückmeldungen, hilfreiche Tage oder Stunden weniger n i nesüzn,deirmrzkme atlse,sh uschätzen. zu sehr lassen, Hilfestellungen habt die zukommen ich mir weiß nehmen, ihr ich zu die wenn Anspruch Unterstützung, Auch mit in die bleiben. Hilfe auch zu eure und mir Weg um sondern richtigen war, geliefert, am stolz geholfen, zu Arbeit manchmal Wissen meine eurem für und Idee Erfahrung bei ursprüngliche eurer anderem die unter mir bedanken, und PyPy-Team geheißen beim auch mich bekommen. ich fertig möchte nicht Letzt ebenfalls Ohne guter war. wohl Zu Lachen Arbeit zum diese nicht ich manchmal mir hätte und wenn allen auch gegeben euch haben, Selbstbewusstsein gebracht Lachen mir zum die mich Improtheatergruppe, freizubekommen meiner Kopf mit mit Erfahrungen meinen Ausfahrten wann haben gemeinsamen haben, geholfen Die geliehen mir brauchte. mir die Zuhören sie Mountainbike-Gruppe, zum das Kollegen meiner jemanden bedanken, und Ohr ich Freunden offenes meinen immer Familie, ihr auch meiner und Rest Gesellschaft beim ihre noch für hätte mich dich, ich Ohne möchte vollenden. benötigt. Zudem zu emotionale Zeit Arbeit die mehr diese und viel um Motivation noch hat wahrscheinlich die gegeben ich für ebenfalls mir danken, das sie Chiara ich die Freundin Unterstützung, dass meiner weißt, auch du will hoffe Ich Ich glauben. mein zu halte. mich auf selbstverständlich an mich für aufgehört ich nicht angekommen, nie sodass immer hast nicht unterstützen, vielleicht du zu sind aber Ratschläge stets Deine mich konnte. konzentrieren und Studium fernzuhalten mir von alles anstrengen, Diplomarbeit seine ihre um für wirklich sich ist. sich selbstverständlich sie er nicht sehr dass das wie Eindruck, etwas versteht den und habe innerhalb Ich kümmert, mir hatte. Studenten er begutachten gab zu habe, etwas benötigt oder Arbeit anhaltende diese seine für bedanken. für Ewigkeit halten, Krall, gefühlte zu motiviert Andreas eine und ich Professor, fokussiert Obwohl meinem mich Bemühungen, bei seine mich und Unterstützung ich will allererst Zu Danksagung vii n, Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. lo ol iet hn l fm aiy red n olausfrtercompany their for colleagues and friends family, my of all thank to like would I Also, au h ra xeine a ihm mrvstoa har ru,wohle me helped who group, theatre improvisational my with had I experiences great the value vntog a oeie o ru ose epfo o,Iral preit the apprieciate really knowledge. I you, and from experience help me. their seek gave sharing idea to you initial by proud guidance the track too and Armin and on sometimes support welcome to me was warm limited I kept a not though also me but Even but gave including thesis, only team, not this PyPy who for the Plangger, thank finished Richard would have and I not Rigo least would not I but it. also Last needed you. I I of questions. when all of laugh, without full me my thesis, was made with this I and tours when confidence the mind, enjoyed my my really gaining free I to to. me talk helped to who someone crew, needed bike I mountain even when me ear, taken friendly probably and have would It line. finish support you. the emotional granted. for to and for motivation not thesis this the if this never take for longer, bring you not Chiara, to girlfriend, do but me, my also gave heard, thank I she to been that like always know, also you have would my I hope not on I might concentrate she me. could me everything in I gave keeping so believing you at me, stopped efforts, advice supporting ongoing The always her and for me studies. mother from thesis, my away their thank could into it to possibly put like me they To also work granted. would review. hard for I to taken the within something and be advice or students not helpful question his should me a for that gave had though cares something he I Even really paper, whenever he thesis. of days, like my piece or seems on this support hours work continuing finish of to his to matter motivated for forever a and Krall, almost focused Andreas me me professor, took keeping my it thank at to efforts like his would and I all, of First Acknowledgements ix Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. iesädgbtahe edn ietiwieuden oltni nrmnel Version inkrementelle vollständig eine und teilweise Eine werden. betrachtet eigenständig opnir ednkn,drdrhdevlsädg nerto edrAsteentsteht. Ansätze Mehraufwands beider des Integration Teil vollständige großer die ein durch und der inkre- ist kann, vollständig werden gut der kompensiert relativ Verhalten Algorithmus das des eigener dass Version mithilfe zeigen, mentellen Ergebnisse und Die verifiziert Die verglichen. Tests bewiesen. Benchmarks aufwändiger semiformell mittels Korrektheit wurden deren Implementierungen und entworfen wurden Algorithmus dieses [ JyNI-Integration Jython’s an unterstützen. ist Algorithmus zu Just-in-time-Compiler finale CPython-Erweiterungsmodulen PyPy von Der im Integration Collector wurden die Algorithmus Garbage um deren dieses implementiert, Versionen und Technologien Zwei gleichzeitig integrierenden hält. und zu niedrig kann, die typischerwei- werden auf das ermöglicht gefunden Auswirkungen Problem es Compiler-Ebene die ein der auf erkennen, und Sprachintegrationen zu vereint, in Algo- Weise Heaps se effiziente einen referenzgezählten auf es, teilweise Ansätze ist auf beide Arbeit Zyklen der dieser finden, Ziel Counting. zu grund- rithmus Reference zwei und existieren Tracing Collection, Ansätze: Garbage legende kurz Speicherbereinigung, automatisierten Zur Kurzfassung Ric16 neen,kn brals aber kann angelehnt, ] xi Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. w seta abg olcintcnqe xs:taigadrfrnecutn.The counting. reference and tracing exist: techniques collection garbage essential Two loih em obhv ut eladi bet opnaealto h introduced the of lot a mechanisms. compensate collection to garbage able the both is integrating of and version fully well fully-incremental of quite overhead, the by behave that measured to reveal, is The seems results efficiency algorithm proof. The their semi-formal and benchmarks. a tests several by sophisticated running established using is verified correctness are integrations their implementations GC and Jython’s designed by are influenced algorithm CPython been of [ has integration JyNI algorithm are the for final algorithm support The the to of compiler modules. integrated versions just-in-time extension Two both PyPy low. the on collector found in impact and garbage typically implemented approaches the existing is keeping both their which combine while and problem efficiently technologies integrations, a to heaps, language counted algorithm, compiler-level reference an in partially find in to cycles is collect work this of goal Ric16 ,btsilsad nison ei n ul-nrmna esoso this of versions fully-incremental and Semi- own. its on stands still but ], Abstract xiii Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Introduction 1 Contents Abstract Kurzfassung tt fteArt the of State 2 Algorithms 3 Implementation 4 Results 5 . olo hsWr 4 3 ...... 4 ...... 2 3 ...... 1 ...... Work . . this . . . . of . . . Goal . . Heap . . Counted . . . . Reference 1.6 . . Partially ...... Heaps 1.5 . . Partitioned . . . Collection . Garbage . 1.4 Incremental . . Counting . Reference 1.3 Cyclic Counting Reference and 1.2 Tracing 1.1 . Pto 9 10 . 5 ...... 11 ...... integration . . .NET/COM . Microsoft ...... JyNI 2.4 . . Jython’s . . . . 2.3 CPython . cpyext and 2.2 PyPy 2.1 . ul-nrmna loih 28 14 ...... Algorithm Fully-Incremental . . Algorithm 3.2 Semi-Incremental 3.1 . eicto 50 ...... 37 39 . 46 . . . 42 ...... Verification ...... 4.5 Implementation . Fully-Incremental ...... Implementation 4.4 . Semi-Incremental . . Rawrefcount . 4.3 Extending . Architecture 4.2 PyPy 4.1 . xetdRsls...... 59 55 ...... Results . Expected . . 5.2 Benchmarks 5.1 Contents xiii xv 55 13 37 xv xi 5 1 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Conclusion 6 Appendix Bibliography Algorithms of List Tables of List Figures of List diinlBnhakRsls...... 91 ...... Results Benchmark Additional . umr 75 73 ...... 59 . 70 ...... Summary . . . . . 5.6 . Issues . . . Benchmarks 5.5 . Application . . 5.4 Microbenchmarks 5.3 . uueWr 78 77 ...... Work Future . . 6.2 Application 6.1 83 85 79 77 81 91 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. . rcn n eeec Counting Reference and Tracing 1.1 tcnntdtc ed ylcsrcue,a hi eeec on lassasaoezero. above stays always count reference their graphs, as most for structures, works cyclic it dead, While detect counting. not reference can with issue it severe a one into is Even subsumed there checks. However, be [BCR04]. further can collection any they garbage without different, of and fundamentally count theory instantly so or universal the freed seem increased Once be techniques and can created. both locally are object though stored the object is zero, the object whole to to an the drops references tracing of new of references when Reference Indstead or ingoing accordingly, mark all objects. objects. decreased we of of live liveliness whether count (potentially) the the roots, of on those graph, this set view from from different the the reachable starting a determine applies by graph are can counting object accessed objects we whole live directly objects, the All visited be trace copy can we roots. from if that static starting so or regions, objects, roots, live roots memory of all stack are trace all like Roots to but application, need collection, roots. algorithms they Tracing copying mutator that common, and the algorithms. in mark-compact basic have mark-sweep, simple algorithms into very those unused two divided free and to be detect down might to boil approaches and all algorithms they different memory, of amount huge the Despite where situations with other. cope each to combining alongside efficiently, with used algorithm concerned are single is both a even thesis into This conducted, collection approaches garbage counting. still two essential reference those is Two and field tracing established. this well exist: already in techniques integrated are Research an fundamentals collection the development. garbage though software makes papers modern etc. first of C# the part JavaScript, with Python, decade, Java, a like [ half languages 1960ies than the more to for back around reaching been has collection Garbage JHM11 .Tewd dpinaogtpplrprogramming popular amongst adoption wide The ]. Introduction CHAPTER 1 1 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 2 .Introduction 1. . ylcRfrneCounting Reference Cyclic 1.2 osleti su,acmo prahi oueatcnqecle akptaig where tracing, backup called technique a use to is approach common a issue, this solve To ra eein sasd ffc,mgtb sdt dniyol mlctykonmutator known implicitly only identify to used be might effect, side a as deletion, Trial eas fteseic ftelnug,tildlto ih lob sdo h whole the on used be paper. also original example might for the deletion objects, in of trial described set language, as a the graph, such of identify object to specifics able the not of is because algorithm collection garbage the If as works and dead graphs where counted reference graph, on object applied the be of only parts can those follows: [ It traces tracing suspected. partial only are perform tracing, cycles to global employed to be contrast also in can it but roots, observations: two on based is It [JHM11]. structures cyclic handling [ for unreachable technique become they [ once efficient them which and clear reference, to the order [ identify in [ efficiently to cycle, problem reference proposed, a this been creates solve have to approaches several how Historically, on made discovered, first been was has [HLM09]. cycles from research [CYTW10], reference away of of memory problem unused lot the freeing a since of Thus, collection responsibility approach. garbage the developers. different as keep application a strategy, to prefer consistent introduced respon- to a primarily of like tend is seems lot developers automatically a language cycles transfers most such cycles, so Detecting reference developer, create the to to not sibility developer application the sections. Forcing upcoming the in see will we as been efficiently, has so research do few to solution, a the how obvious into also on an them is field like integrate This this seems to in cycles. this opportunity made those though ideal clear Even an to and algorithm. time, overlap, single to approaches time both from where executed point, is algorithm tracing a Bro85 1. .Ceralojcs(rmti e) hs eeec on szero. is count reference whose set), this (from objects all Clear zero. 4. than greater count reference external) (= remainig a 3. with objects for Scan 2. • • rc h rp,satn rmteeojcsadices h eeec on fall of count reference the increase and objects respectively. these objects from reachable starting all graph, the (including Trace objects identified of set the from objects). references reachable internal all Deduct count reference a leaves that deletion pointer a zero. from than only greater arise (between can pointers cycles internal Garbage from result structure). counts the reference in all objects cycle, isolated any In ,[ ], Sal87 JL96 ,[ ], PvEP88 ,.Tildlto [ deletion Trial . ], ,[ ], Axf90 .Hwvr oeo hmhsytpoe ob safe be to proven yet has them of none However, ]. Chr84 ,o h te ad sanwwdl adopted widely now a is hand, other the on ], MWL90 .Priltracing, Partial ]. SBYM13 FW79 ], ], Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. . attoe Heaps Partitioned 1.4 Collection Garbage Incremental 1.3 sso stoo oelnugsaeitgae,tergraecleto approaches collection garbage their integrated, are languages more or two as soon As Generational heap. continous single, one on memory their manage always not Applications by attention of lot a seen has that collection, garbage with issue general Another hr ahha smngdb h epcielnug.Sm nertoste force then integrations Some language. respective the by managed is heap each where prahs si sarltvl ipebteetv praht oewt ogpause long with cope concurrent to approach to effective contrast but simple in relatively collection, a garbage is it incremental as prefer approaches, to seem developers efrac a lob mrvd ysaial eonzn bet htmgtnvrbe never might that objects recognizing statically by improved, be also can Performance ffratmtcsltosfrcern uhcce,a ewl e nteucmn sections. upcoming the in see will we as integrations, cycles, Other such cycles. clearing reference for creating solutions from automatic refrain offer to developer application the [ level compiler similar on offering application languages single programming a other into or integrated C be in might written support, code legacy so modules, [ of lot seems a This for simplicity progress. and make times to pause application performance, collection the between the allow applications. However, compromise to time. good time, in a any point like either one at at collection, paused runs incremental be their application with might the and because or proof is collector to This approaches garbage easier verify. Incremental the is to time. correctness easier same their are the synchronization, implementations as at sophisticated application, regions need the memory not with same do synchronized the be access to might need both always approaches Concurrent times. asynchronous the of variant a as well [ as algorithm optimization, the this of apply most detection. can for we cycle objects 3, such [ Chapter ignoring identified in and been see instead cycle, has time, a object in of single point part a later time a set each at the deletion, algorithm collecting trial Asynchronous by actual performing chapter. algorithm, the eagerly upcoming deletion performing of the trial and in the objects see of potential will execution we of as the cases, delays this which some detection in necessary, in cycle but is issue collector section), an garbage next be the to (see and proves application application trial the the allows between with synchronization detection concurrently case cycle executed proposed, Concurrent be been detection. to have cycle deletion approaches advanced asynchronous several or deletion, concurrent trial like of discovery the Since abg olcini utoe u eycmo esnfrpriinn h ep[ heap the partitioning for reason common very a but one, just is collection garbage lone ob nertd oto h ie,ti ol ont attoe heap, partitioned a to down boils this times, the of Most integrated. be to need also to algorithms introduced [ the counting by reference caused for interruptions also the minimum, keep a to how is researchers, ehoois[ technologies Ung84 .Aohroeo hs iutosmgtb neoeaiiybtendifferent between interoperability be might situations these of one Another ]. Inc .Mn oenpormiglnugsoe upr o level C for support offer languages programming modern Many ]. BR01 ,[ ], JHM11 .I rcie oelanguage some practice, In ]. ..IceetlGraeCollection Garbage Incremental 1.3. BR01 jni ,[ ], .A ewill we As ]. csh ,[ ], Lin92 LH83 pycb ], ]. ]. 3 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 4 .Introduction 1. . olo hsWork this of Goal 1.6 . atal eeec one Heap Counted Reference Partially 1.5 ihrfrnecutdhas h uao ot ontne ob nw explicitly. known be to need not do roots mutator the heaps, counted reference with h olwn hpe ie nitouto noPP n tsdfutgraecollector, garbage default it’s and PyPy into introduction an gives chapter following The implementing by efficiency its measure and algorithm this of versions two design will partially in cycles collect efficiently to algorithm, an find to is work this of goal The akptaigagrtm r yial eindt oewt hsise u typical but issue, this with cope to designed typically are algorithms tracing Backup swl sasotitouto noRctrsapoc ihJto n Microsoft’s and Jython problems. with similar solve approach to Richter’s .NET into and introduction COM unable. short with previously approach a was it as which well cycles, as such a collect As to benchmarks. able several be running then and will compiler PyPy just-in-time goal, PyPy rather side the a We in integrate collector. versions to garbage both algorithm mark-sweep an generational garbage find a existing to with scheme try their counting will and reference we technologies simple specifically, integrated More both low. while integrations, collector on language implications compiler-level the in found keeping typically heaps, counted reference times. pause low is, with question garbage efficiently, new the problems Finally, introduce these to integration. solve want each to with known not for how algorithm might are implementations, tracing we them and existing as of algorithms an algorithm, some collection combine tracing only to backup if how arbitrary problem roots, is, an first all problem the find second presents to The This how explicitly? roots. approaches: all both of integrating knowledge of explicit need algorithms tracing counting not. reference or is tracing generational other either the in using when explored generations counted, [ been multiple reference already with is has collectors, heap tracing garbage the with of counting partition reference one Combining case, special this In AP03 ,btti oi a o enmc teto usd fti ra hnworking When area. this of outside attention much seen not has topic this but ], Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. CPython IncMiniMark . yyadcpyext and PyPy 2.1 pr rmgnrtoa abg olcin atal eeec one ep aeneither have heaps counted reference partially collection, garbage generational from Apart h urn eso fPP ssa nrmna,gnrtoa abg olco called collector garbage generational incremental, an uses PyPy of version current The .. abg Collection Garbage 2.1.1 lsrlo ttegraecleto loih,ltu aeaqiklo ttememory the at look quick a a take take we us machine. Before let virtual algorithm, here. the collection covered of garbage not layout the are at but available, look also closer are collectors garbage Other CPython’s with compatible not is collector a scheme. garbage presents counting CPython’s mark-sweep this reference into PyPy, default integrate For the modules management. as extension memory problem, Those for implementation crucial. counting or be reference [ C to NumPy with seems like application support them, Python their of their Some extend code. to C++ opportunity compatibility the a called developers features modules, also application It extension CPython collection. garbage for for layer counting implementation reference standard of instead the tracing than [ faster programs programs Python Python execute for to compiler aiming mizations, just-in-time a is PyPy currently. problem this to solves regards PyPy partitioned with two how integrated how at fully at look look be a a can take take not, us issues, we one let similar Before other collection, solve PyPy. the garbage that in counted, applications solve reference some to one like also heaps, would are we there one and the exist like topic this on papers enetnieysuidi hoynrwdl dpe npatc.Hwvr oescientific some However, practice. in adapted widely nor theory in studied extensively been seucmn eto) ncnrs oteCyhnitrrtr yyuses PyPy interpreter, CPython the to contrast In section). upcoming (see [ pypa .Iciiaki yysdfutadrcmeddgraecollector. garbage recommended and default PyPy’s is IncMiniMark ]. num ,aevr oua mns eeoes so developers, amongst popular very are ], cpyext tt fteArt the of State Pto xeso oue offer modules extension CPython . pypc .I etrsmn opti- many features It ]. CHAPTER 5 2 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 6 Art the of State 2. w ye fcletosaeeeue:mnradmjrcletos olwn h weak the Following collections. major and minor executed: are collections of types Two .. eoyLayout Memory 2.1.2 .. eal Behavior Default 2.1.3 bet r oidt h eodgnrto.Mnrcletosaenticeetl in incremental, not are collections Minor surviving where generation. executed, second minor is the a collection to copy in copied simple collected are A are objects generation performance. young optimize the to in collection objects only hypothesis, non- generational a behaves and collector IncMiniMark counted the reference how at a look into have a default. take modules partitioned by will extension becomes we CPython partition, heap once counted behaviour, the reference altered and the loaded at look been a take we Before stay always will address their so promoted again, are moved are objects never Once Objects are same. they size. the heap. their generation, partitioned on second the depending a to structures, on memory generations various two in stored in objects handles IncMiniMark • • • • • rnscnanmlil ae,wihaeas aae nlss ae oti a contain Pages lists. in managed also are which pages, multiple contain Arenas h xc oaino rmtdojc iltu edtrie yissz and size its by determined be thus will object promoted a lists. of linked location in exact The managed are They system operating the by allocated are which usd.I hygtupne taltrpiti ie hywl vnulybe eventually will they time, in moved point not later are a and the generation. at in there second still stay unpinned the are to to get they forced promoted they their case are If In so they implementation, collector. pinned, outside. the are language by they the changed when by be nursery not pinned must get address also memory might implementation. second objects language as the Some allocated by directly determined be is might This size, large objects. their like generation of treated independent are objects, are they Specific but where the generation, in generation, first fit second the still in the but nursery objects. in arenas, the in buffers in fit into stored to moved are big objects too are Those which collector. nursery. objects, garbage are the within objects aid tables Medium to card each two-level used for in is stack managed marking one by are card stacks, arrays allocated two buffers, Large directly in those is generations. managed two which are the buffer, buffers of single These a system. in operating stored the always are page. objects suitable Large a object. within one blocks exactly free fit of can number buffer the each and size equal of buffers of number regions, predefined memory which continuous hierarchy, of memory consist a Arenas in buffers. memory stored and fixed-sized are pages a nursery, they arenas, the generation, of in second consists stored the are In generation first buffer. the in objects Small Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. sarayntd hytigramnrcleto,bfr hyaeeeue.Atal,a Actually, executed. are they before collection, minor a trigger they noted, already As be to needs and filled been has nursery the once executed, typically is collection minor A h orcns famr-we mlmnaincnb omlypoe ytetricolor the by proven formally be can implementation mark-sweep a of correctness The de otewrigst bet r loae ht,btoc hyaedagdotof out dragged are they once but white, allocated and are gray to Objects reverted set. are increments working two the [ between is to barrier modified invariant added are write the which Boehm that objects grey ensure Black a to simple: uses used PyPy typically are violated. barriers not sweeped, write marking, be incremental can as dead. For objects terminate, thus (white) might and either unmarked phase unreachable are All marking are they the marked. they (so black, been as marked colored have been are objects also objects objects reachable have all Black all children Once already. colors their marked black). Grey all or been as (yet). grey not marked processed, have fully been might children not been have their have but objects marked, White been black. have and grey white, colors: [ needed. abstraction is of collector nature incremental the and the mutator of the Because between increment. synchronization each collector, before the executed is collection concurrently. configurable minor happens This never a and interleaved by algorithm. is grown mark-sweep execution collector has uniprocessor and mutator incremental, memory that an used means, implement the They when executed amount. are collections is arrays Major large for marking Collection card too. Major If objects those used. for is used is list list inter-generational special additional For an a list. an by generation. a enabled, objects, referenced as old pinned directly implemented the are to and to which pointers barrier promoted generation, write young are a the pointer by from inter-generational recorded updated objects are is list, generation set this young This Using the set. to remembered generation a old in the young from the pointers from stack. Inter-generational moved moved generation are are old objects objects the large medium to to arenas, stack references into generation and nursery buffers the managed of separately inter-generational outside into an moved through are it generation objects if old Small survives, the in generation young object the an by of generation, or object old pointer. root, An the a nursery. to by the promoted reachable in are is objects objects pinned surviving for collection, except minor a During cleared. an Then, generation. old the Collection collection Minor of objects. minor part those a collects then which collection, are executed, major objects is a algorithm surviving mark-sweep of all incremental the beginning so in the objects triggered, at process is However, only collections generation. major Technically, old collections. major to contrast DLM + 76 ,[ ], DLM + 78 .I hsasrcin vr bethsoeo three of one has object every abstraction, this In ]. BDS91 .Ti are srelatively is barrier This ]. ..PP n cpyext and PyPy 2.1. 7 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 8 .Saeo h Art the of State 2. hntefis Pto xeso ouei odd peti ntaie n h behaviour the and initialized is cpyext loaded, is module extension CPython first the When tteedo io olcin h usr osntne ob wee xlcty as explicitly, sweeped be to need not does nursery the collection, minor a of end the At the at initialized is set This objects. grey all of track keep to used is set working A h abg olco lospot nlzr n ekrfrne,wihw ilnot will we which references, weak and finalizers supports also collector garbage The .. upr o petModules cpyext for Support 2.1.4 oe eei eal sterbhvorde o edt eaatdt upr cyclic support to adapted be to need not does behaviour their as detail, in here cover nadtoa edi h edro h eeec one betadi oa ffour of reference). total the a of in direction and the object on in counted saved depending reference are generation, the each Links a of for as object. header (two implemented PyPy-managed the lists is the in object to field PyPy-managed linked additional Conversely, is a an object. which to C-managed proxy object the counted C-managed to (non- reference a linked PyPy-managed from is a which reference referenc from proxy a a counted as reference implemented non-reference is A a object counted) to follows: (reference C-managed as a to works counted) reference integration to the executed is detail, code In additional algorithm. of collection, the end major of the and safety At minor the each objects. ensure cpyext-managed of incorporate phase to marking changes, the collector garbage the of Python’s like functions for were needed which are shadows, which object IDs, like stable scenarios, support special to some introduced includes This counting. reference References Weak and Finalizers for Support unused. freed as is marked area simply memory are is the objects it structure, sweeping (white) or memory The unmarked system the buffer. All operating on the the simple. Depending next of by relatively the heap. beginning also to the the is pointer from to collection the sweeped reset major so be nursery, a to the after needs of phase only out area copied memory been free already have objects live all collection Sweeping major of phase case sweeped. In marking be the execution. can reached, its heap is continue the to limit and mutator the over the before is allow empty and increment to the becomes black paused, reached, marked set is been is the collector has object the limit incremental and the the are over Afterwards Once each is objects set. during set. white working working processed referenced the the and from directly to removed set, all added the processed, and to is grey roots which marked all object adding each by For collection, increment. step. major marking a major of each beginning preprocessing of these beginning after the outside that at allocated means restored were This is which invariant collection. objects tricolor minor weak for a the true survive steps, is and same nursery The the grey. of become they nursery the id() . e Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ekrfrne n nlzr edt eseilyhnld ekrfrne nPython in references Weak handled. specially be to need finalizers and references Weak . CPython 2.2 h mlmnaini ete ocretnriceetl hc eut npotentially in results which incremental, nor concurrent neither is implementation The objects live no that means which algorithm, the of safety the guarantee adaptions These r re.Btte edt otn abg,a bet ncci tutrscnann at containing structures cyclic in objects as garbage, floating to lead they But freed. are euigpuetms codn otewa eeainlhptei alto newly of lot (a help hypothesis should generational [ weak collection young) the garbage die objects to generational created according of times, application pause the reducing but times, to needs pause objects high called. dead been potentially have all finalizers of modern set all but the after called, all again, ( be so processed list should objects, be finalizers a some Modern them to resurrect using moved developer. might application objects they are beforehand. the so cleared alive, by structures, be keep cleared cyclic to they manually on need objects called callbacks those be all so not called, and die, might be to not finalizers might about legacy They is Python’s dies. reference object weak reference the weakly if the when callbacks, supported also References references. generations. external is prior as algorithm all treated deletion and simply trial collected are the be generations and to later generation) about from each generation for the (one algorithm. on lists deletion executed trial in collection global managed its generational, are at a Objects look implements a collector take garbage will CPython’s we cyclic so CPython’s algorithm, of our parts of [cpyb]. use design logic can the we for However, collector objects. garbage counted non-reference from and [ Python for implementation standard the is CPython algorithm. the unreachable to become adaptions they our if by even fixed freed, never be are should object issue counted reference one least cou phase. non-reference marking the the of and actual end zero their the the is by at when alive object unmarked freed, kept counted is only be reference object are only the their pairs might of once object them count freed Linked of counted reference not some reference object. are linked, as counted they zero, Also, non-reference that to linked, case. so drops this count, count on in reference reference objects alive artificial actual reachable kept additional Any also an non-reference algorithm. are do have the the heap they objects keep the of that proxies safety of counted so the parts Reference guarantee alive, both to kept often. reference alive, too are the object recreated as proxies counted long be counted as to Non-reference have routines, additional not alive. the is by part alive kept counted always are unmarked objects are phase. Linked they marking when z the sweeped, to of still drops end count are the reference objects at their counted when non-reference freed unlinked, are and objects counted reference Unlinked, one ep ow ontne owryaotayseilcss asdb eeecsto references by caused cases, special any about worry to need not do we so heap, counted FF81 .Teuaeo v eeain nteohrhn is hand other the on generations five of usage The ]. pyt gc.garbage .I aae ueyreference purely a manages It ]. ,weete a be can they where ), This . ..CPython 2.2. nted ero 9 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 10 Art the of State 2. JM [ (JVM) hnmroigterfrnecutdgah h su fol mlctykonexternal known implicitly only of issue the graph, counted reference the go mirroring not When will We case. this in support to difficult quite are finalizers and references Weak . yhnsJyNI Jython’s 2.3 hl betgraph. object whole consistency. for checked be to a need of structures beginning dead the at sweeped, also are but objects increment, before an Thus, of beginning the at only not that means This hc r mlmne nteetninmdlsadcno eaatd edt be to need adapted, be cannot and modules extension the in implemented are which yhni natraiePto mlmnaino o fteJv ita machine virtual Java the of top on implementation Python alternative an is Jython V mlmnainadte eeal ontoe nitraet neatwt the with interact to interface an offer not do generally they and implementation JVM ao olcin h irrdgahmgtntb ycrnu ihtera betgraph. object real the with synchronous be not might graph mirrored the collection, major ycrnzto rseilhnln o ekrfrne.Tero eeto a be can result any detection probably might need root this not However, The do detection. references. root we CPython’s weak process as to and for dramatically, similar objects handling implemented counted algorithm special reference the of or mirroring simplifies synchronization the which the omit directly, can of we them roots cpyext, as and them PyPy the treat In in can references we ingoing objects, count the these reference of identified the count have as we the detected, match Once be not graph. easily does mirrored can objects They referenced elegantly. externally quite of solved be the can simplify roots algorithm core the to finalizers. modifications and our references that weak see sweeped of will be we handling can but they details, matches, any count into reference their and references internal their if Only objects. C raw for possible not are barriers objects, counted write reliable reference as Other asynchronously, graph. mirrored so mirrored notifications, the change on implement applied objects directly Built-in counted are non-reference manner. changes the asychronous to mirrored an permanently in PyPy’s is graph graph in counted cycles reference the refeference JyNI, clear can In efficiently we Anyway, can garbage integration. we the level so low where it, collector. PyPy, of modify garbage to kind and contrast any approach stark support their in to use is modified unmodified This any be level. can with low collector compatible a be on to collector aims garbage across Jython and as heap necessary, counted reference is the JVM- This on the structures heaps. to is cyclic both unreachable implementation mirrored detect mark-sweep is to built-in graph able JVM’s counted then graph. reference counted unmanaged, used non-reference scheme the managed, counting where [ reference JVM, Jython the the with integrate of modules to objects. extension algorithm dead those an clear for proposed to algorithm al. mark-sweep et a Richter uses also JVM the [ of JyNI collector called is which modules, [Hay91]. evident that not objects generally created is newly objects) not older (younger, than hypothesis sooner generational die strong the as questionable, jyt .Js iePP,Jto a optblt ae o Pto extension CPython for layer compatibility a has Jython PyPy, like Just ]. Ric14 .JN ae eysmlrpolm h garbage the problem: similar very a faces JyNI ]. Ric16 .Terapoc sipeetdo top on implemented is approach Their ]. . Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. CRmngd epadars ohhas pcaie,lcltildlcinalgorithm delection trial local specialized, A heaps. both across and heap (CLR-managed) even Microsoft algorithm. mark-sweep a implements code, .NET executes which (CLR), . irsf NTCMintegration .NET/COM Microsoft 2.4 ssrn ylsi Pto xeso oue r loe,Mcootsagrtmcannot algorithm Microsoft’s allowed, are modules extension CPython in cycles strong As ekrfrne.Fnlzr edt eseilyhnldi ohcases. both in handled specially be to need Finalizers references. of weak problem the solve should This phase. marking the of end the at away throw can we by caused pauses, the keep and increment last this for time pause the increase only will bet aet nld tlatoecosrfrne h aetdagrtmepot this exploits algorithm patented The counted cross-reference. reference one include that least structures at cyclic include all to as have efficiently, objects quite applied be thus can eapidi u situation. efficiently. our more in cycles applied such be detect to optimizations, some applies additionally and fact counted [ non-reference allowed the are on reference structures cyclic weak (strong) a exist by cycles only strong closed can create are there to which that allowed means cycles not are only developers [ COM, application scenario in this difference: in crucial cycles one Runtime clearing is Language for patents Common several the holds while counting, reference uses COM problem. similar [ a (COM) Model Object Component Microsoft’s for handling special any need the not to do mutations we of case, apply track this can keep in We to Even simple. does, increments. relatively JyNI between that algorithm graph mechanism the synchronization keeping same which still the phase, while marking times, the counted pause mirror reference the higher to of the snapshot of need low-level beginning does a the it create at so can graph approach, we counted Richter’s Instead, reference modify permanently. graph can counted we reference hand, other the which level. On increment, same last the the on to able increments, heap are other counted we increment.all reference that single the so one of implementation, in mark-sweep phase this our marking perform of the to behaviour defer have the to will change we can as we times, But pause maximum higher in coma nerto n.E [ .NET in integration ] HK15 ..Mcoot.E/O integration .NET/COM Microsoft 2.4. ,[ ], HK17 .Hwvr there However, ]. dotb comb lofaces also ] .This ]. 11 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. sw aese ntepeiu hpe,n pcaie loih xss osleour solve to exists, algorithm specialized no chapter, previous the in seen have we As h ra eeinagrtmi h otpplrcoc o oa rcn [ tracing local for choice popular most the is algorithm deletion trial The hs ftemr-we loih n h hr hs ftetildlto algorithm. deletion trial sweeping the the of using phase heap the third clear the we and Then, algorithm mark-sweep heaps). reference the cross the the of we for marking/incrementing if phase algorithm on objects deletion keep tracing reachable trial (we of the global the conjunction count for a of in algorithm objects. execute phase mark-sweep heap counted second typical can counted a the we reference reference of and known heaps, phase heap of both marking counted set on the non-reference execute our roots we to all First, counted references roots collected external reference algorithm. have like have of we treated objects set that Those be a Now can zero. with than and as us greater them objects leaves count counted to This reference reference a cycle. first all with garbage treat the objects non-reference simply a execute the and of we algorithm of members Then, deletion roots potential trial techniques. all the mark-sweep detect of standard we phase the First, using approaches: heap both counted combine systems. seemlessly can counted by not we reference and does But purely heap deletion for counted trial used non-reference Also, the be for only cycle. used can a algorithm itself of mark-sweep the part with currently integrate is objects be of would [ subset cycle, exists garbage approaches set a several minimal of counted this, [ ideally members reference acheive an be To However, of currently subset cycle. might desirable. the the a which of of of objects, aware roots part candidate only the become of are of potentially we knowledge can as exact which useful, the objects, especially without is operate This can heap. it that advantage, combining the of has way new a find situation. to our have we in that tracing means, with This counting way. reference efficient an in problem SBYM13 ,hwvrdet h rgamn oe,teei oeatwyo eln which telling of way exact no is there model, programming the to due however ], MWL90 Algorithms ,[ ], HLM09 CHAPTER ,[ ], JHM11 CYTW10 .It ]. 13 ], 3 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 14 Algorithms 3. . eiIceetlAlgorithm Semi-Incremental 3.1 h ot ftennrfrnecutdha a eesl eemndb cnigthe scanning by determined easily be can heap counted non-reference the of non- roots and The counted reference the across tracing global performs algorithm proposed The h eutn loih samxueo h loih yysdfut nrmna mark- incremental default, PyPy’s algorithm the of mixture a is algorithm In resulting 3.2). The Section (see heap counted reference the of snapshot a taking by issue, this with freed. is memory the and sweeped are objects Those GC. CPython’s like just zero, than greater count reference a with .. eaint nMnMr n Pto’ GC CPython’s and IncMiniMark to Relation 3.1.1 olcin nteohrsd,ojcsmngdb pet(yyscmaiiiylayer compatibility a (PyPy’s during cpyext considered by are managed code objects memory Python side, PyPy’s from other by created the managed objects On objects only dead collection. that detect means to This able only system. is IncMiniMark default, By and algorithm given. the is of on description based a is correctness, it of algorithms proof the a to and relation pseudocode its [ the implements at currently look collector a garbage CPython’s algorithm the complex. more collector slightly garbage algorithm sweep final in the implementation making its account, and into model taken programming be C dealing to not the have for of are PyPy approach specifics objects advanced additional C-managed more cases, a on both propose barriers will write we reliable section, as counted following once, reference the be at the In to done can of feasible. cheap phase be heap fairly determination) to PyPy-managed and root has the reliable (and minimize heap are of marking to barriers phase the order, write while different marking as implement, slightly the easily, a quite because in incrementally is executed performed are This steps the times. both. level, pause or detailed zero, more of a remaining, count On the reference Afterwards, a have simplicity). still marking or marked of this unmarked are sake call either objects the also are reachable for will objects all (we unreachable descriptions, known, calculated is following newly objects the is root count in of reference set their the respectively, after or, level, obje high for a heap On the deducting scanning by and heap counts counted reference extension reference objects CPython the the for of from used references explicitly roots internal not model the all are calculates programming heap algorithm the counted The of managed reference nature are modules. the the objects of of counted roots because non-reference The known, all system. as memory roots, PyPy’s static by all collecting and stack heap. the of parts counted reference phases the execute to choose order. properties also different the might slightly improve we a as To times, well in model. as pause and programming finalizers, incrementally primarily the and algorithm, and references runtime our weak the of of of care specifics take the to of have additionally we reality, In IncMiniMark urnl mlmns[ implements currently pypa ,ada dpainof adaptation an and ], cpyb .Bfr ehave we Before ]. cts Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. heap C ito abg olce objects collected garbage of list h loih ecie eei bet eetalknso edojcsadadditionally and objects dead of kinds all detect to able is here described algorithm The .. Description 3.1.2 eeecst te bet,ti osntips ra eoyoeha rke any any keep contain or overhead not memory do (for great objects alive a proxy kept impose As therefore not alive. and does is cached this is object objects, PyPy object other PyPy the linked to a as a As references one to long objects, pairs. most proxy as proxy as at a many reuse), viewed be as later too be only acts away can can throwing that objects There and proxy object linked creating a C alive. that avoid as it means to acts keeps which optimization, object and object, an One side real other other. each the each for on to proxy linked object are real which the heaps, to paragraph. both following on the objects are called two in cycle are explained a cross-references is of with which part Objects cycle, be a not of normally part can be which can objects C die. they called before list that from called are methods, clear and traverse called are system memory the PyPy’s by managed Objects Terminology be will objects cpyext-managed concerning PyPy only finalizers in objects, and here. algorithm PyPy-managed references described existing for weak the correctly of because finalizers handling and supported and the simplicity are references which of weak of sake handles both the two already finalizers, For features legacy and algorithm. currently modern the language as by Python to referred The finalizers, of finalizers. kinds and references weak supports of parts dead, existing version, utilizing adapted detected, are the are objects heaps In other both IncMiniMark. zero. all across PyPy’s to and cycles, drops within reference count structures dead reference cyclic CPython detect their when to algorithm. freed solely collection directly objects collector garbage cpyext-managed CPython’s garbage to all pointer, of takes its term version parts uses adapted the applying we The use by when we account, links). links; references; and into as intra-heap references them to both description to refer to the refers references only refer simplify PyPy we are to in references, there on, implementation of case further actual speak in links the alive, references because other those also each call and keep will sides algorithm (we both implemented them objects, on The cpyext-managed between and objects structures. PyPy-managed that between dead ensures border of the and kinds at all objects with detect deals PyPy, to only the in able to IncMiniMark, inside not objects drops mostly cpyext-managed is count implemented for algorithm and reference module support rawrefcount their rudimentary the when by is encapsulated there freed, though only Even are zero. modules) extension CPython for yyheap PyPy o-abg olce objects C collected non-garbage bet hc a oetal epr facce n hrfr mlmn the implement therefore and cycle, a of part be potentially can which objects C . bet aae ycyx r called are cpyext by managed Objects . adul ikdls)bfr ntaiainadaeremoved are and initialization before list) linked doubly (a hr sol n pca ae hr uhobjects such where case, special one only is There . abg olce objects C collected garbage ikdobjects linked ocpuly hyaeraie as realized are they Conceptually, . objects C yyobjects PyPy ..Sm-nrmna Algorithm Semi-Incremental 3.1. hyaeaddt the to added are They . n hyrsd nthe on reside they and n hyrsd on reside they and 15 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 16 .Algorithms 3. oenfiaie hudb aldb h abg olco xcl ne ncs the case in once, exactly collector garbage the by called be should finalizer modern A ed o aet aetpe otiigol uhojcsit osdrto during consideration into objects such only containing contain tuples only take might to tuples have some not because do list, we separate a to added initially are Tuples ekyrfrne bet r ato yl.I h ekyrfrne beti sweeped is object referenced weakly the If cycle. a of part are object, referenced weakly olco uigpae6.Ti en hti oenfiaiesaeue,a es two least at structures. used, cyclic are dead finalizers garbage free the modern to of of if environment needed execution that the are the means of cycles during This outside collection finalizer 6b. done the phase be call must during to this collector safe so be collector, not garbage might PyPy’s It collector. garbage the Finalizers Modern for cleared Support of and list accessed global be the can to they added list, user. are this and the From otherwise, finalizers by dead 6d. legacy object manually be phase with an would during of objects and count (gc.garbage) Instead, alive, to reference garbage cycle. keep safe the collection they not if the objects are called, of all they only outside are as zero They collector, to garbage structures. drops the cyclic by on called called be be never should finalizers Legacy Finalizers Legacy be for never will Support beforehand. callbacks cleared their be that to means always need This are don’t which 5a. they objects, phase application. so PyPy during the called, as crash resurrect objects implemented or or C are behaviour before access references unexpected sweeped might weak to lead case they callbacks might our so Those this in objects, case, However, called. worst dead are the already reference In to weak them. the references of hold the callbacks might and the now reference reference, weak weak before the the cleared both, before that be happen to might need it cycles Otherwise, garbage sweeped. within are references cycles weak the of callbacks CPython, In to added processed. References be Weak is will heap for tuples C Support other the all before However, objects, cycle. collected a garbage of of part list be Python, actual never in the will immutable they are as tuples tracing, As objects. C collected non-garbage or types primitive this take to can have objects Tuples also PyPy we as algorithm, cycle, our a in of that consideration. part means, into be This case might be cycles. special they can PyPy of case, or objects part this counted) object be In (reference (C generally collected side objects. non-garbage which are PyPy Also on objects to proxy. depending those linked a lists, between as two links acts in The stored object) alive. and dead cpyext be by otherwise managed would which objects other beti bu ode fi eurcsayojc,ti utb ae noacutby account into taken be must this object, any resurrects it If die. to about is object Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. etclrdi lc spr ftebscagrtm etclrdin colored text algorithm, in basic colored the text of support, part reference weak is black in colored Text elwtext. yellow oudrtn h ekrfrnespot tsol esffiin ora h lc and black the read want to only sufficient you be example, should for it If, support, ignored. reference safely weak be the can understand text to colored the algorithm, basic in colored Algorithm the of Outline 2. .Mr l te bet,i aecyx senabled: is cpyext case in objects, other all Mark 3. 1. olc h ot ftePP ep(ttcros tc ot,...). roots, stack roots, (static heap PyPy the of roots the Collect akalrahbeojcso h yyha uigol eeecso h PyPy the on references only (using heap PyPy the on objects reachable all Mark ep eusvl,satn rmtepeiul olce roots. collected previously the from starting recursively, heap) )Cletteroso h heap: C the of roots the Collect b) d) a) c) e) icuigPP bet)it eaaels n akte slv (increment live as them mark and list separate a into objects) PyPy (including edobjects dead hnpocsigagraecletdCojc,mv tit e it so list, new a into it move object, C collected garbage a proccessing When blue en htn betadn yyojc hc sol etaieb n C any by alive kept only is This which recursively. object PyPy cycle. objects no this of and dies set object object this C objects. from no dead that reachable of means list objects the PyPy in all finalizers mark modern with move objects so, any If are there if them). Look mark objects. or count dead reference of their list the in finalizers legacy all with move objects so, any If are there if Look case). (special all objects the linked mark Increment collected and reference non-garbage the step. objects referenced increment directly previous C Also, of the collected recursively. count objects in garbage PyPy found reachable unmarked heap, all reachable, starting C of objects, the PyPy count reachable of reference all roots and the objects C from collected garbage the Mark tuples. created collected newly garbage of of list list the the from to tuples cycle other a all of remove part and be objects might which tuples Move necal bet eani h l it h l iti o called now is list old The list. old the in remain objects unreachable ii. i. on tl rae hnzr,o ikdt akdPP bet.Treat heap object). C PyPy the marked of a roots to linked as (reference or objects references zero, those external than with greater objects of still C count list collected the garbage traverse-method. over for iterating their by Scan utilizing case), and (special objects object collected C garbage referenced collected of directly garbage are count which a reference objects by the proxy garbage decrement linked collected all and non-garbage of case) all count (standard reference objects the C from collected references internal the Decrement spr ftelgc nlzrspot fyuaeol neetdi the in interested only are you If support. finalizer legacy the of part is all . bet rmtels fda bet noasprt it Also, list. seperate a into objects dead of list the from objects fthose of bet n l bet ecal rmtoeobjects those from reachable objects all and objects green spr ftemdr nlzrspot text support, finalizer modern the of part is ..Sm-nrmna Algorithm Semi-Incremental 3.1. yellow spr fthe of part is itof list 17 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 18 Algorithms 3. h loih a lob xctdiceetly yitouigwiebrir odrag to barriers write introducing by incrementally, executed be also can algorithm The .. Proof 3.1.3 oie bet akit h okn e n xctn h otdtcinadmarking and detection root the executing and heap. set the working from the sweeped into are back marked. which objects recursively modified objects, are unmarked objects for simple. reachable scanned quite all is is then heap algorithm and basic the determined Finally, The and are heap. objects roots the (reachable) the live from First, determining objects for (unreachable) algorithm dead proven removing formally a is Mark-sweep Outline .SepteCha otieo h otx ftegraecollector) garbage the of context the of (outside heap C the Sweep 6. sweeping for objects C Prepare 4. 5. we h yyheap. PyPy the Sweep )Sepalumre yyobjects. PyPy unmarked all Sweep b) b) b) d) )Sepalojcsi h itcetdi a sn hi erfmethod. decref their using 4a, in created list the in objects all Sweep a) a) a) c) f) g.abg)adeetal raePP rpesfrojcso h heap. C the on objects for wrappers PyPy create eventually and (gc.garbage) weakrefs. objects. PyPy unmarked with alalmdr nlzr vial ieaeoe h itcetdi 3e). in created list the over (iterate available finalizers modern all Call yyojcsi tp3,s hsls a esfl rcse.Atrti step, this After list. processed. gc.garbage safely the linked be by all can alive marking list kept and this are 3b-3e so objects all steps 3f, these garbage consider skipping step action, by of in alive, this objects list heap during PyPy global C triggered the the is on cycle to objects collection 3d another in case created In list cycle. clear a the their of from using part 3c), likely objects in most all (created were Move objects objects Those dead of method. list decref the and in objects all Destroy remaining the be of not callbacks do the we calling so by objects, objects die PyPy any cycles as resurrect in implemented to Weakrefs are not they callbacks. careful as remaining cycle, the the call before and weakrefs all Clear pairs all removing by objects linked of lists afterwards. the sweeped clear be step, corresponding PyPy will previous the their which the add by list, During die, separate alive to non-garbage a about kept any and to only unmarked are object were is C proxy there which PyPy if heap the C If look, proxy. the and on pairs objects object collected linked all over Iterate object). C collected garbage C any collected by referenced non-garbage directly linked not Mark for any are zero. are (important which than there objects objects greater if PyPy count look, reference reachable and a proxies all with C objects with pairs collected non-garbage object linked all over Iterate Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. seFgr .) hr r loseilcsslk ekrfrne rdcinre,which dictionaries, or references weak like cases special also are There 3.1). Figure (see hnw hn bu h esn h ene oprommr-we ntereference the on mark-sweep perform to need we why reasons the about think we When the then and collected are roots all Normally, execution. of order the is different is What eletbihdmtos iesann h tc n ttcprso h ep h roots The heap. the of parts static and stack the scanning like methods, established well u hi eeec one rpe sntgraecletd(hc en hycnin can they means cycles, (which create collected can garbage and not heap is the wrapper of counted part reference counted objects their non-reference non-reference collected but the the non-garbage such on on to implemented objects linked are keep objects are to such which need why alive, still realize heap we quickly the However, we of cycles), traced. part clear be counted to to is have cycle). (which not reference a heap do their clearing the when when of freed not or part only execution are counted are program they They normal that during cycle. means, (either a collected zero of of to garbage part part drops counted Not be count reference cannot collected. the they on garbage because objects traced, not some are where heap case, the special a have we However, all. at changed easy been is not it has another roots), core, just detected its as newly at heap as algorithm, the roots the of we counted that part If reference see counted all incrementally. to reference treat heap the we the of (where of phase increment perform part marking counted already very the We non-reference is about the algorithm. it think mark-sweep of but only incremental change, phase using an substancial marking marked, in a the been like counted happens has seem reference what part might the to counted This of similar non-reference roots. roots whole counted the the non-reference collect after the we heap case the our objects. of in root part However, of starts. set phase the marking is than This greater them. internal count their to reference and references a iterated, external with is with trial objects heap) those called whole remaining are algorithm the The zero an case deducted. this using is (in determined count objects are reference using of heap set determined the a are of where heap part deletion, the counted of reference part the counted of non-reference the modified. of be roots cannot the executed objects case, is dead phase our sweeping as In the barriers, Then, write empty. any is without set increments, working in the until increments, in phase iue31 o-abg olce betkeignnrfrnecutdojc alive object counted non-reference keeping object collected Non-garbage 3.1: Figure A B o-eeec counted non-reference root eeec one,nngraecollected non-garbage counted, reference C ..Sm-nrmna Algorithm Semi-Incremental 3.1. 19 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 20 Algorithms 3. esleti su,b aigteenngraecletd eeec one bet that objects counted reference collected, non-garbage these taking by issue, this solve We ,B n r eutd sntcniee,bcuei sanngraecollected non-garbage a is it because considered, not is D deducted. are E and C B, A, ilb wee uigti olcin u n o-eeec one betta was that object counted non-reference any but collection, this during sweeped be will heap the of part counted reference the of phase detection root the in included are They one bet.Btentoetocce eeeuetefiaiesadmr hmas them reference mark dead and of finalizers set the the execute in we detected cycles situation are two this finalizers those with obj Between if deal counted cycle, we non-reference objects. collection case, reachable counted objects, next our all dead the (and In potentially until objects freed. of alive, counted is set reference which object the all finalizers, any keeping in about before by exist careful executed finalizers be be and case to must unreachable have In they are only We objects. objects dead resurrect status. as might their incrementally, keep done not to be is have easily F therefore can collection, live heap garbage the a next alongside Sweeping the as removed marked During one, are is of zero. E sweeped. count F to and and reference phase, drops D again a marking count marked sweeped, has the reference are still during their A-C count hand that as phase, reference other means C, sweeping total the This the a on During root. have E a now object. it roots. as C as because acts and act considered, it B don’t is so A, they E object. so object. counted zero, counted non-reference of non-reference a a objec to to linked of linked counts is not reference is internal which The object object: counted non-reference the for root a as itself object to collected happens non-garbage object the collected cycle, non-garbage unreachable a an if by that referenced is, indirectly mentioning be worth objects. left collected thing garbage phase. One like marking just the marked during be account, will into and object counted non-reference a to linked are 3.2). Figure see cycle, a o part be fact ulcleto seFgr .) hsi eas h o-abg olce betacts object collected next non-garbage the the until because sweeped is be This not will 3.3). object, Figure collected (see non-garbage collection a full such by alive kept E A iue32 ylcsrcuewt o-abg olce object collected non-garbage with structure Cyclic 3.2: Figure D B C o-eeec counted non-reference eeec one,graecollected garbage counted, reference eeec one,nngraecollected non-garbage counted, reference ects) ts Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. fe hs a encmltd h eto h loih ste xctdi one in executed then is algorithm the of rest the completed, been has 2 Phase After ewl hwatrad,ta hyfi ieyi u omlzto.As oeta for that note Also formalization. our in nicely fit they that afterwards, show will we the point some at once, executed be only can finalizers As objects. the free safely can we omte o hs hssaeeeue,adta tsol etiilt elc both proof. replace our to of trivial context be the should in Definitions: it counterparts, hold, that incremental phases and their two executed, first with are the phases phases from non-incremental those postconditions how the matter that conclude no incrementally. can executed We are increment. 2) phases single and two 1 those implementation, (Phases the phase In marking counted incremental. However, non-reference not the proof. is the pseudocode, in the accout first. in into assumptions simplicity, finalizers and and references prepositions weak some take define not do to we need that we Note, proof, semi-formal the For Correctness more. of any Proof used Semi-Formal Otherwise, not cycle. are two this they those during if of again freed, one objects be If object of will any set executed. objects if this be check look to to and needs have again still we cycle finalizer met, last we any is the cycle, if criterias following from or the objects resurrected, During dead been Python). potentially has in of once set executed the be check only can (finalizers executed collected non-garbage dying by alive kept object counted object non-reference Dead, 3.3: Figure • • • • • • • A rc nonrc gc root ref link link ( ( x x ( B ( _ ( . h beti eeec one aCobject) C (a counted reference is object the ... ) . h beti abg collected garbage is object the ... ) ,y x, x ,y x, rc ( . oto h o-eeec one ep(yyheap) (PyPy heap counted non-reference the of root ... ) x . hr xssarfrnefo betxt bety object to x object from reference a exists there ... ) ( := ) . bet n r ikdt ahohr saproxy a is x other, each to linked are y and x objects ... ) ,y x, C := ) ¬ rc ( link x . h beti o eeec one aPP object) PyPy (a counted reference not is object the ... ) ( ,y x, D ) ∧ rc ( x ) E o-eeec counted non-reference eeec one,graecollected garbage counted, reference eeec one,nngraecollected non-garbage counted, reference F ..Sm-nrmna Algorithm Semi-Incremental 3.1. 21 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 22 Algorithms 3. olce objects. collected bet,allv abg olce bet r akd nldn oeseilnon-garbage special some including marked, are objects collected garbage live all objects, Assumptions: lo ntest of sets the in Also, recursive a use We is. object collected) (garbage live a what define, to have we Also, ihpscniin seAgrtm1.Alo hs otodtosaeacmltv,so accumulative, are postconditions those of All 1). Algorithm (see postconditions with euso vapointers): (via Recursion aecases: Base live live n ewl hw htorsto cuuae otodtoscrepn ooroverall our to correspond postconditions the accumulated In of hold. set still our should annotated that methods pseudocode, show, previous the will the at we from end look postconditions a the have method every us after let this, For sweeped. is heap the before 1 Theorem in them treat and objects. them Even collected mark chapters. garbage still previous treat can we the we way in objects, same described collected the cases non-garbage special are the they are though These contained. be might of set the that Note, live definition: Proof 6. 5. 3. 1. 4. 2. • • • • • • • • _ _ _ pointers base objs live live live live live live ∀ ∀ link marked ∀ ∀ ∀ ∀ bet a nyb ikdwt xcl n te object other one exactly with linked be only can objects ,y z. y, x, ,y. x, ,y. x, ,y. x, x. x. u oli oso hteatytoeojcsi h e of set the in objects those exactly that show to is goal Our ( ( ______nonrc root _ := := ∄ ( (( proxies links refs roots trialdel linked nonrc link z. rc (( live live ( tteedo h akn hs,bfr esepumre abg collected garbage unmarked sweep we before phase, marking the of end the At ( ( x := x ( link link . h betxi akdo a eeec on rae hnzero than greater count reference a has or marked is x object the ... ) ( x ) ( := x := := ,y x, ) _ _ ( _ live ⊃ ) ,y x, ¬ ↔ _ base roots ( ( roots := ⊃ { nonrc { { ,y x, ,y x, roots ) x live x x _ live gc | := ) ⊃ { | |∃ gc rc refs root x ) ∪ ) ( _ y. ( ∪ ( |∃ x ∧ := ( ⊃ _ rc x live ( y links )..nnrfrnecutdojcsaegraecollected garbage are objects counted non-reference ... )) ( := link live y. x ) linked link y )) ( ( ref x { )..ros(ftennr ep r o-eeec counted non-reference are heap) non-rc the (of roots ... )) ∪ ∃ ∧ x ( ∈ x { ) _ y ¬ ⊃ ) live } _ x ( |¬ ( live ¬ ↔ pointers ( ∈ ,y x, y. | ,z x, trialdel ,z x, and gc gc _ ( live ref _ y ( _ ( ) roots )..poyojcscnthv ugigreferences outgoing have can’t objects proxy ... )) x rc ) links x ∈ ∧ objs ) live ( ) ⊃ _ ( ,y x, ∃ ∧ live nonrc ∃ ∧ y objs ( _ ) . ik a nyb cross-heap be only can links ... ))) y _ osssol fnngraecletdobjects. collected non-garbage of only consists ∧ ∪ )..teeaen eeecsbtenteheaps the between references no are there ... )) roots y. y.z _ = proxies ( link live ∧ objs ¬ ( ( z x ¬ link gc )) ) ∪ _ gc ( ( ∧ ,x y, ∧ y wrappers live ( _ ) y ( ref oenngraecletdobjects collected non-garbage some link ∧ ) rc )) ∧ _ ref ( } ( ,y x, linked ref ,x y, ( ,x y, ( ,y x, ) ( )) } ,x y, ) } _ ∧ )) roots ) } link ∧ live link ( ,x z, _ _ objs )) rc ( ⊃ ,z x, r marked are ( y ))) = } z )... )) Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. loih 2 Algorithm 1 Algorithm loih )cnttt h akn hs fatpclmr-we loih.W only We algorithm. mark-sweep typical a of phase marking the constitute 3) Algorithm sgetrta eo tews,te ol aearaybe lae ytestandard the by cleared been count already reference have their would means they which Before Otherwise, marked, 4). zero. are (Algorithm than objects roots greater counted counted is reference reference all with concerned 3, are Phase 4 and Even here 3 given Postconditions on. is later version 3 non-incremental Algorithm the of incremental, simplicity. postcondition phases for the these violating execute and not we 2 about though (Algorithm careful methods be two to the have as straightforward, quite are 2 and 1 Postconditions Ensure: hold. let actually First, postconditions marked). individual are the objects of collected all garbage that live show all us exactly all (that postcondition Ensure: 15 14 13 12 11 10 9 8 7 6 5 4 3 4 3 2 2 1 1 procedure ∀ ∀ ∀ ∀ ∀ ∀ procedure ∀ ∀ ∀ ,y. x, ,y. x, ,y. x, ,y. x, ,y z. y, x, ,y. x, ,y. x, x. x. ( ( MarkProxies MarkRc CollectRcLinked CollectRcTrialdel MarkNonrc CollectNonrcRoots o all for root root (( (( (( (( (( (( Mark link link rc link ¬ nonrc (( ( ( gc x x ( ¬ x ) ) ( gc eiIceetlAgrtm-Pae1 Phase - Algorithm Semi-Incremental Algorithm Semi-Incremental root _ _ _ ) x ⊃ ⊃ Mark CollectNonrcRoots ∧ root rc rc nonrc ( ) ( x x marked marked ∧ ref ( ( ) ) in ,y x, ,y x, gc ¬ ∧ ∧ n d tto it add and ( NonrcRoots ( ref ( ,y x, y ) ) ,y x, gc ) ∧ ∧ ∧ ( ( ( ( ) marked marked x x ,y x, y ) ref ∧ )) )) ) ∧ ∧ gc ) marked ( ref ∧ ( ,y x, y marked ) ( ( ( y x working do ∧ )) ,y x, )) )) marked ⊃ ( ⊃ ⊃ x ) )) marked ∧ marked marked ( x link ⊃ )) _ marked ( set ⊃ x _ )) ( marked rc ( ( y ⊃ x y )) ( )) )) ,z y, marked ( y )) )) ( y ⊃ )) marked ( y ..Sm-nrmna Algorithm Semi-Incremental 3.1. )) ( y )) 23 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 24 Algorithms 3. loih 4 Algorithm 3 Algorithm otewrigst lo h eeec on flne sddce yteatfia referenc artifical the by deducted is added linked are of which count second objects, reference external marked the the for In with Also, scanned zero. objects set. is working than heap only the counted greater internalto reference still loop, the is all first count loop, deducting the third reference and their by After as references, marked, count. remain external objects reference references with collected the garbage those from all except references unmarks now proxies, loop linked first and The procedure. counting reference Ensure: Ensure: 10 11 12 13 16 14 15 8 6 7 2 5 7 8 4 3 3 1 2 1 6 5 4 9 ∀ procedure ∀ ∀ ∀ ∀ procedure ∀ ,y. x, ,y. x, x. y. x, x. ,y z. y, x, ( ( while o all for o all for o all for root root (( (( (( o all for Pop o all for if ermn eeec on of count reference Decrement if nonrc ¬ nonrc (( ( ( gc x x ¬ IsMarked IsMarked working if if d tto it Add d tto it Add ) ) ( gc eiIceetlAgrtm-Pae3 Phase - Algorithm Semi-Incremental 2 Phase - Algorithm Semi-Incremental x x x x x ⊃ ⊃ MarkNonrc CollectRcTrialdel not IsGc ( in in in ) ( ( from Mark utat1fo eeec on of count reference from 1 Subtract x x x marked marked y y ∧ ) ) ) RcGcObjList ikdc roxyList LinkedRcP RcGcObjList in in gc ¬ ∧ ∧ ∧ IsMarked ( ( _ ref ref working y References References y y or ) gc working working set ( ( ) x x n d tto it add and ∧ ( ( ( ( ( ) ) x x ,y x, ,y x, y 6= ref )) )) then then ) IsLinkedProxy ∧ ∅ ) ) _ ( ref ( ∧ ∧ do ,y x, _ _ y set do do marked marked ) set set ( then )) ,y x, ( ( x x ⊃ ) ) working ) do do ⊲ x marked do ∧ ( ( x x link )) )) ( ⊃ ⊃ y _ ) _ ( marked marked rc then y set )) ( ,z y, y eoeatfiilrfrnecount reference artificial Remove )) ( ( y y ⊃ ⊲ )) )) utatitra references internal Subtract marked ( y )) e Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. loih 5 Algorithm h atpaei ut tagtowr.Pae6ad natfiilrfrnecutt all to count reference artificial an adds 6 Phase straightforward. quite is phase last The tsol o etodffiutt e,ta l ftecnendpscniin od once hold, postconditions concerned the of all that empty. see, is algorithms, to set mark-sweep difficult working about too the to knowledge be have our not we to betwe should level, according and it detailed However, objects more same counted links. a the non-reference and On perform and references we 1. counted high-level, Phase reference a during between On be did distinguish to 5. we will have and as we also 2 algorithm, as we Postconditions mark-sweep however, 7), violating 7, (Postcondition not and objects about 6 counted careful Postconditions non-reference fulfilling linked with reference marking concerned the be primarily objects. of is reachable roots 5 all all Phase mark detected were to have which ready we non- references, are that their ingoing we Now other heap, if phase). have counted marked, previous they the if only (or in therefore marked detected The are is linked, unmarked. proxy objects from is counted proxy count counted reference counted reference reference non-reference artificial linked, their the case remaining remove in we objects counted simple: reference quite is 5 Postcondition Ensure: phase. next collected the garbage in such exception: them only one handle that with will We marked, now, remain objects. see proxies counted to counted reference easy reference linked linked be refere such internal should and the It objects after count, deducted. represent reference been objects their have respectively collected reference and non-garbage thus references from (and external references collected the counted ingoing non-garbage These non-reference from we because references postconditions, objects. ingoing concerned, counted) both have are analyze not now objects might we counted objects If reference reference 7). only this add (Algorithm that might 6 We see Phase object. during counted again, non-reference an count to linking when added count 10 11 4 3 9 8 2 7 6 5 1 ∀ ∀ ∀ procedure ∀ ∀ ,y z. y, x, ,y. x, ,y. x, ,y. x, x. ( o all for root (( (( (( if ermn eeec on of count reference Decrement y ¬ nonrc link (( ( ← gc x ¬ IsMarked nrmn eeec on of count reference Increment ) ( gc eiIceetlAgrtm-Pae4 Phase - Algorithm Semi-Incremental x _ PointsTo x ⊃ CollectRcLinked nonrc ( in ) ( x x marked ∧ ) ) ikdorProxyList LinkedNonrcP gc ¬ ∧ ∧ ( ref ( y ,y x, gc ( ) x ∧ ( ( ( ( ) x ,y x, y ) x ref )) then ) ∧ ) ∧ ) marked ( ref ∧ ,y x, marked ( )) ,y x, ⊃ ( x ) ⊲ y )) marked ∧ ( x link ⊃ y )) do n d tto it add and marked ⊃ _ ( marked rc y )) ( ,z y, ( y eoeatfiilrfrnecount reference artificial Remove )) )) ( y ⊃ )) working marked ..Sm-nrmna Algorithm Semi-Incremental 3.1. _ ( y set )) nces en 25 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 26 .Algorithms 3. loih 6 Algorithm iltn n te postconditions. other any violating on osasaie tsol ees ose htatrti hs,Pscniin8 about Postcondition worry phase, to need this not after do that we see, references, outgoing to any easy have the not be object might should proxies counted It As non-reference the holds. alive. if stays alive, to them keep point to proxies counted reference Ensure: 27 26 25 24 22 23 21 20 18 19 17 16 14 15 13 12 11 10 9 8 6 5 3 2 1 4 7 procedure ∀ ∀ ∀ ∀ ∀ ∀ ∀ ,y. x, y. x, y. x, y. x, x. ,y z. y, x, ,y. x, ( while root (( (( (( (( (( else if Pop rc link ¬ nonrc link (( ( gc x ( ¬ IsRc x working o all for o all for o all for o all for ) ( gc eiIceetlAgrtm-Pae5 Phase - Algorithm Semi-Incremental _ _ ) x x ⊃ MarkRc ∧ nonrc rc ( ) ( from nrmn h eeec on of count reference the Increment if if if if x x marked ∧ ( ref ( ) ) x ,y x, not not not IsGc gc ¬ ∧ ) ∧ Add Mark Mark nrmn h eeec on of count reference the Increment if y y y y then ( ( _ ref working ( ,y x, y ) not in in in in ,y x, gc IsMarked IsMarked IsMarked set Add ) ∧ ( y ∧ ( ( ( y Links References Links References ) marked x ,y x, y y y ) or ) IsMarked 6= to ref ∧ )) ) ∧ n d tto it add and n d tto it add and y ∧ gc ∅ ) marked working to _ ( ref IsLinkedProxy ∧ do ( ,y x, ( ( set y x x marked working ) ( ) ) ( ( ( ( x ∧ )) ,y x, y y y do do )) ) ) ) marked ⊃ ( ( then then then _ ⊃ x y ) ( ( x x )) marked ) set ∧ marked ( ) ) then _ x working working link ⊃ do do )) set marked ( ⊃ x _ )) ( marked ( rc ( y y ⊃ y )) y ) ( _ _ )) ,z y, marked then set set ( y y )) )) ( y ⊃ )) marked ( y )) ( y )) y Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ekrfrne ontiflec h orcns ftemrigpae eol have only We phase. marking the of correctness the influence not do references Weak loih 7 Algorithm ekReferences Weak marked. been that have and the objects marked in those was objects exactly consideration, object counted that into counted reference take conclude only non-reference additionally 4 no we conclude Phase If can phase after we marking marked. objects, the been live have before all objects that of those definition of the all to that postconditions these comparing By marking the expressions. of compact end more the into at marking: them hold combine Root postconditions and those them of reorder all can we that shown phase, have we that Now Ensure: r eeecn n hi alak r aldcrety(fe h bethsde) As died). they has object object the the of (after death correctly the called about are notified callbacks get their references and weak referencing the are that sure make to eusv akn vapointers): (via marking Recursive 10 11 12 13 7 6 5 4 3 2 9 8 1 • • • • • • ∀ ∀ ∀ ∀ ∀ ∀ procedure ∀ ∀ ,y. x, ,y. x, ,y. x, ,y z. y, x, ,y. x, ,y. x, ,y. x, x. 1: 5,7: 3: 2,6: 8: 4: ( o all for root ∀ ∀ ∀ ∀ (( (( (( (( (( (( x. ,y. x, ,y z. y, x, ,y. x, ∀ ∀ y if link rc link ¬ nonrc link (( ,y. x, ,y. x, ( ( ← root gc x ( ¬ IsMarked (( (( x nrmn h eeec on of count reference the Increment ) ( gc eiIceetlAgrtm-Pae6 Phase - Algorithm Semi-Incremental x _ _ _ ) PointsTo x ¬ (( link (( ⊃ (( MarkProxies ( ∧ rc nonrc rc ( in ) ( gc link ref x x ¬ x marked ∧ ref ) ( ( ) ) ( gc ikdc roxyList LinkedRcP _ ,y x, ,y x, x gc ⊃ ¬ ∧ ∧ ( rc ( ) ( ,y x, ( x ,y x, ( ref marked ( ∧ ,y x, y ) ) ( ) ,y x, gc ( ,y x, ) ∧ ∧ gc ¬ ∧ y ) ∧ ) ( ( ( ( ) ) ∧ marked marked x ,y x, y ( ) x ∧ y ) ref ∧ then )) ) ∧ ) gc gc ) ∧ marked ∧ gc ) ∧ ( marked ( ( marked x ( y ref y ∧ ( ,y x, ref )) ) ) y marked ∧ ) ∧ ( ( ( x y ∧ )) ,y x, ( ref marked )) )) ,y x, ( marked x ⊃ ( ⊃ ⊃ ( x )) ) ( y )) )) ,y x, marked do ∧ )) marked marked ( ⊃ x ⊃ link ⊃ ⊃ )) marked ) ( x marked marked ( ∧ marked ⊃ )) x _ x link )) ( marked ⊃ rc ( ( y ⊃ x y )) ( marked )) )) _ ,z y, ( working marked y ( ( rc ( y )) y x )) )) )) ( )) ,z y, ( y ⊃ )) ( )) y marked ( _ )) y ..Sm-nrmna Algorithm Semi-Incremental 3.1. ⊃ set )) marked eemre,w can we marked, were ( y )) ( y )) 27 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 28 Algorithms 3. . ul-nrmna Algorithm Fully-Incremental 3.2 ehv led etoe ale,polm ihwa eeecsi ylcstructures cyclic in references weak with problems earlier, mentioned already have we h andffrneo h ul-nrmna ihrsett h eiiceetlalgorithm semi-incremental the to respect with fully-incremental the of difference main The de- algorithm, semi-incremental the of adaption an is algorithm fully-incremental This .. Description 3.2.1 cie ntepeiu hpe.Wieteoiia loih sol nrmna with incremental only is algorithm original the While chapter. previous the in scribed ftegraecletdpr fterfrnecutdha icuiglne non-garbage linked (including heap snapshot counted lightweight reference a the collected, of are heap part counted collected reference garbage the the of of roots the before that is, o Pto xeso oue nteJN,btdffr nteodro xcto and execution of order the collector [Ric16]. in garbage collector differs the garbage but of existing implementation JyNI, the the the into on in respect integration based modules with is extension incremental It CPython also is heap. for counted algorithm this reference heap, the counted to non-reference the to respect can be and not finalizers, finalizer. can contain any objects might by those which dead resurrected as objects, definitely be phase, dead are not marking potentially list also current of the separate therefore the set the in after back the in roots sweeped list to objects find be separate connected remaining we the can All case from and objects. them now In live move by we of cycles. tracing, set previous this during the those and in them in into including detection list encounter objects objects, or root separate counted the list the perform reference of separate all we to finalizers on moved cycle, cycles the heap were following next of counted that the the reference all of during the Once one on called, until marking wait been processed. called to have be been have have list to will not separate list we might case separate finalizers which the modern in should for some cycle, finalizers cases, next modern rare the all some object before ideally counted In cycle, reference called. collection a been reference next by have any the resurrected Before by be this reachable never finalizer). during not can list, modern freed thus separate are be (and a which will object to objects found, moved counted object counted are and No non-reference some marked objects. except case are counted in cycle, freed non-reference and be reachable finalizers to all modern counted about including for reference objects scanned All counted are reference phase. freed all sweeping be the to before about just objects processed are finalizers sweeped. Modern be might objects remaining objects Finalizers reachable the all Modern Only be found, list. to are separate some about a case objects to in All moved and and phase. finalizers marked legacy marking are for the scanned after are just freed processed are finalizers Legacy sweeped. are Finalizers heaps Legacy the which in order the to due arise, cannot iha with Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ecp ihteeknso iutosb atn h srpormadcmaigthe comparing and program user the halting by situations of kinds these with cope We ewl rcs hmaandrn h olwn yl,weew oeul o’ detect won’t hopefully we where cycle, following the during again them process will we the during point some at alive still were subgraph the in objects some means which like situation a Otherwise, changes. those synchronize to have we and barriers), write yI fa betde o xs nteata betgahaymr,i a probably has it more, any graph object actual the in exist not does object an If JyNI. olcinadmgtsilb lv o da bet a ee hne.I edetect we If change). never can objects (dead now alive be still might and collection ecrflaotti iuto,we eiighwln u nrmnsaegigt be. to to going have are We increments our objects. long dead how any to deciding sweep lead when to might situation, able this this increments, actually about the never careful during will be change we objects where subgraph, of the situation lot keep a to a had If we subgraph. inconsistencies. and the subgraph any sweep the in to non-reference save objects any dead is (and actually it subgraph were otherwise, there the subgraph), case in the In object from any reachable sweep object not counted do changed, we has inconsistencies, subgraph such the reference that its conclude, and can wou we references we Otherwise outgoing because its same. fine, exists, the is still be This object still zero. the must count If to anyway. and dropped it Jython count sweeped reference in have like its graph, because deleted object been actual the with snapshot the of subgraph unmarked arise. with might cope 3.4 we Figure counted (which in reference marking depicted snapshotted during the sweeping change to prevent can contrast to heap the in changed, counted of because been non-reference end this, has the do the snapshot snapshot heap, to at the the have However, We take if incrementally. to check objects. phase program to live marking user have the change, the we of not halt phase, rest to will marking have the snapshot the only execute the we of can As collector, phase and the marking snapshot. pause and this and we collection on references if root operates even only whole then The because heap lightweight, counted snapshot. is the reference in snapshot stored The are metadata taken. is objects) collected E A iue34 xml,wyw edsaso ossec checks consistency snapshot need we why Example, 3.4: Figure D B C h eeec rmCt sdltd fe the after deleted, is D to C from reference The ossec,DadEwudb re,ee though even alive. freed, for still checked be are not would they is E marked. D and is of D C count consistency, before reference and the created If been has snapshot o-eeec counted non-reference eeec one,graecollected garbage counted, reference ..FlyIceetlAlgorithm Fully-Incremental 3.2. ld 29 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 30 Algorithms 3. CollectRcTrialdel loih 8 Algorithm hstm,tepedcd sgvna ul-nrmna loih.I ossso three of consists It algorithm. fully-incremental a as given is pseudocode the time, This ihrsett h orcns ftealgorithm. the of correctness the to respect with 2. Phase of end the at graph object real the with .. Pseudocode 3.2.2 ycrnzto ftesaso,adte ro fewrs htntighschanged has nothing and that creation afterwards, the proof concerning then methods and with new snapshot, two pseudocode the the the of explain annotated synchronization only we will where we version, semi-incremental postconditions, the to contrast In the 0. Phase from methods of taken three end are the the However, methods tasks. individual same The the order. perform and in algorithm executed semi-incremental be will which phases, incremental of benefits the long of as all increments loose our we the make otherwise take and long, to collection). cycle too is garbage collection not situation the (although this during prevent possible possible to as as way late safest as the snapshot that conclude, can we However, 18 17 16 15 14 13 12 11 10 5 4 3 2 1 8 9 7 6 procedure leif else if leif else phase if MarkRc if MarkNonrc CollectNonrcRoots if CollectRcLinked CollectRcTrialdel finished finished finished phase MarkProxies SyncSnapshot phase phase TakeSnapshot ul-nrmna Algorithm Fully-Incremental phase phase MarkIncrement 0 = , CollectRcLinked MarkProxies ← ← ← then 2 = 1 = _ _ _ 3 2 1 phase phase phase then then then then then seeue fe h nphthsbe synchronized been has snapshot the after executed is and MarkRc r xctdo h npht ae at taken snapshot, the on executed are Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. hnsnhoiigtesaso,w aet hc l nakd(n oetal dead) potentially (and unmarked all check to have we snapshot, the synchronizing When loih 9 Algorithm h ehd nti hssrmi aial nhne,ecp htte prt nthe on operate they that 2). and except 1 unchanged, (Phases basically phases remain following phases the this performing in for methods needed, The information only the is This n lomr n ecal o-eeec one bet.Ohrie ecnunmark can we Otherwise, h counted objects. reference counted referenc whole non-reference any the reachable If keep any to changed. mark have have also we references and changed, or been counts has reference count any reference if see and objects Synchronization Snapshot the of version semi-incremental the counted in non-reference like the barriers, during on write graph Changes using counted detected algorithm. reference on. be executed the later still now of will snapshot are changes heap the they detect object of Also, to actual synchronization able the objects. the be use counted will still non-reference we They to as incrementally, comes objects. counted it reference when to graph, comes it when snapshot a save also we objects, object/proxy. linked counted and during non-reference proxies references, linked linked external the For are of to these number deletion. pointer because the trial references, calculating via internal for detection in need root interested we references only objects. references outgoing are those only the we for and the However count references reference any object. not the copy each might of to collected of proxies consists need garbage As primarily like not copy heap. treated do lightweight counted Our we be reference references, should the outgoing and of any cycle phase pro have a counted marking of reference the garbage part linked during whole be include the objects We also of might heap. copy lightweight they counted a reference because make the we of snapshot, part the collected of creation the During Creation Snapshot 10 11 12 8 9 7 6 5 4 3 2 1 procedure o all for o all for snapshot x x Add Add o all for snapshot _ _ snap snap if ul-nrmna loih nphtCreation Snapshot - Algorithm Fully-Incremental x x x x TakeSnapshot IsGc in in _ _ ∅ ← Add y snap snap ← ← ikdc roxyList LinkedRcP RcGcObjList _ in refs ( LightweightCopy LightweightCopy y y References or ) to to to ∅ ← snapshot snapshot snapshot IsLinked do ( _ x refs ( ) y do ) do then ( ( x x , , snapshot ∅ ) _ refs ) ..FlyIceetlAlgorithm Fully-Incremental 3.2. a alive eap xies, or e our 31 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 32 Algorithms 3. loih 10 Algorithm ol aearaybe re) oee,i ohcss ehv ob aeu about careful be to have we cases, both in However, freed). been already have would el rae bet.W aet epteeojcsadayojc hti reachable is that object any and objects alive. these objects keep new to these have from We they and marked objects. zero are created been newly objects have counted would reference count (all reference graph their object otherwise the synchronization, in before objects dead potentially all 28 27 23 26 25 24 20 22 21 19 18 17 16 15 13 14 12 10 11 2 1 3 4 6 7 9 5 8 procedure else if consistent o all for consistent o all for o all for else if InSnapshot MarkReachable y e h eeec on of count reference the Set if if x x _ ← ul-nrmna loih nphtSynchronization Snapshot - Algorithm Fully-Incremental SyncSnapshot IsLinked not in snap if y Add for refs if if refs x x ← LinkedObject ← RcGcObjList not Count RefCount in in IsMarked consistent if consistent consistent then true i _ LinkedObject x ← ← dead ikdc roxyList LinkedRcP ... 0 = refs snap IsMarked consistent to ToSnapshot References ( ( x x dead ( _ [ refs ) ) i ← list <> ] then then Count ( ( _ ← ← ← References x x <> ) ( do ∪ list y <> ) _ ( false false false ) refs ( ← ikdc roxyList LinkedRcP snap x y ) ) ( ( false refs Count then ( x ( _ OriginalRefCount x x x ) ) ) snap ) then o0 to ) do do ( ( [ x ⊲ i refs ] _ nakalptnilyda cobjects rc dead potentially all Unmark then snap _ snap ) ⊲ akalrahbennr objs non-rc reachable all Mark do ) then ( x _ snap ⊲ opr references Compare ) then Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. akdobject. marked elwt h rt are ftenniceetlmrigpoeue ota nthe in that so procedure, marking non-incremental the of barrier write the with well semi-incremental the as steps same the performs essentially algorithm fully-incremental The .. eiFra ro fCorrectness of Proof Semi-Formal 3.2.3 eso,w ilso fewrs o hyitgaewt h proof. the with integrate they how afterwards, show will we version, integrates snapshot the of check consistency the that is, proof to left is What version. ae3 Case ae2 Case Outline ae1 Case Proof eiFra ro fCorrectness of Proof Semi-Formal n w diinlpof otepof htn ieojc ih efreed. be might hypothesis object this live of no 2 proof that Theorem the proof, unmarked) reduce the (= can black-white to white we proofs the a Afterwards, additional to that two situation. points and show, our which tricolour in exists, will the holds object We from marked) object, (= hypothesis black algorithms. black-white no the mark-sweep hypothesis, use typical will of we abstraction proof, semi-formal the For semi-incremental the of proof the in like finalizers however, added and account, been references into have Weak taken which respectively. be objects, considered to counted are have reference taken, also 2.1.3) new was Subsection that snapshot (see show the abstraction to since tricolor have we the Also, of hypothesis holds. black-white adapted the end ⊥ ⊥ ⊥ one rxe hnw ycrnz h npht etettesnapshot the treat reference we created/linked snapshot, newly the . encounter synchronize inconsistent we we case when proxies In counted phase. marking our unmarked an to ∃ linked is object: which proxy counted counted non-reference reference marked a exists There unmarked an to points ∃ which object object: counted counted reference reference marked a exists There an to points which object ∃ counted object: non-reference counted non-reference marked unmarked a exists There ,y. x, y. x, y. x, idrc) hr xssamre betwihpit oa nakdobject. unmarked an to points which object marked a exists There (indirect): eadlne o-eeec one bet otewrigst during set, working the to objects counted non-reference linked add We nossetsaso rfrnecutntmatching). not count (reference snapshot Inconsistent h rt are rvnsti situation. this prevents barrier write The ( ( ( marked marked marked lc-ht yohss omre beteit hc onst nun- an to points which exists object marked No hypothesis: Black-white ( ( ( x x x ) ) ) ∧ ∧ ∧ link rc non ( x _ _ ) rc ∧ rc ( ref ( x ,y x, ) ( ∧ ,y x, ) ref ¬ ∧ ) ( ¬ ∧ marked ,y x, marked ) ¬ ∧ ( y marked )) ( y )) ( y )) ..FlyIceetlAlgorithm Fully-Incremental 3.2. 33 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 34 .Algorithms 3. betwihi eeecdb ienngraecletdojc exists. object collected non-garbage live a by referenced is which object ecal rmte,aekp alive. kept are them, from reachable Proof eeec one betwihi eeecdb ienngraecletdobject. collected non-garbage live 1 a by Case referenced is which object counted reference 5 Case 4 Case Proof hoe 4 Theorem 3 Case 2 Case 3 Theorem ⊥ ⊥ ⊥ ⊥ de bet:sepofbelow. proof see objects: added unmarked: external is an object collected with ∃ non-garbage object a counted from reference reference collected non-garbage linked, A below. proof see objects: added object: collected which non-garbage object live ∃ counted a reference by collected referenced garbage is unmarked an exists There increment. ⊥ root: counted non-reference unmarked an exists There marked. marked, is are object proxies counted counted reference reference non unmarked the all case and in iterated are links all an to linked is which ∃ object object: counted counted reference non-reference unmarked marked a exists There snapshot. the synchronize we afterwards, Directly phase. marking the continue an to linked is which ∃ proxy object: counted counted non-reference reference unmarked marked a exists There ,y z. y, x, y. x, y. x, y. x, edsigihbtenfu cases: four between distinguish We idrc) hr xssa nakdnnrfrnecutdro,o nunmarked an or root, counted non-reference unmarked an exists There (indirect): tteed fe h nphthsbe ycrnzdduring synchronized been has snapshot the after end, the At o-eeec one otdtcini xctda h einn feach of beginning the at executed is detection root counted Non-reference eke hcigtesaso o uhlnsada oga hyexist, they as long as and links such for snapshot the checking keep We l bet:icnitn npht(eeec on o acig,newly matching), not count (reference snapshot inconsistent objects: Old newly matching), not count (reference snapshot inconsistent objects: Old (( ( ( marked marked ¬ (( oumre o-eeec one ot rumre eeec counted reference unmarked or root, counted non-reference unmarked No bet,wihhv enaddsnetels npht n l objects all and snapshot, last the since added been have which Objects, gc ¬ ( gc x ( ) x ( ( ∧ x x ) ) ) gc ¬ ∧ ∧ ∧ ( y link link gc ) ∧ ( y _ _ ref ) rc nonrc ∧ ( ( ref ,x y, ,y x, ( ( ) )) ,y x, ,y x, ¬ ∧ ¬ ⊃ ) ) marked ∧ ¬ ∧ marked link marked _ ( rc y ( )) y ( ,z y, )) ( y )) )) ∃ x. ¬ ⊃ ( root marked ( x ) MarkProxies ∧¬ ( y marked )) ( x , )) Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ilb re:Alnwyaddojcsaemre,alrosaemre n omarked no and marked are roots all marked, are objects added newly All freed: be will betpit oa nakdojc,wihmasallv bet utb akdbefore marked be must objects live all obje means live which phase. no object, sweeping unmarked that our an conclude, to can points we above, object presented proofs three the combine now we If 4 Case 3 Case 2 Case 1 Case nwadod.Te,a h n ftesnhoiain ewudmr all mark would we synchronization, the of end the at Then, old). and (new ed o ietypoessc bet uigorgraecleto proce- collection garbage our during objects such process directly not do We when objects collected garbage counted reference all of list the enumerate We synchronizing when proxies counted reference all of list the enumerate We hswudrsl na nossetsaso,i hc aew ilke all keep will we case which in snapshot, inconsistent an in result would This otnetemrigpae sln salnwojcsadojcsreachable objects and objects marked. new been We all have increment. as objects each long those of as from otherwise beginning phase, or the marking object, at existing the collection an continue via root barrier, graph the write object during the the to detected by added detected were they are case objects in counted non-reference added Newly tteedo h ycrnzto,w ol akalrahbenon-garbage reachable all Then, mark old). would and we (new synchronization, objects. marked the collected which objects of in counted end snapshot, reference the inconsistent all at an keep in unmarked will result increase an we would would to case This they point linked), count. they as or reference case long collected their In as (garbage alive, graph. object and object counted marked the reference stay to always connected will are themselves they objects the so dure, proxies): (except objects collected non-garbage counted the Reference of end objects. the collected at non-garbage reachable Then, all old). mark would and we (new synchronization, increased. marked been objects have garbage counted must unmarked reference object the any this in references of not it count is case reference that In the object, object, marked. collected an it encounter keep we we If snapshot, snapshot. the synchronizing proxies): (except objects collected garbage counted Reference marked objects. objects snapshot collected counted the non-garbage reference reachable treat all we keep marked, will not we reachable is case keep all it this we marked, case In snapshot, is In the inconsistent. object marked. in counted already not non-reference are is the objects that case object In an marked. encounter it we If snapshot. the proxy: counted Reference objects: counted Non-reference ..FlyIceetlAlgorithm Fully-Incremental 3.2. ct 35 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 36 .Algorithms 3. ekrfrne n eayfiaiesaehnldi xcl h aewya nthe in as way same the exactly in handled are finalizers legacy and references Weak emr o-eeec one bet ecal rmfinalizers. from reachable objects objects counted the non-reference that mark sure we be can we because this, do safely can We graph. real the with rmtesprt itaentrahbefo h eto h oetal edobjects, dead potentially the of rest the from reachable not are list separate the from rw ol aemre ikdojcsatrtesnhoiaino h npht when snapshot, the of snapshot, synchronization the the of after creation objects the linked during marked reference, have would a we such inconsistent or detected is have would cycle we collection otherwise this from objects without dead objects the these of sweep can rest we the snapshot, if the even with consistent ado, we still further is snapshot, list the separate subset. of the objects separate consistency If (some a the managed sets like check have we both objects we when join those If we then, treat separate. separate, list, can list the separate objects the the from the keep keep reference in we and to a otherwise object detection encounter resurrected), an we been root to If probably during graph have snapshot. list object the the this in of in them rest objects include called. the simply been we processing had this marking, of directly finalizers processed list modern We of all separate instead finalizers. after Now, a modern cycle, had with collection sweeped up following be the ended to during we about list algorithm objects the some if of objects, version non-incremental the algorithm. In the of correctness the Finalizers change not should Modern in this It and anyway. that declining finalizers see, probably to modern is by hard usage replaced too their been be as have not possible, should as they the simple application, keep as most to algorithm non-incrementally the processed of are rest finalizers Legacy version. semi-incremental Finalizers Legacy and References Weak Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. . yyArchitecture PyPy 4.1 .. RPython 4.1.1 h Pto usse hntasae hsitrrtrsaial noCcd n utilizes and code C into statically interpreter this translates then subsystem RPython The the explain to have first we PyPy, in implemented are algorithms the how understand To to order in PyPy, in implemented were chapter, last the in presented algorithms The ita ahnsfrdnmclnugs h aeRyhndrvsfo h at that fact, the from derives RPython name The languages. dynamic for machines virtual n ssteitra nepeaino h oddPto rga ognrt h C the generate to program Python loaded programs RPython the include of to interpret interpretation code. interpreter to internal meta-programming Python need the a not a is uses uses does Python and instead compiler fact RPython but In the programs, code. means RPython machine which into RPython, RPython. it for in compile language interpreter to an compiler implement C virtual to a new neccessary a only implement is to RPython it uses language, used who a developer be for in language can machine a written RPython of that (Python standpoint language. fact, from a dynamic From the comes any change for PyPy not machines name does itself virtual the it compiler write where but RPython to Python), is The in This Python. written of RPython Python. subset in writing restricted written for a is infrastructure is an language and RPython language the a is RPython RPython. in written is PyPy system. this with integrates code cpyext existing the how and PyPy of architecture verified. was implementation the of correctness the how present, also and be detail can implementation The repository: chapter. branch/cpyext-gc-cycle next official the the in in described found as performance, their compare nti hpe,w ildsrb h hne oPP in PyPy to changes the describe will we chapter, this In . https://foss.heptapod.net/pypy/pypy/tree/ Implementation CHAPTER 37 4 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 38 Implementation 4. htmksteRyhnifatutr pca,cmae omr rdtoa toolchains, traditional more to compared special, infrastructure RPython the makes What .. petmodule Cpyext 4.1.4 extension Rawrefcount 4.1.3 Collector Garbage 4.1.2 ol edsrbe rbbytebgetcalne eewudb,t oewt different with cope to be, would here challenges biggest the Probably desirable. be would memory the and collector garbage the developer, language the for simple things keep To s rcn;epii s mlctetra eeecs t. n tl ananacceptable maintain still and etc.) references; external implicit vs. explicit tracing; vs. bet eeecn uhojcsada diinlatfia eeec on,t prevent PyPy to collected. to count, never drops reference are artifical count object additional reference such an their one add if least objects freed, at such of only referencing (on consisting are objects objects cycles C live means by potentially which of managed zero, management collection Objects object premature the prevents heaps). objects of the only both of implementation and aware existing minimal collector the very garbage However, is representa- RPython’s It code. makes PyPy’s C. also C and and It by C RPython managed in program. written Python, Python modules a in extension of written tion CPython PyPy, between for gap module the a bridges as implemented is Cpyext counting (reference objects performance. controlled externally the of management an memory is approach of this general styles thesis, more this a of implementations, sake in future the concerns for For specific however collector. language heap. compromise, garbage counted some acceptable agnostic reference introduce language from to information otherwise have neccessary we the the that all means already access this code to Unfortunately, Similar able RPythons be RPython. in to from module extended, objects cpyext controlled the methods, externally for template those implement exists and access collector can garbage we the so modify to able are we Fortunately, simply cannot objects externally those by are system. occupied memory modules memory RPythons those the by in means managed which Objects garbage be code, implement for C to modules. by specifically difficult extension controlled implemented somewhat CPython be it to makes for need this collection However, not do language. and target RPython the in implemented are system to compared effort minimal with language, developers any enables for This approaches. compilers program. traditional JIT interpreted (and develop the compilers subsystem of rapidly JIT RPython trace tracing to the the of optimizations), compiling nature clever essentially the with is by combination the in and of choices this representation design doing internal specific of By additional interpretation an code. the using machine during execution, compiler generated interpreter, during its JIT the circumstances recording of tracing by certain execution a program, under the the integrates triggered traces also is then it compiler It interpreter, JIT interpretation. an This generate executable. only the not into does it that is rawrefcount xeso.Ti oenest be to needs code This extension. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. . xedn Rawrefcount Extending 4.2 ihrgrst abg olcin peti epnil o h ntaiaino the of initialization the for responsible is cpyext collection, garbage to regards With .. xedn cpyext Extending 4.2.2 .. xedn h CInterface GC the Extending 4.2.1 l fteaoemtosadlssaeijce noRyhnsgraecletrwe the when collector garbage RPython’s into injected are lists and methods above the of All For representations. object two the between convert to required, are methods Additional ob bet asterqie ehd otegraecletr eea te at of parts other several collector, garbage the to methods required the pass to able be To garbage CPython’s and collector garbage RPython’s between interoperation need enable that To objects counted reference access (e.g. to situations able certain be in to collector and garbage forked) is the process of the behaviour when extended the control To of code the alongside located primarily are algorithms our of implementations The h Pto rmwr n yynee ob extended. be to needed PyPy and framework RPython the eoh nRyhno ydlgtn h al opee fCcode. C of pieces to the calls implementing the directly delegating by by either or methods, RPython provide template to in needs GC medoths also the It for infrastructure. implementation collection an garbage CPython’s of structures internal supported. be also might collectors garbage garbage default other the future, in the implemented In only is incminimark. interface collector extended the Currently, a cycle. support. reference and a tuples of allocated part newly become of or list be might the tuple to query a pointer to if method a determine, a to objects, added: method of been type also finalization have the interfaces three objects. integrations, collected advanced code: garbage more of of pieces list two global to CPython’s access and needs method mainly tp_traverse collector CPython’s garbage the infrastructure, collection developers. now language collector by garbage invoked the be etc.), can (finalizers, that language methods, implemented additional the offers in processed be to also modules other several model, However, adapted. memory behaviour). CPython’s be existing with to the interoperate needed mimics to each that need dummy, for we (two a as classes for interchangable one three and in implementation encapsulated collector, garbage RPython’s a extended. for be However, to simple. needs the implementation implementation modules, the this the those keep As support, for to sophisticated zero. support order more be rudimentary in otherwise add reasonable might to were count created restrictions reference originally actual was their module as cpyext freed, being from them petmdl slae,aogietearayeitn ehd o h uietr GC rudimentary the for methods existing already the alongside loaded, is module cpyext ..EtnigRawrefcount Extending 4.2. 39 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 40 .Implementation 4. .. xedn h etn Framework Testing the Extending 4.2.3 hsla oteie fa btato,weecetr fsc etcss on longer no do cases, test simplified. such be of to creators had where tests abstraction, such an creating of prone, idea error the and to tedious lead quite This be to proved way was it conveniently, cases corner their and scenarios common all test to able be To h olwn trbtswr de otendso h rp,t mlmn u test our implement to graph, the of nodes the to added were attributes following The manually. tests a those enables write This would editor. we text if have, a not in would or we code Python from either need attributes, not custom do we our so with attributes, those handle to able be will Python, for exist already which directed describe to language text-based simple a is language description graph DOT The eatcEtnin fteDTlanguage DOT the of Extensions Semantic owieoronpres sms ol ilinr nnw trbts ecnuethem use can we attributes, unknown ignore will tools most As parsers. own our write to cases: which visualization, case test time or any generation at test-case annotate automated can like we possibilities, that of graphs, lot DOT custom our visualize or parsers, Low-level edit generate, tests. to our for needed make information can influence additional We to encode metadata. need to arbitrary neccessarily this, encode not might of do they use attributes tools but new popular representation, of Those several graphical set like do. the fixed defined, already a graphs be their define might DOT not describe attributes does for to itself additional edges language means or The which nodes attributes, graphs. to those added in be representation might graphical Attributes graphs. undirected and graphs, language object description describe graph to DOT fit good extensible a the [dota]. research, be heaps some sense to After both make seemed across to cases. spanning language seemed test It description those environment. describe graph testing to DOT the language, of a internals integrate the to about existing worry the to need in more tests need those we writing As and understand. what implementation and for our read long test to relatively hard to were quite cases, existing they also test the and that complex way achieve was the to written, trying with were were issue collector they main garbage The the framework. for testing tests the extend to neccessary • • • type rooted alive – – – – – (mandatory) yyobject PyPy = P beti edadsol ecollected be should and collected dead be is not object should = and n alive is object = y object CPython border = the C at object linked = B (mandatory) otoa;frPP rbre objects) border or PyPy for (optional; Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. • • • • • • • • • • added garbage delete tuple resurrect finalizer tracked gc tuple_type ext_refcnt – – – – – – – – – – – – – – – – – otoa;frCyhno odrobjects) border or CPython for (optional; hntefiaie fti beti executed is object this of finalizer the when beti ul n hudb de otetuple_list the to added be should and tuple a is object = y fe_np=teojc scetd fe h nphthsbe created been has snapshot the after created, is object the = after_snap (default) objects of list global the to added be will and tuple a not is object = n objects of refer- set from managed resulting the count, to reference external additional ences 0): (default integer positive h betsol ee eaddt cgrae(default) gc.garbage to finalizer added legacy collection, be a the never with should after object object gc.garbage dead the to a = by added n alive been kept have is should it because object the = y removed, be should (reference) edge the which to (object) node the of name of finalizer the when resurrected, be executed should is that object (object) this node the of name epy bethsn nlzr(default) finalizer no has object finalizer = legacy (empty) a has object finalizer = modern legacy a has object = (default) modern tuples of list list any or in objects tracked of not list is global object the = in n tracked is object = y beti o abg collected garbage not is object (default) = collected n garbage is object = y ul sntiiilzdytadsol ekp ntpelist tuple in kept list be GC should global and the yet to initialized promoted not be is should tuple and untracked = types be 2 gc should contains and tuple types = primitive 1 only contains tuple = 0 (default) set root PyPy’s in not is set object root = PyPy’s n in is object = y otoa;frCyhno odrobjects) border or CPython for (optional; otoa;frojcswt oenfinalizer) modern a with objects for (optional; otoa;frflyiceetlalgorithm) fully-incremental for (optional; otoa;frgraecletdobjects) collected garbage for (optional; (optional) otoa;frCyhno odrobjects) border or CPython for (optional; otoa;frojcswt oenfinalizer) modern a with objects for (optional; otoa;frCyhno odrobjects): border or CPython for (optional; mnaoyfrtuples) for (mandatory ..EtnigRawrefcount Extending 4.2. 41 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 42 .Implementation 4. . eiIceetlImplementation Semi-Incremental 4.3 hsipeetto sbsdo obnto fPP’ eeainlgraecollector garbage generational PyPy’s of combination a on based is implementation This pytest-based existing the into tests driven data as integrated were tests DOT new The graph: the of edges the to added were attributes following The bet,aedsrbdhr,frbte understanding. counted better fully- reference for the of here, than abstraction described simpler the are is like objects, it solutions, As common algorithm. implementation, tracing incremental backup generational CPython’s and correctly are files are expected. the checks as that sanity works ensure Some framework to testing test, results. the actual test and the the parsed folder to in respective prior individually the performed displayed from automatically are automatically results discovered the are and files DOT framework. testing case. for test Framework tests the Testing of the the creator of into the execution of Integration and the responsibility graph during the the done in of lies not topology rather is the but the this reasons, from However, several inferred attributes. be could other attribute the alive the that Note, • • • • weakref added removed removed – – – – – – – – – – epy h eeec ilntb eoe (default) removed be not will snapshot reference the the after = graph, (empty) the from created removed been be has will reference the = (default) after_snap collection first the to prior created has was snapshot reference the the after = (empty) graph, the to added created was been reference the = after_snap (default) removed be not zero will snapshot to object the drops the after count = graph, reference (empty) the its from because removed created, be been will has object the = after_snap (default) collection first the to prior exists object the snapshot = the (empty) after created, is created object been the has for proxy linked a = linked_after_snap eeec sawa eeec n osntices h eeec count reference the increase not does and reference weak a is reference = y eua eeec hc nrae h eeec on (default) count reference the increases which reference regular a = n otoa;frflyiceetlalgorithm) fully-incremental for (optional; otoa;frrfrne nterfrnecutdheap) counted reference the on references for (optional; otoa;frCyhno odrojcs o ul-nrmna algorithm) fully-incremental for objects; border or CPython for (optional; otoa;frflyiceetlalgorithm) fully-incremental for (optional; Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. .. btato frfrnecutdobjects counted reference of Abstraction 4.3.1 rhtcual,oeo h ol a oipeetteetr loih o reference for algorithm entire the implement to was goals the of one Architecturally, h olwn ehd aebe de oteitra nefc ftegraecollector, garbage the of developers: interface language internal by the used to be added can been which have methods following The reference the of initialization upon collector garbage the to passed now are lists Two to necessary not is it Nervertheless, practices. in interface specific rather programming or this runtimes need other will for used be also can implementation, the that imply would agae htfc iia sus oee,i sqetoal,hwmn te languages other many how questionable, is it However, issues. similar face that languages Methods subsystem: counted RPython existing the to Lists made been support: have object changes counted following reference the for interface level, detailed especially a languages, used. On other even for not compilers is JIT interface create the to if code Python-specific any include This possible. as system underlying that was the fact, goal in the the concerns and of specific subsystem because PyPy RPython is the little This in as way. implemented introduce is agnostic to PyPy language of less collector or garbage more the a in objects counted • • • • • • hc ih epr farfrnecce hsls ssmlrt h it sdin used lists the to similar is list This cycle. reference a of part be might which sriiilzd sti ih tews edt rse ruepce behaviour. unexpected or subsystem crashes cpyext to the lead before activate_rawrefcount_cycle otherwise used process, might example forked this for a is as This of reinitialized, initialization alive. is were the they during if PyPy as objects, in counted reference all should treat result, and a as and, cleared deactivate_rawrefcount_cycle heap. been the have from objects swept all been null, have returns method the If next_cyclic_isolate for optimization an is This tuples. 4.3.2). allocated Subsection newly (see all objects contains immutable list for This lists several list: not Tuple CPython. and in list like tracked, one objects, are only of objects is generation counted there each reference except all collector, where garbage list CPython’s a is This objects: of list Global iaiainspot(e uscin4.3.4): Subsection (see support Finalization – – cyclic_garbage_remove finalizers. contain might cyclic_garbage_head eun h etojc fada yl,ta hudb cleared. be should that cycle, dead a of object next the Returns : eun h rtojc ftels fcci slts that isolates, cyclic of list the of object first the Returns : eciae h yl detection. cycle the Reactivates : eoe betrtre ycyclic_garbage_head. by returned object Removes : eciaeteccedtcinagrtmtemporarily algorithm detection cycle the Deactivate : ..Sm-nrmna Implementation Semi-Incremental 4.3. 43 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 44 Implementation 4. .. Tuples 4.3.2 ocl agaeseiccd rmteG,tefloigtmlt ehd aebeen have methods template following the GC, the from code language-specific call To ulsaentdrcl de otegoa itwe hyaealctd u r instead are but allocated, are they when list global the to collector. added garbage directly our not of are performance Tuples overall the improves likely most which we As cycle. reference a of part be still might they but Python, in immutable are Tuples hc ih epr facce(ulsta oti uls rohrojcsta might that objects other or tuples, contain that (tuples cycle a of part be might which ulsta ih epr facceit h eodgnrto.A u abg collector garbage our As generation. second the into only cycle promoting a by of implemented, part is be up languages. might optimization left other that is this for untrack tuples reused collector to is garbage tuples interface CPython’s which this this used In deciding case from is of in removed hook logic developer, are tuple_maybe_untrack the language tuples The means the other cycle. which to All reference task, list. a this global cause perform the never to to will moved tuples they are only as cycle) cycle, list, a collection of next part the be During above. described list special the cycles, to collection added future reference in a ignored of remove be part therefore to become never can hook might and a tuples integers) as some of well because tuples as allocated is collector, (e.g. newly This cycle garbage for list. the list this a to from available exists tuples made there subsection, is previous which the tuples, in described already have added: epaeMethods Template • • • • • • gc_as_pyobj pyobj_as_gc uscin4.3.2). Subsection tuple_maybe_untrack 4.3.5). Subsection (see dies clear_weakref_callback 4.3.4). tion finalizer_type references. traverse – – – – loih.Ti a eue uigtecntuto ftegraels,to list, garbage the of end_garbage construction the behaviour. during unexpected used prevent be can This algorithm. list. begin_garbage garbage the to added be list. garbage next_garbage_pyobj the to added be should next_garbage_pypy altepse alako vr bet h eeec one object counted reference the object, every on callback passed the Call : eunteG edro h eeec one object. counted reference the of header GC the Return : eunterfrnecutdojc eogn oteG header. GC the to belonging object counted reference the Return : euntetp ffiaie,teojc mlmns(e Subsec- (see implements object the finalizer, of type the Return : enbe h epcieprso h code. the of parts respective the Reenables : eprrl ialsprso h oei h yl detection cycle the in code the of parts disables Temporarily : eoetetpefo h ito uls fpsil (see possible if tuples, of list the from tuple the Remove : la h alaks hnawa eeec oti object this to reference weak a when callback(s) the Clear : eun h etrfrnecutdojc,wihshould which object, counted reference next the Returns : eun h etnnrfrnecutdojc,which object, counted non-reference next the Returns : Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. .. Finalization 4.3.4 Cycles Clearing 4.3.3 hr r w ye ffiaiesi yhn hc r upre yteccedetection cycle the by supported are which Python, in finalizers of types two are There h n facleto yl,oc h atojc a enpoesdi hswy this way, this in processed been has object last the once cycle, collection a of end the oe oals fgraeojcs cesbet h plcto eeoe (gc.garbage), developer application the are to they accessible Therefore, by objects, called routine. garbage cpyext be of never asynchronous list should our a they in to so even moved structures, not cyclic collector, on call garbage to our save not are again. finalizers processed Legacy be to needs 4.3.3. and Subsection finalizers objects in is Legacy of described is it list as outside, set global processed from the the and unreachable to objects cycle, still moved dead is is collection of it set following set Otherwise, the the the If to during collector. back garbage Then, moved the by objects. the again being using returned processed tp_finalize of routine, the the instead asynchronous of calling same case, and the this slot in In methods cyclic_garbage_remove called collection. and are separate cyclic_garbage_head finalizers a finalizer_type all to cpyext, the moved by (using If are cleared finalizers 3.1.3. isolates modern Subsection cyclic with in all objects described hook), encounters as finalizers, collector garbage modern the process able is implementation Our them. of both finalizers implement to Modern Python is decided current algorithm we by our finalizers, of that supported show types still to all are and with compatibility but compatible backwards proposal, provide To this implementations. with deprecated been ( [ have finalizers 442 Modern PEP by finalizers. introduced legacy and modern implementation: their because detected, zero. were to that dropped structures have cyclic should in count safety, objects reference for all count deallocated reference have their should increments it returned, are method objects next_cyclic_isolate an their as the calls after long calls then asynchronously As simply executed and loop. which is cycle garbage a code, collection routine in the Python garbage cpyext of compiled) a respective context JIT of the The (or increment from interpreted supported. routine execute collector, not to deallocation the garbage try the is (using the might call cpyext of it to by scope as safe mark- processed collector, the not our of is is outside of which it done phase set, because is sweeping a This the to during method). moved However, heap next_cyclic_isolate instead 3.1. the but Section from collector, in removed described sweep directly as not algorithm our are by they detected are structures cyclic Dead approach this adapted needs. we our objects, fit counted to reference above, organize described to as generations use not does tp_clear pep ehdadte ermnsterrfrnecutaan At again. count reference their decrements then and method n r h ucso flgc nlzr ( finalizers legacy of successor the are and ] ..Sm-nrmna Implementation Semi-Incremental 4.3. tp_finalize tp_del aebeen have ) ,which ), 45 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 46 Implementation 4. . ul-nrmna Implementation Fully-Incremental 4.4 ekrfrne ncyx r mlmne slne rxe owa eeecxi PyPy. in referencex weak to proxies linked as implemented are cpyext in references Weak .. ekReferences Weak 4.3.5 fe h olcincce nta fcern hs bet,tecyx otn retreives routine cpyext the objects, those clearing of instead cycle, collection the After ie tta h akn hs seeue nasaso fteha.Ti mle,that implies, This heap. the of snapshot a on executed is phase marking semi-incremental the the that with it code wise, the of lot a shares implementation fully-incremental The especially that be problem, to a needs collector solves garbage implicitly CPython’s it attention. but special overhead, need unnecessary otherwise an would like seem might This wr fwa eeec alak ncci tutrs yhnoesawyfrapplication for way a offers Python structures: cyclic in callbacks reference weak of aware nphthst ecetdadti nphthst esnhoie.W ilexplain will We synchronized. be to has snapshot this and created be to has implementation- snapshot also a but algorithmically only not difference, main The implementation. callbacks. the problematic after any structure about cyclic worry to respective is need alive the not them clears does cpyext kept it As that phase, proxy cpyext. sweeping the by corresponding because cleared afte collector, be is subsection, sweeped garbage to this This be the about of will of beginning beforehand. objects phase the counted cleared marking in non-reference the be mentioned Those to as structures objects. are, need counted cyclic references non-reference not the weak do before actual callbacks die the structures. always problematic because cyclic this callback) so the CPython their cleared, clearing In (and called before are cleared. references also callbacks, yet weak such are not PyPy, callbacks clearing are these and In which then detecting objects by because resurrect solved, issue, might is an objects them is referenced of cyclic weakly This some sweeping some call. and and When this called during die. are die objects methods might referenced clear respective weakly the when structures, notified, be to developers alread not does will which we object as counted routine, reference object. this each linked during for a by triggered This objects have enclosed proxy be interfere. is linked might not routine creating collector does cpyext be garbage collector the the garbage of as the part necessary, so is This calls, list. end_garbage gc.garbage They and the begin_garbage methods. to next_garbage_pyobj appended and then next_garbage_pypy the are using by objects those objects reachable all until encountered, continued are is objects processed. process linked been objects tracing case have unmarked This in a all (GCFLAG_GARBAGE). boundaries, to and flag heap moved traced new across and a also hook with are traverse they marked objects the are objects counted using of Non-reference legacy traced set are with list. complete objects separate objects the counted of determine reference set To alive, the hook. keep determines finalizer_type collector the garbage using the finalizers, able cycle, are cycles. collection developers their a application breaking During there, manually From by alive. objects, keep these they free objects to the of all including y r Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. .. nphtCreation Snapshot 4.4.1 l fteeojcsne ob cne ortmsi oa,i re ocet h snapshot. the create to order in total, in times four scanned be to need objects these of All hsi aiiae ntresteps: three in facilitated is This moved eventually are (tuples objects of list global the in objects all includes snapshot The non- the of phase marking default the of increment last the in created is snapshot The h ed ftebffrue o h ih oylo sfollows: as look copy light the for used buffer the of fields The ato yl)adalcci sltsfo h atcce(o eal e eto 3.2.2). Section see details (for cycle last the be from also might isolates they cyclic (as all proxies and linked cycle) collected a non-garbage of all part beforehand), list the to the in object the of objects. location those the between to references adresses, themselves raw the objects of the store array of to an copy buffer. used in light is stored a snapshot are buffer store the References to memory save used to second is buffers the buffer memory and memory large non-reference two One all First, from allocated. reachable marked. are are been that have objects, roots, all counted after directly heap, counted reference in the described to already relates were implementation 3.2. differences this Section algorithmic how The and implemented implementation. been semi-incremental have methods those how 1. 2. • • • • • • • scn cn.Frec bet l ugigrfrne r oist h second the to copies are references outgoing all object, each For scan). (second hc siiilystt h rgnlrfrnecount reference original the to set initially is which nadcinr,i aei ed ob etrdatrad ol eddfrlinked up for backed needed is (only field afterwards restored this be of to content the needs The in it object object. objects). case the original in will of dictionary, the and index a of the object in field storing original a (temporarily) the by in another to two, snapshot point after step initially in one They remapped buffer, be memory scan). (third the buffer in memory created are count objects reference all their of of sum copies the Light as well as scan). count (first their calculated and are iterated are objects All of end the at synchronized is refcnt snapshot the when phase changed, marking been the have objects the to refcnt_original refs_index status pypy_link pyobj refs_len h drs fteoiia beto proxy or object original the of address the : edfrterfnecut hti sdt aclt h ot ftegraph, the of roots the calculate to used is that count, refence the for field a : h akn ttso hsobject this of status marking the : h ubro ugigreferences outgoing of number the : h drs fteoiia,nnrfrnecutdojc rproxy or object counted non-reference original, the of address the : h rtidxo h ugigrfrne ntearyo references of array the in references outgoing the of index first the : h rgnlrfrnecut hc sue oceki h references the if check to used is which count, reference original the : ..FlyIceetlImplementation Fully-Incremental 4.4. 47 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 48 .Implementation 4. .. akn Phase Marking 4.4.2 .. nphtSynchronization Snapshot 4.4.3 ehv oinr uhojcs ncs eecutrte uigtaig hsi quite is This tracing. during them encounter we case in objects, such ignore to have we h nphti ycrnzdi h aticeeto h akn hs,drcl after directly phase, marking the of increment last the in synchronized is snapshot The in executed be will which of each sub-phases, several into divided is phase marking The ay eas hi ikfil stpclyzr,ecp o-abg olce bet that objects collected non-garbage except zero, typically is field link their because easy, akdrahbe u nyi aetesaso ssilcnitn ihtera graph. real the not with are consistent which still objects, is all snapshot sweep h the to that case want objects, in We all only created. keep but was we reachable, safety, snapshot marked ensure the To after marked. added been been have objects reachable all increment: separate one least at created. the been tracing has start snapshot we the before after dictionary, state, their a previous set in we the it restore too, store We objects temporarily graph. these and exclude object zero To to proxy. counted fields non-reference link a to linked means are which snapshot, the to added the be of not buffer should memory objects the collected in field. non-garbage object link Other the the of in to index stored regards that temporarily with except is objects, snapshot, snapshot collected the garbage of like creation handled the are proxies collected Non-garbage 1. 3. 3. 2. fut cn.As,teoiia otn ftefilsta aebe sdfrthe for used been have that fields the of content original the Also, scan). (fourth sw aet ycrnz h nphti h aeincrement. same finished, the not in is limit snapshot increment incremental the the the synchronize However, to before finished. have empty is kept we are phase are as sets marking sets working working the the reached, the the If is and Once increment. over repeated. next is is reference increment the process the for for the reached, set step, is working second limit marked, the the incremental are If during objects increased counted marked. are objects reference are counted First, objects objects unmarked sets. counted and working non-reference the cases then of both one outgoing in marked, either traced is to counted are object added non-reference an objects When for linked (one processed. and are reference set references sets working added working separate both newly Then a increment, to objects). an added of are beginning proxies set. the counted working at a to greater Marking: added refcnt Incremental are a have objects which those objects of for All scanned zero. is than snapshot the Collection: Root refcnt snapshot. the the from within subtracted objects are the counts of reference field internal all Determination: Root snapshot the in object restored. the is of index copy object’s the to point they so remapped, are References ave Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. hc hudntfe n oetal ieojc.Ojcsi ylcioae rmtelast the from isolates cyclic in Objects object. live potentially any free not should which exist still that objects, all unmark we strategy: following the use we this, achieve To hc aearaybe oe osprt it akt h cullssadmr all mark and lists actual the to back lists separate to moved been already have which nteoiia rp sm ol aearayde sarsl farfrnecount reference a of result a as died already have could (some graph original the in olcinaehnldi h aemanner. ph same sweeping the the in to handled continue are we objects collection Then, all move processed. all we been as yet inconsistent, phase, not was sweeping have it which the If objects, to now. proceed by simply unmarked be can should we objects consistent, dead was snapshot the If all free we consistent, follows: is as snapshot works the this If detail, mark In and unmarked. are synchronization just afterwards. references the have objects outgoing we stop unmarked all we that and inconsistency, again, count an objects reference encounter all the we if If check matching. we still Also, zero). to dropping 1. 3. 2. fewrs esa h urn ito o-abg one rxe n okfor look and proxies counted non-garbage of list current the scan we Afterwards, eaottesnhoiain sw i o o-abg olce bet Old object. collected non-garbage for did we as synchronization, the abort we that object an found have we after them, for looking stop can we it, creating when ntera rp,a hyaeol re ytegraecletradnvra a as never and collector garbage exist the still by objects freed those only that are sure, they be as can graph, We real proxy. the collected on snapshot non-garbage the the a of in not beginning is objects the at such always are for objects searching these by that ensuring proxies, By collected snapshot. non-garbage all sync We r oe oasprt itfrda isolates. dead the for objects like list dead works Potentially separate basically a and no objects. to simple be collected moved rather can garbage are is there still other this As can all case, we for vice-versa). this consistent, synchronization (and in is objects the objects subset these if added this free step, newly case and this In progress perform inconsistent. some also was make We snapshot synchronized. the are of collection rest last the from Isolates list. separate unmarked, a is to moved object this In and alive. object kept counted simply non-reference are the a objects to to New linked reference field. valid are count a they have reference case only created cyclic because was their objects, snapshot in garbage old the snapshot of and when new list existed between current that distinguish the objects over can We iterating by objects. synchronized, collected are collected garbage All during considered inconsistent not an were which also added, is been this phase). have as marking proxies synchronization, the new the that abort seems unmarked. to (it is have state object we counted case, object. non-reference this collected the In non-garbage where an a proxies, have to always collected link they non-garbage their because of is, result This a zero. as to count dropping reference count artifical reference a of result bet r hce o ossec n vnuly oetal edojcsare objects dead potentially eventually, and consistency for checked are objects ..FlyIceetlImplementation Fully-Incremental 4.4. ase, 49 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. .Implementation 4. 50 . Verification 4.5 .. Premises 4.5.1 hc h ro fteagrtmasms r ufild esseaial mlyunit employ systematically we premises, fulfilled, all are that assumes, and algorithm algorithm the the of with proof consistent the is which implementation the that verify, To h eifra roso orcns nSbetos313ad323ipiil rexplicitly or implicitly 3.2.3 and 3.1.3 Subsections in correctness of proofs semi-formal The nt,wihaevrfiduigteeitn etn niomn.T nueta the that ensure To testable of environment. list testing a into existing them the condense using we verified fulfilled, are are premises which all units, that ensure To test. fteepeie,wt h aeo h ets hc a efudi h following the list in logs. a trace found find using be manually, can can verified you were which tests, Below test(s) automatic the without valid. of Premises not have are name pypy/module/cpyext/text/test_cpyext.py we the mark-sweep rpython/rlib/test/test_rawrefcount.py, premises that with implemented files: those Note, the premises, that them. these of assume of of premises each we tested) for as created (and test we algorithm, existing unit practice, a already in implemented fulfilled the and are included them premises of those if list check a To premises. several assume 4.2.3. Subsection in have behaves we described partitions which environment, partitions, the testing the in of our each using data for verified case input test and the exemplary implemented why one present and we Then, partitions equally. partitioning. those equivalence describe use we we algorithm, First, described the with consistent is implementation 11. called. eventually are finalizers Modern 10. 1. 6. 5. 2. .Altmlt ehd ecie nSbeto .. oka specified. as work 4.3.1 Subsection in described sweeped. are methods template objects All non-cyclic dead, 9. of list sweeped. the are in objects Objects cyclic dead, 8. of list the in Objects 7. 4. 3. hnte r rae:test_gc_track created: are they when bet,rahbefo sltdojcswt eayfiaies r de othe to added are finalizers, legacy with list. objects gc.garbage isolated from reachable Objects, counted test_create_link_pypy (non-)reference test_create_link_pyobj, of linked: set are the they to when added proxies, are proxies counted (Non-)reference test_collect_o_dies test_collect_p_dies, dies: proxy their when unlinked, test_create_link_pyobj are linked: Objects are the objects when in added, is content count reference their artificial An on depending created: untracked, are test_gc_tuple_track or they method: tracked tuple_maybe_untrack when correctly tuples, are of Tuples list the to added test_gc_tuple_track tuples objects, counted of list Reference global the to added are objects counted reference collected, Garbage Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. .. vuvlnePartitioning Evquivalence 4.5.2 h iesoso u mlmnainaelse below: listed are implementation our of dimensions The semi- the with consistent is algorithm implemented the that verify systematically To l iesosaetse,w aevrfidtecreteso h hl implementation. whole the in the of partitions correctness all verify the Once to combine verified unit-test. order have can single we we in one tested, dimensions, into partition, are multiple them each dimensions with of for all work several cover we data to If sufficient input dimensions, is partition. a single those it whole in one assumption, the inputs this for of all to correctness test inputs, According possible a way. of provide same set the to infinite exactly Equiva- the in of partitioning. behave equivalence out partition apply that we assumes, algorithm, partitioning the lence of description proven formally 2 oenfinalizers: Modern y/n tuples: 12. counted y/n reference objects: uninitialized Tracked, collected garbage 11. containing tuples, counted Reference 10. 3 eayfinalizers: Legacy 13. 4 iewa eeecs y/n references: weak Live 14. .Nnlne,nngraecletd eeec one bet:y/n references: Cross objects: counted 5. reference collected, y/n non-garbage Non-linked, objects: counted 4. reference collected, y/n garbage Untracked, objects: counted 3. reference collected, garbage Tracked, 2. y/n objects: counted Non-reference 1. .Rfrnecutdtpe,cnann nypiiievle:y/n values: primitive only containing tuples, y/n counted Reference objects: counted 9. reference including y/n subgraph, Non-cyclic objects: counted 8. reference including y/n cycles, Reachable objects: counted 7. reference including cycles, Unreachable 6. )Mr hnoepoyi tlatoesubgraph one least at in proxy one than More d) subgraph per proxy counted reference one most At b) )Ol ecal cobjects rc reachable Only b) )Ol ecal cobjects rc reachable Only b) )N rs references cross No a) )N oenfinalizers modern No a) )N eayfinalizers legacy No a) )A otoennrfrnecutdpoyprsubgraph per proxy counted non-reference one most At c) )Mxdrahbeobjects reachable Mixed c) )Mxdrahbeobjects reachable Mixed c) ..Verification 4.5. 51 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 52 .Implementation 4. diinldmnin o ul-nrmna implementation: fully-incremental for dimensions Additional h etcss(o et) hc loehrcvralpriin,aelse eo.The below. listed are partitions, all cover altogether which tests), (dot cases test The epcieprtosec etcs oesaeas nldd(ulctsaeomitted): are (duplicates included also are covers case test each paritions respective M) 6 edwa eeecsi o-ylcsbrps y/n subgraphs: non-cyclic in references weak y/n Dead cycles: 16. within references weak Dead 15. G) K) O) Q) D) N) H) A) R) C) B) P) E) 6 eeec ewe o-eeec one bet de ewe incremen between added objects i7. counted y/n non-reference between increments: Reference beteween removed i6. objects y/n counted reference increments: Non-linked, beteween created i5. proxies y/n counted non-reference increments: New beteween created i4. proxies y/n counted increments: reference beteween New added i3. objects y/n counted increments: non-reference beteween New added i2. objects counted reference New i1. F) L) S) J) I) 5,1n 1,in 3,in 5,in i7n i6n, i5n, i4n, i3n, i2n, i1n, 16n, 15n, garbage_cpython_simple_1 garbage_cross_simple_1 free_cpython_weakref_simple_1 free_cpython_weakref_simple_4 keep_cpython_inc_5 keep_cpython_inc_3 keep_cpython_inc_2 keep_cpython_weakref_simple_1 free_finalizer_simple_1a free_finalizer_simple_2 free_cpython_tuple_3 free_cpython_tuple_1 free_cpython_tuple_2 keep_cross_simple_1a keep_nocycle_nogc keep_cpython_untracked keep_pypy_self keep_cpython_self free_cross_multi_2c increments: between removed objects counted non-reference between Reference 2n : n a n 7y 6n, 5a, 1n, : y b 8y 5b, 4y, : y y n n d y n n n 0,1n 2,1a 14n, 13a, 12a, 11n, 10n, 9n, 8n, 7n, 6y, 5d, 4n, 3n, 2y, 1y, : i4y : i3y : 1,i2y i1y, : 11y : 10y : 9y : 5c : 12b : 3y : 13c : 12c : 13b : 15y : 14y : 16y : s y/n ts: y/n Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. U) T) keep_cpython_inc_1 keep_cpython_inc_6 i6y : 5,i7y i5y, : ..Verification 4.5. 53 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. eeeueec ecmr nfu niomnso hsmachine: this on environments four in benchmark each execute We illo tterslso h ecmrigpoesaditrrtorfindings. our interpret and process benchmarking the of results the at look will . Benchmarks 5.1 u eut.Freeyeeuinasprt rcs ssatd oaodvraindeto due variation avoid to started, JIT. of is the validity process of the separate behaviour ensure a warmup to execution the repeatedly, every executed 18.04.3 For are Ubuntu results. benchmarks an our cores All on 1.80GHz Dual-Channel-RAM system. four DDR3 a operating with 16GB on LTS processor threading, executed CPU hyper are i7-8550U enabled benchmarks Core(TM) and The Intel(R) objects. an counted execute with reference heavy We machine make collected, implemented times. which garbage our pause benchmarks, of and of application usage time real-world performance execution and in usage, microbenchmarks memory differences artificial to the regards show with going algorithms are benchmarks Our we Then, first. given be and will algorithms benchmarks our the of of of the characteristics description Most compare the a to chapters. test so benchmarks, previous to implementations, several the created their of in specifically results described were the we benchmarks at that the look algorithms, a the take of will implementations we chapter, this In • • • • ii fa qiaeto ,0 eeec one bet o rs-epmarking cross-heap for objects counted reference Inc50k 5,000 of equivalent an of limit Inc5k Base Mark h xsigipeetto n yl eeto frfrnecutdobjects) counted reference of detection cycle (no implementation existing the : h mlmnaino h eiiceetlalgorithm semi-incremental the of implementation the : h mlmnaino h ul-nrmna loih,wt nincremental an with algorithm, fully-incremental the of implementation the : aea n5,wt niceetllmto 50,000 of limit incremental an with Inc5k, as same : Results CHAPTER 55 5 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 56 .Results 5. 1B.Ti ala hudhl s omk h ieecsi eoyconsumption memory in differences the make to us, help should payload This (1KB). ewl xct ahbnhaki eea ainsadwt ieetpretgso live of percentages different with and variants several in benchmark each execute will We h bet nbt ep oss ffiefilst tr pt v eeecsado one of and references five to up store to fields five of consist heaps both on objects The iha qa ubro ieadda bet,b epn 0 fteojcsalive. objects the of 50% keeping by objects, dead and live of number equal an with aubedt,aatfo eeecst te objects. other to references from apart data, valuable ipeCycle Simple Liveliness eew locet ylsuiglne it flnt ,btwt ubro cross- of number Y with but X, cycles. length of of number lists Z linked create using We cycles references. create also we Here objects collected non-garbage variants: Z The keep three heap. they in counted and benchmark reference Y this the length execute within We of cycles lists alive. of linked number of X consist create cycles we benchmark this In benchmarks the 100% execute keep additionally we we visible, view, more balanced 0% detection more keep cycle a we see For of To be, overhead alive. possibly objects. the objects can make root the To consumption the of memory alive. of to one objects to regards of the graphs with count of object reference benefits constructed requested the the of the incrementing big percentage keep artificially how requested will by we the or adding benchmark, list by the a alive, on objects Depending of 100%). ratio and 50% (0%, objects store also structures memory most reality in size that uniform fact, of the string reflect random should a and to clear initialized more be will which values, some store to field results. our also influence will might We which detection. layout cpyext, cycle with Object of issues impact practical the some see of at to most look able detect brief be cannot a will which take implementation, we references. current cycles, cross the etc.) constructed non-cyclic to the large, with results very cycles the (many, and comparing creating cycles, By several, include cross-heap in cycles, scenarios implementations counted Those our reference of scenarios. peformance created the measure specially we microbenchmarks our In Microbenchmarks 5.1.1 rs-epCycle Cross-Heap 3 2 1 1 2 nongc size size count cross eyln it X=2 = (X lists long very : eyln it X=1,Y=2 = Y 10, = (X lists long very : o fcosrfrne X=1,Y=2 = Y 10, = (X cross-references of lot a : o fcce X=2 = (X cycles of lot a : o fnngraecletdojcs( 0 0 2 = Z 10, = Y 10, = (X objects collected non-garbage of lot a : 14 14 0 10) = Z 10, = Y , 0 10) = Z 10, = Y , 14 10) = Z , 14 10) = Z , 14 ) Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. hl hr r eea te pnsuc plctosadlbaisipeetdas implemented libraries and applications source open other several are there While benchmarks. our for GTK of top on created applications, UI using on decided We hc neatwt abg olce,rfrnecutdojcsvatecyx module. cpyext the via objects counted reference collected, garbage with interact which yteeitn aksepipeetto.W ilwtesti su ihrsetto respect with issue processed this been witness 5.5. already have will Section We not in likely would implementation. tuples most or mark-sweep would would existing we with they the differently, issues by because implemented overhead, similar be different face would a We they reference see If containing method). tuples. lists traverse and counted special are dictionaries reference a they implementing cpyext non non (in items, to a items counted proxies to counted proxies as reference implemented as implemented to be or proxies currently items, might implemenation containing counted the list lists reference on counted counted containing depends reference reference objects heavily example, overhead counted For the reference as as classes. scenarios, thesis, those internal this in collections. those even of detection and of focus cycle tuples the of like overhead not classes the is most measure internal this to are In able use are objects. they we counted though kind Even reference this collected of garbage objects of only processing, use the data make scientific cases, for actually library few NumPy very popular only the like interaction. modules, extension user CPython automate benchmarks, to both these used create compare is To to [ldt] detection. order Project cycle Testing in of Desktop applications overhead these the the Python measure use Music, source to can Gnome open and we like of algorithms PyChess, PyGObject, lot using or a also Tweaks interface are can user Gnome there It their As components. implement module. UI which [ extension its applications, PyGObject CPython implement the a to via as system applications, implemented object Python an for as used GObject be uses and C in [ GTK applications, suitable need we benchmarks, application meaningful perform to order In objects. counted reference Z of number an X objects th create counted cycle we non-reference counted directions, Y (reference both with cycle For non-rc graphs counted to resides alive). object rc (non-reference cycle objects and the rc counted alive) heap non-reference to keep objects which keeps non-rc counted they on reference but Depending directions: keeps heap, two alive. that the between heap of the distinguish side of we one side on, on other purely the reside on cycles objects the microbenchmark, this In rs-epReferences Cross-Heap .. plcto Benchmarks Application 5.1.2 3 1 2 3 count count nonrc rc o fr bet X=1,Y=1,Z=2 = Z 10, = Y 10, = (X objects rc of lot a : samlipafr oli o raiggahclue nefcs ti written is It interfaces. user graphical creating for toolkit multi-platform a is ] o fcce X=1,Y=1,Z=2 = Z 10, = Y 10, = (X cycles of lot a : o fgah X=2 = (X graphs of lot a : o fnnr bet X=1,Y=2 = Y 10, = (X objects non-rc of lot a : 14 0 10) = Z 10, = Y , 14 14 14 ) 10) = Z , ) pygb agaebnig hc is which binding, language ] ..Benchmarks 5.1. at 57 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 58 Results 5. tssrt)frorbnhak,wihw ilrnfraot1 eod.I animates It seconds. 10 about for run will we which benchmarks, our for (testsprite) eg NumPy). (e.g. nm ui,i ffr oeavne ofiuainotos hc a ecngrdby configured be can which options, configuration advanced more offers it Music, Gnome [ Libet Quod the Libet off Quod bounce and screen the area. across animated diagonally the move scenarios which of simple sprites, borders rather of one number use fixed We a features. its showcase to scenarios, demo built-in [ PyGame launched be will chess. which of PyGame games benchmark, several our simulate for to chess tutorial execution, about this one user of during the fraction times teach several a to tutorial use interactive We an moves. like features, additional several offers [ PyChess for used commit git the PyChess of hash these The of fonts. several system 11d9d1db. change the is and for for benchmark through themes factor this browse visual scaling we between the benchmark, switch like this to settings, In used be icons. can or it applications example, For environments. desktop [ Tweaks Gnome used commit Tweaks git Gnome the of hash from The 45612fa. songs songs. is some between benchmark different playing switches this the starts and for between then them switches It pauses and Playlists). album, launches library the Songs, this benchmark the as Artist, The in (Albums, music, music. present views stored stream album main locally to one play trying with only when application we crashes the benchmark, PyPy of our version In tested internet. the over music [ [ Music Gnome created even are cycles that low relatively are going chances are of the objects, such as scope counted use detection, reference the only collected cycle that garbage outside need to applications to is comes few compare it probably this when to standpoint, classes, but have practical predefined also classes, a From would internal we thesis. those that this means of this implementations analysis, different performance overall an For nm Music Gnome gnoa .I a eue olse olclysoe ui,bti a lob sdt stream to used be also can it but music, stored locally to listen to used be can It ]. pyga pyca quo sa D odvlpmliei plctos iegms toesseveral offers It games. like applications, multimedia develop to SDK an is ] sacesapiain hr sr a lyaanttecmue.It computer. the against play can users where application, chess a is ] gnob samscpaigapiain iia oGoeMsc ncnrs to contrast In Music. Gnome to similar application, playing music a is ] gnoc samscpae,dvlpdfrteGoedstpenvironment desktop Gnome the for developed player, music a is ] sagahclitraet oiyavne etnso nm 3 Gnome of settings advanced modify to interface graphical a is ] Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. lhuhteei oevrnet htotefrsalohrevrnet,w will we environments, other all outperforms that environment, no is there Although memory lower a have to and faster be to environment Mark the expect would we Anyway, ene oke nmn htteeaeatfia ecmrs n ti ihyulkl to unlikely highly is it and benchmarks, artifical are these that mind in keep to need we none oeo hs iutosi rcie n ecmr si oewyseil as special, way some in is benchmark One practice. in Still, situations improvements. these future their of for and some point algorithms encounter reference our a of as weaknesses useful use several most can out the we point be which results might implementations, the implementation reasons. Also, which various our on practice. for tendencies of in results, and see, expected executions differences will the clear the We from see results. differ during results expected taken actual our measurements the to cases, them the some compare at in and that 5.4) look - a 5.1 (Tables take benchmarks will we Now Microbenchmarks snapshot. the 5.3 synchronizing and performance taking gain of actually costs could the we the outweight of process, even layout to might and memory increase efficient that snapshot different also more benefits, the would the be which to might environments, increments, due which incremental However, between snapshot, our memory consumption. in in memory stay average because Also, to the time need and snapshot. set space a working save the of might we lack it as the increment, environments, of single incremental overhead. one the synchronization than in incremental additional the consumption processed the if considering is Also, effect, graph opposite scenarios. whole the all end the exactly for incre- the and in case our at high result the of graph too be beginning object not is the actual might at our limit this snapshot with collection, a synchronize take our to have to of have environments. we we incremental which the that collection, for fact mental times the environ- pause to (incremental) lower due Inc5k/Inc50k However, expect the stay obviously increment. and objects would (non-incremental) single of we Mark one ments, lot the in a compare all case we them in pause If process the highest, to that the cycles. have except free be would predictions, and probably we precise detect will as any environment to alive, expect have make Mark still not cannot the would would we of we we times, times case, as pause this fastest, of in the terms even increasing be In But an to die. if environment structures consuption, Base point cyclic memory the some in highest at the objects would have of we to number environment introduce, Depending implementations Base other the memory). the (free expect and overhead productive time memory other anything processing the all do of on never case terms would this offer in they In to overhead because environment consumption. additional memory, Base memory introduce the least only the expect would with generally environments would times, we execution alive, fastest stay the objects all case In Results Expected Gnome in 5.2 as steps settings. similar these perform of we some benchmark, through our browse In also dialog. but separate Music, a in user the ..Epce Results Expected 5.2. 59 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 60 Results 5. vrg n aiu eoycnupinaetems motn ausw measure we values important most the are consumption memory maximum and Average h ffcieeso u loihscnb esrd ycetn o fojcs hc die which objects, of lot a creating by measured, be can algorithms our of effectiveness The fe eaieysottm.I the In time. short relatively a after etcleto,wihlast infiatdces ntenme fmjrcollections, major of number the the in delays thus decrease also significant and It a structures to consumption. cyclic increases and leads memory the This smaller which maximum of getting collection, cycle. and deletion slowly next collection average the only the a and is increases complete creation set greatly to the working limit needed between incremental the is timespan the case, increments the As this of are increment). number for (which each high low increments of a two too beginning between be the added at to are cycle, incremental set seems objects collection working the a border the for during new to variants, increasing of escalate added two is lot to other set a the seem working quite for the collection because variants, also major raw all but variant, the In per at cross increments implementations. look the we of for If number especially benchmarks. that, the Cycles see difference. Cross can significant the we in a data, found not be is Mark can this to differences but compared Significant benchmarks, Inc50k The nonrc and Mark. Reference Inc5k to Cross for compared lower the Inc50k slightly in and is Inc5k consumption for memory higher average slightly are Inc50k consumption Base. vs. memory to Inc5k compared usage, vs. on memory Depending Mark average objects. lower counted 95% reference to on any up memory free measure our more to we in uses unable benchmark, environment freed is the Base be cyclic algorithm the also any Reference the benchmark can free Cross as this objects to average, the in counted unable in non-reference Still, are found the environment. we are as Base (as rule benchmarks, alive this rc be to to would about exceptions non-rc is objects notable consumed our only memory of The the 100% structures). Base if in as whereas same environments, the Inc50k and Inc5k Rest Mark, consideration. vs. this Base in important equally are consumption, memory maximum and mean Effectiveness capture to by important also (especially is collections it our implementations), during incremental memory overhead. freeing the by some this memory, in allocate save snapshot to to a is need goal creating we primary As our as objects. benchmarks, cyclic our of execution the during Memory 5.3.1 this noted. exclude otherwise will unless We this considerations, rc). way our to the of non-rc to most nonrc, due for measurements, Reference: benchmark most (Cross for constructed differences is significant benchmark no actually are there ftecetdcci tutrsde ietyatrte aebe ul osrce.Both, constructed. fully been have they after directly die, structures cyclic created the of sepce,w r bet relreaonso eoyi our in memory of amounts large free to able are we expected, As ihol e xetos h vrg n maximum and average the exceptions, few only With %alive 0% oun,w e h esrmnsi aeall case in measurements the see we columns, Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Table 5.1: Benchmark Results - Simple Cycle 214

0% alive 50% alive 100% alive Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k count 263 97 99 98 263 208 208 204 262 312 309 305 size 132 97 101 100 135 122 123 125 132 168 167 166

Mean nongc 134 101 101 101 139 119 115 112 145 156 151 161 ∅ 177 98 100 100 179 150 148 147 180 212 209 211 count 461 109 112 112 462 297 300 300 457 466 465 464 size 244 132 136 135 246 191 197 197 243 253 262 260 Memory (MB) Max nongc 244 132 136 136 246 178 176 178 253 248 251 256 ∅ 316 124 128 128 318 222 224 225 317 322 326 327 count 0.48 0.34 0.35 0.35 0.48 1.47 1.27 1.24 0.47 2.05 1.73 1.64 size 0.14 0.17 0.19 0.19 0.14 0.28 0.28 0.28 0.14 0.44 0.42 0.42

GC nongc 0.14 0.16 0.16 0.16 0.14 0.22 0.20 0.20 0.14 0.34 0.28 0.29 ∅ 0.25 0.22 0.23 0.23 0.25 0.66 0.58 0.57 0.25 0.94 0.81 0.78 count 0.74 0.52 0.52 0.53 0.75 1.72 1.53 1.51 0.74 2.33 2.03 1.95 Time (s) size 0.26 0.26 0.27 0.27 0.25 0.38 0.38 0.39 0.26 0.56 0.54 0.55

Total nongc 0.25 0.24 0.24 0.24 0.25 0.32 0.30 0.30 0.25 0.46 0.41 0.42 ∅ 0.42 0.34 0.35 0.35 0.42 0.81 0.74 0.73 0.42 1.12 0.99 0.97 count 8.37 5.50 3.49 3.53 8.39 24.25 4.46 11.33 8.32 35.92 4.25 14.01 size 5.47 6.31 2.93 4.27 5.45 11.27 2.23 6.09 5.51 17.48 2.00 7.70

Mean nongc 5.46 5.78 3.52 3.52 5.46 8.86 4.92 5.00 5.37 12.94 6.61 6.72 ∅ 6.43 5.86 3.31 3.77 6.43 14.79 3.87 7.47 6.40 22.11 4.29 9.48 count 69.0 22.1 11.9 12.4 69.3 234.0 71.7 73.6 68.1 397.4 112.4 106.0 Microbenchmarks 5.3. size 31.8 28.1 16.6 16.3 32.1 87.8 34.0 34.7 32.1 140.2 51.5 52.0 Pauses (ms)

Max nongc 32.1 24.9 15.5 15.3 32.1 58.9 31.9 31.6 31.5 102.2 33.2 34.2 ∅ 44.3 25.0 14.7 14.6 44.5 126.9 45.8 46.6 43.9 213.3 65.7 64.1 61 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

62 Results 5.

2. 765598558.2 539.8 3716.5 729.7 374.9 385.8 1932.3 730.6 128.5 160.8 181.2 736.5 ∅

4316.2 832.3 394.6 374.9 2273.4 830.7 22.9 23.9 13.5 853.6 count 618.3 566.9 Max

ass(ms) Pauses 4155.0 848.8 412.5 445.7 2287.9 855.1 277.3 287.8 334.7 841.0 cross 537.7 564.5

2678.5 508.2 317.6 336.7 1235.5 506.0 85.5 170.6 195.3 514.9 size 518.7 487.9

70 90 .68.77 3.96 49.08 17.07 8.54 4.55 37.02 17.51 4.60 3.76 13.73 18.08 ∅

13.38 6.74 51.61 17.91 13.54 7.48 41.11 18.54 4.20 4.51 4.90 19.93 count Mean

60.72 20.30 0.10 0.10 45.27 20.31 0.09 0.10 22.82 20.05 cross 0.11 0.12

34.91 13.00 11.97 6.06 24.68 13.67 9.50 6.67 13.49 14.24 size 12.80 5.04

.61.51.713.34 12.97 15.65 6.36 9.09 9.80 11.42 6.33 6.57 6.81 7.43 6.28 ∅

15.17 14.04 17.98 7.02 8.91 10.12 12.44 6.97 4.70 5.07 4.07 6.92 count Total

6.86 8.59 9.19 10.96 6.80 cross 14.16 14.54 17.38 6.87 10.86 11.58 13.21

ie(s) Time

5.16 6.41 6.18 7.26 5.13 size 10.68 10.33 11.57 5.20 7.49 7.71 8.62

.099 .07.52 8.00 9.93 4.70 5.25 5.37 6.16 4.66 .31.71.611.49 10.96 13.97 4.73 ∅

5.23 3.47 3.74 2.81 5.19 count 13.24 11.89 16.17 5.28 7.35 8.22 10.82

GC

5.14 6.88 7.37 9.50 5.07 cross 12.04 12.29 15.61 5.14 8.95 9.54 11.61

3.75 5.39 5.00 6.17 3.73 size 9.19 8.69 10.12 3.78 6.27 6.24 7.36

1825 102809 3140 2554 4158 1069 1222 475 4154 1541 444350 4404 4211 4155 ∅

4313 235 237 115 4303 count 4450 4554 4364 4305 2752 3332

2674 Max

eoy(MB) Memory

4290 2282 2285 674 4282 cross 4545 4545 4346 4282 3209 3210 2619

3870 690 1143 637 3876 size 4056 4113 3924 3878 2465 2879 2368

0019 671512 1657 1391 2080 702 765 419 2073 0525 202280 2280 2359 2085 ∅

2226 219 219 112 2213 count 2367 2354 2561 2229 1464 1691 1527 Mean

2215 1284 1278 604 2204 cross 2310 2317 2537 2210 1752 1743 1430

1798 603 798 542 1800 size 2164 2169 1978 1816 1320 1536 1217

Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark

%alive 0% 0%alive 100% alive 50%

al .:BnhakRsls-CosCce 2 Cycles Cross - Results Benchmark 5.2: Table 14 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Table 5.3: Benchmark Results - Cross Reference 214 (rc to non-rc)

0% alive 50% alive 100% alive Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k count 256 93 108 108 250 189 216 192 255 303 263 282 nonrc 133 92 89 90 132 111 102 96 133 135 138 140

Mean rc 134 95 100 98 139 123 121 127 137 165 171 168 ∅ 174 93 99 99 174 141 146 138 175 201 191 197 count 487 110 132 133 483 310 382 327 485 495 501 510 nonrc 248 151 167 166 247 197 186 183 247 247 253 253 Memory (MB) Max rc 244 129 135 136 247 191 197 197 247 251 263 261 ∅ 326 130 145 145 325 232 255 236 326 331 339 341 count 0.46 0.24 0.32 0.30 0.46 0.58 0.49 0.47 0.46 1.02 0.57 0.73 nonrc 0.23 0.13 0.14 0.13 0.23 0.18 0.17 0.15 0.24 0.26 0.28 0.26

GC rc 0.15 0.17 0.20 0.17 0.15 0.28 0.28 0.26 0.15 0.44 0.41 0.39 ∅ 0.28 0.18 0.22 0.20 0.28 0.35 0.31 0.29 0.28 0.57 0.42 0.46 count 0.65 0.38 0.46 0.43 0.65 0.75 0.67 0.64 0.65 1.22 0.77 0.92 Time (s) nonrc 0.27 0.17 0.18 0.16 0.27 0.22 0.21 0.19 0.27 0.30 0.32 0.29

Total rc 0.27 0.26 0.29 0.25 0.27 0.38 0.39 0.35 0.27 0.57 0.52 0.51 ∅ 0.40 0.27 0.31 0.28 0.40 0.45 0.42 0.39 0.40 0.69 0.54 0.57 count 9.74 4.54 4.31 4.02 9.74 13.49 5.20 7.19 9.74 21.69 5.12 7.80 nonrc 4.79 4.14 3.15 2.87 4.79 4.97 3.48 3.13 4.81 5.32 4.12 3.75

Mean rc 5.74 6.27 3.10 3.88 5.81 11.18 2.24 5.55 5.81 17.73 1.95 7.13 ∅ 6.76 4.98 3.52 3.59 6.78 9.88 3.64 5.29 6.79 14.91 3.73 6.23 count 74.8 10.6 9.7 9.2 74.1 124.0 38.0 32.9 75.6 296.1 51.7 58.0 Microbenchmarks 5.3. nonrc 20.1 3.8 3.6 3.5 20.4 17.5 8.2 7.3 20.2 31.8 31.2 29.4 Pauses (ms)

Max rc 33.4 28.0 17.7 16.0 33.6 85.6 33.7 32.5 33.4 140.8 49.6 50.8 ∅ 42.7 14.2 10.3 9.6 42.7 75.7 26.6 24.3 43.1 156.2 44.2 46.1 63 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

64 Results 5.

421593. 34.5 36.9 105.9 24.2 25.7 24.3 63.1 24.0 12.4 12.8 21.2 27.9 ∅

52.0 136.2 32.8 32.9 34.8 88.2 33.4 22.4 22.0 42.3 32.9 rc 50.4 Max

ass(ms) Pauses 3.7 4.0 3.8 3.6 3.8 4.0 3.8 3.4 3.6 3.8 4.2 nonrc 3.5

55.0 177.4 36.0 40.7 34.4 97.2 34.9 11.5 12.7 17.5 46.8 count 49.7

.91.732 5.63 3.24 10.57 5.09 5.22 3.28 8.89 5.34 3.70 3.08 5.81 5.47 ∅

7.13 2.02 17.34 5.85 6.27 2.28 13.05 5.76 5.15 2.55 8.79 5.80 rc Mean

3.11 3.47 3.47 2.85 3.10 4.11 4.06 2.87 3.12 4.12 4.10 nonrc 2.99

4.58 10.91 5.95 6.54 4.47 9.52 6.21 3.08 3.57 4.54 6.50 count 6.78

.906 .30.53 0.53 0.60 0.39 0.39 0.41 0.41 0.31 0.26 0.28 0.26 0.28 ∅

0.51 0.55 0.56 0.27 0.41 0.44 0.43 0.27 0.32 0.34 0.32 0.27 rc Total

0.20 0.16 0.18 0.17 0.17 nonrc 0.25 0.26 0.27 0.27 0.19 0.20 0.20

ie(s) Time

0.47 0.29 0.34 0.29 0.41 count 0.84 0.78 0.99 0.63 0.57 0.58 0.60

.003 .90.28 0.29 0.30 0.20 0.18 0.19 0.17 0.17 .704 .00.41 0.40 0.48 0.27 ∅

0.15 0.23 0.25 0.23 0.15 rc 0.39 0.42 0.43 0.15 0.31 0.33 0.32

GC

0.16 0.13 0.14 0.13 0.13 nonrc 0.21 0.22 0.23 0.23 0.15 0.17 0.16

0.27 0.17 0.19 0.16 0.21 count 0.64 0.57 0.78 0.42 0.39 0.37 0.41

7 2 4 234 243 224 273 145 146 136 225 2 2 3 334 339 329 327 ∅

247 155 154 148 249 rc 260 261 256 246 197 197

191 Max

eoy(MB) Memory

192 165 169 151 153 nonrc 251 247 248 250 178 184 188

381 114 114 109 272 count 491 508 482 484 325 347 294

4 3 3 136 138 135 143 98 101 99 128 7 9 8 190 187 190 171 ∅

137 119 120 115 140 rc 166 169 168 137 132 133 135 Mean

102 88 91 94 94 nonrc 133 127 131 134 93 97 100

189 88 91 87 151 count 270 265 272 241 181 183 170

Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark

%alive 0% 0%alive 100% alive 50%

al .:BnhakRsls-CosRfrne2 Reference Cross - Results Benchmark 5.4: Table nnr orc) to (non-rc 14 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ouint hspolmwudb ihr etro vnaatv nrmna limits incremental adaptive even or better higher, be would problem this to solution A hc aemr ie stenme fojcssedl nrae,rslsi essamples less in results increases, steadily objects of number the as time, more take which we usage, memory to regards with algorithms our of efficiency the of sense a get To incremental higher the variant, size the in see can we As references. cross to respect with some) (or all if happens also This benchmarks. other the of any for see don’t we which a esr h diinloeha foripeettos hscnb oeby done be can This implementations. our of overhead additional the measure can h rbblt facleto ih tteedo u ecmr srltvl o.The low. the relatively to is that due benchmark and likely our highest, most of the end is is the This memory at consumed right Mark. the collection and benchmark, a our Base of of probability for end the same 100% the the with at consumption about that memory fact, is maximum objects the live that benchmark, of see actual consumption. we the memory microbenchmarks, on average most lower Depending For or outweight set. higher to working a seems the in this and results benchmarks, snapshot this some the In of collections high. effects late is the in consumption especially memory which, terms when 5.3.2), in taken Mark Subsection lower than see The faster details, (surprisingly) Mark. (for Cycles: is to time Cross Inc5k GC compared that pure (e.g. Inc5k fact of benchmarks for the other from higher result in is might is overhead whereas overhead overhead memory Inc5k, memory average and average the Mark the size) in other), same some an the (and with benchmarks about deal Cycle we benchmarks). Simple (as these our references exactly For the cross in cases, for them these set of In working number Mark efficient count). high the more extremely Reference: of a Cross overhead probably count; memory is and the reason cross than lower, Cycles: significantly (Cross is enviroment environment Inc5k the Inc50k of vs. Inc5k vs. overhead Mark the benchmark, percent. the 19 on to Depending 4 Base. about to from compared ranges Inc50k, and Inc5k Mark, Rest by vs. introduced factors, overhead Base of actual lot the a of on indicator depends better collection the a last time be algorithms. our exact to our of the seems overhead time on memory the the depends average of As heavily the indicator it triggered. good of as is a benchmarks, amout collection not maximum our last is The in important, every implementaions benchmarks. in and our our useful of processed of practice be end in to the while need until memory, but alive freed, stay be structures never cyclic will the which In objects, live collection. of lot a creating Efficiency escalation. an such prevent to seems limit usage. memory a average such in see decrease don’t a we even cases, and these usage in memory anyway maximum surviving in objects increase the as large but alive, stay objects 0%alive 100% sepce,w e htteaeaemmr vredi ihrfor higher is overhead memory average the that see we expected, As oun,w a e h eut,i aealo h created the of all case in results, the see can we columns, neetnl,i oecssteaeaemmr overhead memory average the cases some in Interestingly, ..Microbenchmarks 5.3. 65 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 66 .Results 5. hsi rbbybcueo oeecetmmr aot fw euaiyfe unused free runtime. regularily GC we in if benefit layout, the memory efficient than greater more is a runtime of total because in probably benefit is the This that see also we heap, counted reference the the on at detection cycle look additional a the take of we impact the measure To a nysv nttleeuintm,i o fojcsdeqiky hsi refrall for true is we This that quickly. realize die quickly objects we of columns, lot alive a 50% if the time, bechmarks. at execution our look total of short on a save alive take only them we can of if one case, keeping any of them In overhead of the lot so of a is notable. small, though overhead alive, be relatively even the not triggered, benchmarks, are might is that other graphs collection all large, the In the created, so when benefits. are are created performance graphs the currently the than is Reference: higher that that on Cross graphs graph, cross; is, large size, the explanation with keeping Cycles: possible benchmarks Cross all One size; for Cycle: to case rc). (Simple compared the heap equal be counted or to reference higher seems the is This Mark/Inc5k/Inc50k environment. of Base time the total the benchmarks, some In closely, more time total lower with objects. benchmarks total other the the GC variant), at the nongc though look and even we (count that If benchmark fact, cycles Cycle marking lower. of the Simple of is lot is overhead the time a surprising the in case more than higher in even higher are that is is times seems What alive times, it them them. GC But keeping sweeping higher heap. of and expect counted overhead would reference the we the created, as process are surprising, to is need This we lower. if significantly also is time the inspecting by overhead, the total and time Impact collection benchmarks. garbage our consider in we factors way, lead important any even as or In time penalty execution times. performance [ execution the program reducing faster heap executed help to modified the could the of performance but performance application time, in on additional changes up to take lead collection might and detection cycle Generally, Time overall an increments. in two 5.3.2 result between would in which memory, be taking in still still held consuption. might is currently memory we collection is maximum as a snapshot higher benchmarks, that the chances, our case increased this of the In end of the The in because at consumption samples. be memory memory place might our maximum This of higher timing case. a different this have to actually due environments just incremental likely two most are see we differences aev.Rest vs. Base n5ki ut o oe hnfrteBs niomn.I oto hs ae,teGC the cases, these of most In environment. Base the for than lower lot a quite is Inc50k nms ecmrs h oa xcto iefrteMr,Ickand Inc5k Mark, the for time execution total the benchmarks, most In %alive 0% oun rt fewrs ewl aeasprt okat look separate a take will we Afterwards, first. columns 0%alive 100% columns. BCM04 .Pstv effects Positive ]. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 0%alive 100% oeaut h eprloeha forcci abg olcin etk oka the at look take we collection, garbage cyclic our of overhead temporal the evaluate To depending similar, quite generally is environments incremental the of performance The eysmlr eedn ntebnhakoei oeie atrta h other. the than faster sometimes is one benchmark the on depending similar, very 1%,a aede o efr rcn nterfrnecutdha.Poesn the Processing heap. counted reference the on tracing perform not does Base as 215%), .. Pauses 5.3.3 o hscmaio,a h okodsastesm n bet r re nayo the of increased any cause in freed only are will objects environment (no Mark columns same semi-incremental other the the incremental the stays than an As workload suitable in the environments). level more work as somewhat similar its comparison, are a of this columns at most for alive times performs 100% pause already The the (which environment keep manner). Base to is, the environments in incremental as the for goal Our indicator alive an 100% is pauses. this distributed. long as evenly frequent time, quite less pause are beside maximum times pauses the pause short to might extremely the close is times is of that collection time pause lot pause average a garbage average as having incremental the of times, Ideally, why result pause a maximum reason be are main only indicator the good is A low, implemented. times pause Keeping an in the results behave But which environments incremental phase, Both phase. marking benchmarks. the marking all during the in and process of process snapshot to collection end faster faster a overall the be creating at to by snapshot seems overhead snapshot the additional synchronizing introduce by they in especially though e.g. Inc50k even (unlike vs. faster, heap Inc5k the vs. on Mark moved are objects memory no the and improve [BCM04]). survive to collectors unable mark-compact objects is all implementations as other the layout, in heap counted reference Rest vs. Base environment. Base the to compared other. the Overhead than faster significantly. slightly not sometimes but is fastest, for one the benchmarks, benchmark is Reference the environment Cross on Inc50k the the In variants Mark. rc time to the Cross GC compared the and the the lower for nonrc thus of are lower the 5.3.1), variants time is Subsection total collections cross in the major and noted and of size already number the (as the implementation variants, found: incremental these be In can benchmark. exceptions Cycles semi-incremental notable the Two than slower slightly one. generally is Inc50k implementation vs. fully-incremental Inc5k vs. Mark oun.W ol xeta vredi l ainso u benchmarks, our of variants all in overhead an expect would We columns. sepce,alohrevrnet r lwrta ae(yu to up (by Base than slower are environments other all expected, As sepce,det h ycrnzto vred the overhead, synchronization the to due expected, As h nrmna mlmnain r eeal slightly generally are implementations incremental The ..Microbenchmarks 5.3. 67 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 68 Results 5. aot01 s.W loseta h vrg as ieo aei itebthigher bit little a is Base of time pause average the that see also We ms). 0.11 (about for lower are times pause maximum benchmarks), Reference Cross the of variants (all iomn ilntb bet rems edojcsadojcsta r re are freed are that objects and objects dead most free to able be not will vironment ttd vrg as ieaeiflecdb te atr swl lk nrmna limits). incremental (like pause well average as for already factors effect as other same by but the influenced environments), objects see are incremental the We time the keep pause increment. for average to last (especially stated, has the benchmarks always in most Base alive in because free times percent), to 98 unable and is 10 it (between Base to pared Rest vs. the how Base be, environment. therefore Mark will environments the part other to interesting all en- compared most of perform Base The differences environments our big environment. incremental see as Base obviously the algorithms, will to all we compared for so again, same processed the never not is workload the comparison, this In can alive limit objects. 0% 50,000 ’ideal’ and the This 5,000 that benchmarks. between and most in appropriate for somewhere Inc50k found seem and be limits Inc5k probably incremental of the times that pause low average indicates extremely the is have between time we in pause collection, or average Cross major the the per subsections, of increments previous variant the of cross in escalation the witnessed the In already to specifially. to benchmark due (compared one environments benchmark, incremental for Cycles low the in extremely benchmarks and most Base) for low relatively are Times Pause Average the in generally limit. increments are incremental more increments lower are because the there environment, to benchmarks Inc50k due most objects the shorter in changed in and and to than set) (new environment seem working increments Inc5k differences between the Most set to single increments. working added one other increasing are in all the done than by be benchmarks, time caused most to more be in has take Inc50k which to counted synchronization, and seems non-reference Inc5k and increment, the between creation of difference snapshot increment big the last no because the is There in snapshot phase. a marking creating than efficient less references cross of lot increases a still with but benchmarks helps, In Simple collection benchmarks. incremental to most compared The in Mark benchmarks. times for all pause times for maximum pause higher maximum lot The a expect. are would we what quite Times Pause reference Maximum a last algorithm. as the incremental it in our use performed of can is potential we work the implementation), additional show Base the unchanged to of otherwise all the (as of times increment pause average and maximum h odrhv rvosybe l akdi h aticeet hc em obe to seems which increment, last the in marked at all objects been as environment, previously Base have the border to the compared environments, fully-incremental the aiu as ie r infiatylwrfralagrtm com- algorithms all for lower significantly are times pause Maximum fw aealo tteaeaepuetms eseta they that see we times, pause average the at look a take we If eeal,terslscnenn aiu as ie are times pause maximum concerning results the Generally, Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. drcinnnr or) hsi eas nti ain ftebnhak aedoes Base benchmark, the of variant this in because is This rc). to non-rc (direction ecnseteipc fti ffc oeacrtl,i ecmaetetoincremental two the compare we if accurately, more effect this of impact the see can We ernalmcoecmrswt ieetnmeso bet.T civ hs ealways we this, sizes, achieve heap To increased objects. with of well numbers scale different also with implementations microbenchmarks our all of ran we metrics the if check, To marking the of end the at snapshot the synchronizing for needed time the increases which benchmark Reference Cross the of variant rc the is rule this to exception only The hc em ob saaigol nteIckevrnet h aiu as ie of times pause maximum the environment, Inc5k the in only escalating be to seems which niomn,bcuete emt eal ohnl rs eeecsmr efficiently more references Base cross the handle stay outperform to objects to able rc able be anyway, to are die seem environments objects they incremental (non-rc because the alive environment, Still, objects linked anyway). any alive keep to need not cl h igs aibeacrigt h ento ftebnhakvrat.W scale We variants. benchmark the of definition the to according variable biggest the scale n5kevrnet,ol o oevrat h aeevrnetsae etrta the than better and scales Inc5k environment Mark, Base the the in variants all some better environment, always for for Base almost well only the environments, scale equally to Inc50k times about Compared pause well. scale linearily. maximum reasonably implementations almost and still all scale average but that them benchmarks, see of of can to most we lot seem benchmarks, column, a environments in 100% Inc50k environment the and Base In 0% Inc5k the the Mark, than scale in The worse benchmarks linearily) scale in all implementations. almost than runtime, majority all lower total (the in lot and quadratically the columns, a time and where quite GC linearily colums, definitely to between 0% but regards somewhere constant, the With to for environment. close linearily Base and benchmarks the most (very some mean at columns in The and alive is environment) 100% scaling Base the well. the for reasonably linearily to scale quite similar scale to consumptions seem memory maximum all implementations appendix. our the Fortunately in included exponent are the results 2 incrementing The from and starting benchmark. two step, of each base one the by keeping by exponentially, variable this benchmark. Scaling Inc50k the times in pause 5.3.4 than average lower the slightly and expected, pause algorithms as maximum incremental are, the both Inc5k bechmarks, for the other same for all the In about Inc50k. are than times increments, higher of significantly both number are effect, high Inc5k this the Without to due benchmark. but Cycles times, Cross pause maximum the comparable of have variant should size the in algorithms increment). single one in cycles, happen collection to longer per needs overall increments (which to of phase leads number set escalating working maximum the increasing Cross of of the the effect terms as of another in variant collection, probably Inc50k count major is and the This is Inc5k times. exception outperforms are pause notable Mark times only pause where The maximum benchmark, and Inc50k. Cycles average and the Inc5k that for witness lower generally we Inc50k environment, Mark vs. Inc5k vs. Mark environment. Mark the than fw opr h ul-nrmna niomnst the to environments fully-incremental the compare we If n hr h nta au of value initial the where , n ais eedn nthe on depending varies, ..Microbenchmarks 5.3. 69 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 70 .Results 5. ehv led entedffrne foripeettosi pca cnro nthe in scenarios special in implementations our of differences the seen already have We al . umrzsterslso u plcto ecmrs sw ilsei our in see will we As benchmarks. application our of results the summarizes 5.5 Table ecn) hsmasta ut o fojcscudb re n htteoverhead the that and freed be could objects of lot a quite that means This percent). 3 enn httemxmmmmr snteulyes opeitmauefreach for predict/measure to easy environment, equally the not and is the application because memory the careful, execution. maximum on be the depending to have that high, is we quite meaning consumption case, any be memory as In maximum can Music the deviation Base. Gnome benchmarks, where to standard with all compared case, 9%), almost Inc50k special to In for a lower up as percent). slightly (by PyChess 4 higher and to also exception and 2 is an Inc5k about consumption Mark, (by memory of Base maximum consumption to the memory compared average higher higher. the is is benchmarks, Inc50k usage three memory other maximum the than the benchmark, In lower though Libet slightly even is Quod 2%), implementations the about fully-incremental In (by the effort. Base of the usage to worth memory 2 is average all about snapshots the (by and/or in environment collections usage Base the the memory of in maximum than the lower is and detection, average cycle benchmark, with Tweaks environments Gnome the In Memory 5.4.1 test. depending under drawbacks, scenarios. application its realistic the and more on benefits its in has differences implementation/environment every the analysis, at look a take will we Now microbenchmarks. Benchmarks Application 5.4 in were especially we implementations, Finally, fully-incremental reasonable. the benchmark. quite in Cycles be spots Cross to weak the seems some memory but identify The notable, to tracing. is able during snapshot is layout the which even memory of (or better snapshot, overhead compensated seemingly the completely the synchronizing sometimes by is and overcompensated) collection, creating fully-incremental found of the also for overhead we pause needed runtime to However, maximum the compared surprising. and that not implementations, Average out, is fully-incremental which the time. implementation, offer for semi-incremental also processing the lower can total detection significantly cycle of are die, terms memory times objects maximum in of and large gains lot average sufficiently a cycles, performance a reference If if detecting significantly. that by decrease out, freed consumption found are we objects microbenchmarks, of our number ouf analysis the During Summary linear. pause than 5.3.5 average better variants, always some but In worse, slightly constant. bit or stay little linearily times a scale pause scale times average times pause all maximum almost cases, and all better nearly In environment. Mark Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Pauses (ms) Time (s) Memory (MB) al .:BnhakRsls-ApiainBenchmarks Application - Results Benchmark 5.5: Table Max Mean GC Max Mean ∅ ∅ ∅ ∅ ∅ udLibet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome udLibet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome .32046 .920.4927 0.4972 0.4961 0.4302 197.27 198.45 195.32 195.26 179.77 180.09 180.09 178.77 190.15 134.73 237.69 189.64 224.08 179.68 127.52 205.28 174.34 207.02 0.2701 1.0543 0.6316 0.1039 0.0909 02 21 .69.07 9.36 12.15 10.26 10.19 12.49 10.68 Base 683. 2421.5 22.4 31.7 16.8 15.2 24.4 19.9 13.0 11.4 8.79 9.13 189.72 138.88 240.88 183.97 223.12 179.09 130.61 210.58 170.01 210.17 0.2949 1.2734 0.7002 0.1200 0.0922 Mark 13.70 10.84 14.59 11.99 27.1 64.9 31.9 19.3 15.2 9.62 195.89 147.39 238.51 184.70 225.75 175.70 133.17 210.39 170.77 210.43 0.3352 1.2384 0.6911 0.1184 0.1030 Inc5k 10.41 21.9 41.7 17.8 13.4 17.0 9.54 9.75 7.64 9.45 ..ApiainBenchmarks Application 5.4. Inc50k 193.48 147.22 236.25 183.57 225.80 176.46 132.43 209.03 170.26 210.69 0.3084 1.2421 0.6977 0.1140 0.1016 10.08 18.0 41.7 17.6 13.2 17.1 8.59 9.78 7.63 9.27 71 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 72 Results 5. bten9ad2 ecn) fw aeterslsfo u irbnhak noaccount, into microbenchmarks our from results the take we If percent). 24 and 9 (between htw a normicrobenchmarks. our in saw we what .. Pauses 5.4.3 ihrpuetms oprdt h aeevrnet(bu wc shg) nthe In high). as twice (about drastically environment has Base environment the Mark to the compared Libet), In times, Quod environments. pause and and higher (Pygame implementations benchmarks the five between of not differences two significant will are users ideally there collections, Still, major allow during additional they executed the difference. as only any As FPS, is notice animations. the cycles in during influence detecting improvements collections not for recent will existing major code the collector automatic the to garbage disable to due the to up However, to developers add changes will frame. our they single pause GC, as a maximum the especially rendering measured applications users, for the by UI spent Here, present tested noticable time already Pygame. the be to of for definitely up exception enough will add small the times might be with pauses environments, to GC all seem 20 the in still to though themselves 16 even pauses within results, the rendered our delays, at be look should rate we frame frame If single the a Ideally so which render. FPS, 16, to 60 is milliseconds and milliseconds. (FPS) 62.5 50 second most between [ per at be frames take should al. of should fluent et number frame Valente require the one which to for means of According bound most lower delays. keyboard games, accepted interactive smaller for commonly creating much milliseconds for thus framework 150 and a animations below is [ delay interactions it mouse as a for special, Dabrowski notice milliseconds to a 195 According won’t have and which exceeded. users interactions interface, is most user threshold the certain Munson, applications. of a and interactive times once usability, to response on comes high effect it to negative when lead interest, pauses peculiar long of Extremely are times pause Maximum to consistent is This faster. are themselves to collections (according the same that the the means the to is this for compared collections number data), lower of benchmarks, small raw is number a the five time the only GC the As and the of Interestingly, implementation. alive semi-incremental stay three freed. objects in be most can implementations that structures fully-incremental fact cyclic the in Base to objects to due of compared likely times, most GC is increased this have Inc50k and Inc5k tested Mark, the bechmarks, measure for all to negligible In hard probably is is it effect the microbenchmarks, the on the and impact in applications. applications an seen garbage interactive have have for the also we impact time can as this the layout application, is memory the relevant, better of more a the rest is though on What Even depends framework. takes. mostly we automation collection time as UI irrelevant, execution the practically the of is and speed time applications execution interactive total measuring the are benchmarks, application our In Time 5.4.2 DM01 .PGm ssomewhat is PyGame ]. VCF .1 a 1] p. , Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 8%ad8%lwr oprdt h aeevrnet hc en htpuetimes pause that means which environment, Base the to compared lower) 81% and (89% pr rmrte hoeia sus eietfiduigormcoecmrs ealso we microbenchmarks, our using identified we issues, theoretical rather from Apart ecnseteopst ffc nsm te benchmarks. other some in effect opposite the see can we eonzdsm sus htmgtb oerlvn npatc.Hwvr hs susare issues these However, practice. in relevant more be might that issues, some recognized Issues 5.5 moderate. quite but were increased, changes times the pause exceptions, maximum few and very average from and maximumapart times time and pause average GC Generally, incremental maximum consumption, PyChess, detection. memory the cycle In did incremental making Tweaks. times employing Gnome environments, when pause for decreased, maximum incremental choice the the of ideal increased, an kind in implementation time any increase GC using significantly the when though not decreased, Even Tweaks, consumption Gnome detection. memory In consumption cycle garbage memory maximum detection. average cyclic cycle and the incremental employing average employing that of the when saw Libet, We effects Quod test. negative in under and decreased applications positive the identify on could collection we total, In Summary 5.4.4 average and the to than Base due shorter of likely be increment most Base. to last is of seem the increment This which in increments, Mark computations Base. additional for additional to introduce values performs Inc5k/Inc50k compared higher Mark Inc50k, show that and benchmarks fact Inc5k all the for almost values times, lower pause and average However, of interruptions. terms cause In to lower likely significantly less is thus it and that predictable of see and deviation also uniform standard more can the are we at slightly look appendix, are we the times If in pause times Base. maximum to pause the average compared hand, the Inc50k and other Inc5k the for on lower benchmark Pychess Inc5k the for the In higher slightly In only overhead. are some times Inc50k. pause quite and maximum probably add environment, the synchronization Base benchmark, and Tweak the Gnome creation to snapshot compared entirely environments, the almost Inc50k because problem and this Inc5k mitigate the to for interfaces potential provide the and have collections demand, [ on major garbage pause them the to execute in application to are improvements the recent applications However, allow multimedia of which hangups. and case collector, short games the to most even In as sensitive, troublesome, times. extremely the especially pause However, maximum is environment. lower this Mark significantly Pygame, the offers implementation to still extreme. fully-incremental environment compared as the times Base not benchmarks, pause but Libet maximum higher, Quod the also the improves are and times Pygame pause the maximum In the benchmarks, three other pypb .I h nm ui ecmr,w loeprec ihrmxmmpuetimes pause maximum higher experience also we benchmark, Music Gnome the In ]. ..Issues 5.5. 73 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 74 .Results 5. hl h efrac falohrbnhak em osa nacmaal ee,one level, comparable a on stay to seems benchmarks other all of performance the While hni oe ocyx,bttestainsest e vnwre fw lotk cycle take also we if worse, even get to seems situation the but cpyext, to comes it when 5.6. Table hss tl,i hudb osdrd hnapyn h mlmnaini practice. our in of implementation part the as applying problem when this considered, consider be not should did it we Still, issue, of specific thesis. time implementation a execution have an total to be the seems to doubling clearly almost This implementation performance, counting. overall tuple the reference the existing cyclic on the support impact 4, to negative Chapter extended, the be in to noted had slow As quite account. already into are detection Tuples issue: practical relatively a highlights benchmark specific microbenchmarks of set small a created Cuni Antonio thesis. [ this cpyext of for scope the of outside simple.allocate_tuple cpya Time (s) .W a hs ecmrssvrltmsadicue h eut in results the included and times several benchmarks those ran We ]. Total ∅ np.mean getitem onearg((i,)) onearg((X,)) onearg((1,)) onearg(X) onearg(i%2) onearg(i) onearg(1) onearg(None) Foo()[0] len(Foo()) Foo().varargs Foo().onearg(i) Foo().onearg(None) Foo().noargs simple.allocate_tuple simple.allocate_int simple.varargs simple.onearg(i) simple.onearg(None) al .:BnhakRsls-cpyext - Results Benchmark 5.6: Table ecmr.A hsi ahrseicpolmadas seems also and problem specific rather a is this As benchmark. Base .318 .51.75 1.75 1.82 1.23 0.28 0.31 1.43 1.41 0.31 0.25 0.30 0.16 0.47 1.39 0.23 0.22 7.49 1.18 0.49 1.44 0.25 1.49 0.76 4.36 1.68 Mark 14.94 0.27 0.29 1.92 1.85 0.29 0.26 0.32 0.17 0.56 1.86 0.24 0.23 1.28 0.60 1.79 0.27 1.54 0.72 6.88 1.91 Inc5k 14.81 0.27 0.28 1.69 1.67 0.28 0.25 0.30 0.16 0.49 1.69 0.23 0.22 1.27 0.52 1.65 0.25 1.58 0.73 6.49 1.95 Inc50k 14.80 0.28 0.30 1.65 1.64 0.29 0.25 0.31 0.16 0.50 1.69 0.24 0.22 1.26 0.54 1.63 0.25 1.56 0.73 6.47 1.92 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ecudseta aiu as ie mrvdars ital l ecmrs We benchmarks. all virtually across improved times pause maximum that see could we many too case In cycle. collection a during increases steadily set working the where all than better clearly is implementation no that revealed, process benchmarking The dniyacerwne,w eeal ogi oeisgt bu h pcfiso our of specifics the about insights some to gain able to not able were were we we though winner, Even clear scenarios. a tested identify the across implementations, other h pta vredi ut esnbei otcss h s fasaso em obe to seems snapshot a of use performance. the overall As cases, of most terms phase. in in marking in reasonable the beneficial compensated quite during quite be layout is to overhead memory seems improved spatial snapshot the the the by implementation, synchronizing benchmarks fully-incremental and all the creating almost in to for snapshot due needed the increased time generally for the consumption needed memory space the additional though the even that witnessed, implementation, fully-incremental also the to semi-incremental the of be results the also applications. comparing could specific By to times, like limited pause are benefits, maximum they Other lower average, but cycles. or identified, on detecting consumption freed for memory be needed maximum could memory most lower memory additional for cyclic the increased enough compensate consumption applications to memory two that only saw For we applications. with benchmarks, cycles application collection our long In and increments. durin sets of processed working number are increasing high objects ever unusually few to an leads too This increments, two increments. between the implementation, added fully-incremental are the objects They of border increased. limit collection incremental garbage the the for with also needed issue but time an decreased, the reveiled reference though consumption also detecting even memory by did, maximum freed runtime and are total average objects only enough not if cycles, that showed, well. we relatively microbenchmark Also, scale Our performance. to of seem terms implementations in all situations that certain observed in implementations and algorithms Summary 5.6 ..Summary 5.6. g 75 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. edrvdsm eea udlns nwe hc mlmnainsol eue in used be should implementation which when on guidelines, general some derived We nteftr,tecoc fagrtmmgtas eedo ute mrvmnsand section. improvements following further the on to depend us also brings might This algorithm of findings. choice additional the future, the characteristics In performance desired the on Base choice and application. the The structure the either memory performance. of applications, the best still batch on environments the running Inc50k depends offer short environments heavily or most applications Inc5k/Inc50k Inc5k For the server the choice. or cases running best environment most the long in be for but to layout, choice seem memory the the Incorporating running microbenchmarks, on and applications. our long depends interactive Inc5k for of for the choice results implementation, However, best on the fully-incremental impact the be the the times. to for As seem pause environments low difference. Inc50k increased relatively crucial is a of make times cost especially could pause small, the memory be cyclic at to freeing seem comes applications, detection often cycle of account. it benefits into as the taken applications, be optimal running to short for need For and application differ the might of outcomes characteristics the individual application, the actual results, the on Depending practice. Application 6.1 the area. practical how this the discuss, in to work and regards future findings with and interpreted those implementations be the summarize should of now described process application we will benchmarking that We the algorithms of implemented perform. results the how 3 seen Chapter have we in chapter, previous the In Conclusion CHAPTER 77 6 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 78 .Conclusion 6. hl tmgtntb eial npatc,adwiei a lonttega fti thesis, this of goal the not also was it while and practice, in desirable be not might it While okn e forflyiceetlipeetto.Ti sdfiieya ra where area, an definitely is This implementation. fully-incremental our of set working ol aeadee nesadn n ol aemr rfuddcsos nwe to when on decisions, profound more make could and understanding deeper a have would ihdffrn abg olcoso ohsds h ucm spoal icl to difficult probably is outcome The sides. both on collectors garbage different with h xsigipeetto a eipoe,a oeapiain ih ue from suffer might applications some as improved, be can implementation existing the eeec one ytm,ne ob ae noacut hn agaedevelopers language approaches. Then, hybrid such account. in apply into structures taken program object be on non-cyclic to implications of need the reclamation systems, immediate especially offer counted of to case, reference effects able this the are In interesting approaches e.g. have. hybrid be behaviour, they would benefits it which downsides integrations, standpoint, which of scientific and kinds a these from for know collector to entire fully collector. the a garbage redevelop to counted to compared non-reference be fully changes could a radical it or more example, collector to For garbage compared process. counted performs, collection reference approach garbage the overall how the tested, of be differ. also might should optimizations It potential changes of behaviour different level the with the how as see tested as predict, to such be interesting also algorithms, be should would tracing It It different schemes. to collectors. counting relatively applied reference is garbage algorithm be copying core also or the tech- could As mark-compact different approach findings. with our the situations, up similar generic, back thesis. in to this tested implementations, of is be and result This also nologies a should counting. as approach reference separately, presented cyclic investigated of Our of be performance effect should the an and that as issue seen deteriorate an have to obviously we seems Also, classes scenario. internal this the in the behaviour with detrimental issue the concrete very a is there that witnessed, have we benchmarks, our During Work Future 6.2 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. . xml,wyw edsaso ossec hcs...... 29 . . 20 ...... checks . consistency snapshot . need . we 19 why . Example, . . 3.4 . . object collected alive non-garbage object with counted structure 3.3 non-reference Cyclic keeping object collected 3.2 Non-garbage 3.1 bet...... 21 ...... collected non-garbage . dying . by alive kept object object counted non-reference Dead, ito Figures of List 79 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. . ecmr eut pet...... 74 ...... 71 ...... 2 . . Cycle Simple . . - . . Deviation Standard . . - . . Results Benchmark ...... 1 cpyext . - . Results Benchmarks Benchmark Application - 2 Results 5.6 Reference Benchmark Cross - 2 Results 5.5 Reference Benchmark Cross - Results 5.4 Benchmark 5.3 ecmr eut tnadDvain-CosCce 2 Cycles Cross - Deviation Standard - Results Benchmark 3 2 . ecmr eut rs yls2 Cycles Cross - Results Benchmark 5.2 ecmr eut cln rs yls...... 98 97 100 . 99 ...... rc) . . to . . (non-rc . . Reference non-rc) . Cross 96 . to - . . (rc Scaling Reference . - . Cross Results . . - Benchmark Scaling . Cycles - . Cross . Results - Benchmark . . Scaling Cycle 9 - . Simple Results - Benchmark Benchmarks Scaling Application 8 - - Results Deviation Benchmark Standard 7 - Results Benchmark 6 5 4 2 Cycle Simple - Results Benchmark 5.1 ecmr eut tnadDvain-CosRfrne2 Reference Cross - 2 Deviation Reference Standard Cross - - Results Deviation Benchmark Standard - Results Benchmark 14 14 14 14 62 ...... 61 ...... nnr or)...... 64 63 ...... rc) to . (non-rc non-rc) to (rc ito Tables of List 14 14 14 14 93 92 ...... nnr orc) to (non-rc r onon-rc) to (rc 81 95 94 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. ul-nrmna loih 30 . 27 . . 31 . 26 . 32 . . 25 ...... 24 ...... 24 ...... 23 ...... 23 ...... Synchronization ...... Snapshot . . . - . . . Creation . . . Algorithm . . Snapshot . Fully-Incremental . . . . - ...... Algorithm . . Fully-Incremental ...... 10 ...... Algorithm . . 6 Fully-Incremental . . . . Phase . . . . . 9 . - . . Algorithm . . . 5 Semi-Incremental . . Phase . . . . 8 . - . . . Algorithm . 4 Semi-Incremental . . . Phase . . . 7 . - . Algorithm . . 3 Semi-Incremental . Phase . . 6 . - . . Algorithm 2 Semi-Incremental . . Phase 5 . . - Algorithm . 1 Semi-Incremental Phase . 4 - . Algorithm Semi-Incremental . 3 . Algorithm Semi-Incremental 2 1 ito Algorithms of List 83 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. [BR01] [comb] [coma] [Chr84] [Bro85] [BCR04] [Axf90] [AP03] [BDS91] [BCM04] betOine Programming Object-Oriented — Construction ofrneo ucinlpormiglnugsadcmue architecture computer and languages programming Functional on Conference rcieadExperience and Practice Review Evaluation Performance win32/com/the-component-object-model hmsWCrsohr eeec on abg collection. garbage count Reference Christopher. W Thomas 1985. Springer, 273–288. In pages machines. combinator for counting reference Cyclic Brownbridge. R David refer- in collection Heidelberg. Berlin cycle Springer editor, Concurrent Knudsen, Lindskov Rajan. Jørgen In T. systems. V. counted and ence Bacon F. garbage David parallel Mostly Shenker. Scott and Demers, collection. J garbage Alan of theory Boehm, unified Hans-J A Rajan. T. V. and Cheng, collection. Perry Bacon, F. David and collection. Myths garbage McKinley. of S impact performance Kathryn The and Cheng, realities: Perry Blackburn, M pro- Stephen functional for graphs cyclic of counting grams. Reference Axford. H Thomas refer- advanced In with collectors. generations garbage Integrating counting Petrank. ence Erez and Azatchi Hezi ue o aaigrfrnecounts. reference managing 08. rules-for-managing-reference-counts for docs.microsoft.com/en-us/windows/win32/com/ Rules homepage. Com h optrJournal Computer The C IPA Notices SIGPLAN ACM Not. SIGPLAN ae 8–9.Srne,2003. Springer, 185–199. pages , https://docs.microsoft.com/en-us/windows/ 46:0–0,1984. 14(6):503–507, , 91)5–8 coe 2004. October 39(10):50–68, , 35:6–7,1990. 33(5):466–470, , 21:53,2004. 32(1):25–36, , ae 0–3,Bri,Hiebr,2001. Heidelberg, Berlin, 207–235, pages , 66:5–6,1991. 26(6):157–164, , nentoa ofrneo Compiler on Conference International Bibliography cesd 2020-02- Accessed: . cesd 2020-02-08. Accessed: . C SIGMETRICS ACM CO 2001 ECOOP https:// Software: 85 , Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. [CYTW10] [DM01] [gnob] 86 [gnoc] [dota] [csh] [cpyb] [cpya] go]Gnome. [gnoa] [FW79] [FF81] [dotb] [DLM [DLM + + 78] 76] H’1Etne btat nHmnFcosi optn Systems Computing in Factors Human on Abstracts Extended CHI’01 computation 1976. 2010. 10, – 111(1):1 2020-01-14. 2020-01-14. 2001. ACM, 317–318. interop/ microsoft.com/en-us/dotnet/csharp/programming-guide/ garbage_collector/ benchmarks. cpyext-benchmarks Cpyext nm tweaks. Gnome music. Gnome the manage can 1979. counting 8(1):41–45, recursion. Reference mutual Wise. of invironments S David circular and Friedman P Daniel macsyma. vax of Characterization Fateman. J Richard In and Foderaro K John 08. homepage. .net DOT_(graph_description_language) language). description (graph Dot In fast? too milliseconds 100 Is Munson. V Ethan and Dabrowski R in James exercise Scholten, An S. collection: Carel garbage Martin, On-the-fly J. cooperation. Steffens. Alain FM Lamport, Elisabeth Leslie and Dijkstra, W Edsger in Scholten, exercise S an Carel collection: Martin, darbage J On-the-fly In Alain cooeration. Steffens. FM Lamport, Elisabeth Leslie and Dijkstra, W Edsger reference cyclic search. to coarse-grained approach a efficient on An based Ting-Wei. counting Hou and Chin-Yang Lin guide). programming sharp (c Interoperability collector. garbage cpython’s of Design rceig ftefut C ypsu nSmoi n algebraic and Symbolic on symposium ACM fourth the of Proceedings https://www.gnome.org/ cesd 2020-02-02. Accessed: . ae 41,1981. 14–19, pages , omnctoso h ACM the of Communications agaeheacisadinterfaces and hierarchies Language https://dotnet.microsoft.com/ https://wiki.gnome.org/Apps/Tweaks https://wiki.gnome.org/Apps/Music cesd 2020-01-15. Accessed: . cesd 2020-02-06. Accessed: . https://en.wikipedia.org/wiki/ https://devguide.python.org/ https://github.com/antocuni/ cesd 2020-01-15. Accessed: . 11)9695 1978. 21(11):966–975, , nomto rcsigLetters Processing Information cesd 2020-01-30. Accessed: . nomto rcsigLetters Processing Information ae 35.Springer, 43–56. pages , cesd 2020-02- Accessed: . https://docs. Accessed: . Accessed: . pages , , , Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. [JHM11] [num] [MWL90] [Lin92] [LH83] homepage. Jython [ldt] [jyt] [jni] [JL96] [Inc] [HLM09] [HK17] [HK15] project. gtk The [Hay91] [gtk] ofrnepoednso betoine rgamn ytm,languages, systems, programming Object-oriented on proceedings Conference inHnbo:TeAto uoai eoyManagement Memory Automatic of Art The Handbook: tion on Symposium International 10th 2009 (ISPAN), Networks and applications and ai yai eoymanagement memory dynamic matic //developer.xamarin.com/guides/android/advanced_topics/ rcsigLetters Processing 2020-02-11. 1990. 34(1):31–35, garbage_collection/ ar ae.Uigkyojc potns ocletodojcs In objects. old collect to opportunism object key Using Hayes. Barry aalDLn.Cci eeec onigwt aymark-scan. lazy with counting reference Cyclic Lins. D on Rafael based collector garbage objects. real-time of A lifetimes Hewitt. the Carl and Lieberman Henry 01-14. ldtp. Gnu interface. native Java Lins. D Rafael and Jones Richard 2011. edition, Moss. 1st Hall/CRC, Eliot and Hosking, collection. Antony Jones, garbage Richard - Xamarin.android Inc. Xamarin cycle 2009. single-trace IEEE, A In systems. Ma. counting Tien-Yan reference and for collection Lin, Chin-Yang 9,613,073. Hou, Patent US Ting-Wei in 2017. lifetime 4 object April Managing graph, Krishnaswamy. cyclic Raja a and Hillberg 9,053,017. Patent John US Michael in 2015. lifetime 9 object June Managing graph, Krishnaswamy. cyclic Raja a and Hillberg John Michael ue o aaigrfrnecounts. reference managing for Rules Cyclic mark-scan. Lins. local D with Rafael counting and Wachenchauzer, reference Rosita Martínez, D Alejandro Native_Interface https://ldtp.freedesktop.org/wiki/ ae 34,1991. 33–46, pages , https://www.gtk.org/ 44:1–2,1992. 44(4):215–220, , https://www.jython.org/ cesd 2020-02-02. Accessed: . omnctoso h ACM the of Communications cesd 2017-03-31. Accessed: . https://en.wikipedia.org/wiki/Java_ abg olcin loihsfrauto- for algorithms collection: Garbage ie,1996. Wiley, . https://numpy.org/ nomto rcsigLetters Processing Information evsv ytm,Algorithms, Systems, Pervasive cesd 2020-01-14. Accessed: . cesd 2020-02-08. Accessed: . 66:1–2,1983. 26(6):419–429, , h abg Collec- Garbage The cesd 2020- Accessed: . hpa & Chapman . ae 40–45. pages , Information Accessed: . https: 87 , Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. [pyga] [PvEP88] [SBYM13] [Ung84] [quo] [pep] 88 [Sal87] [Ric16] [Ric14] homepage. Python homepage. Pypy [pyt] [pypc] [pypa] Pychess. [pycb] [pyca] [pypb] [pygb] eeec onigagrtmadisproof its and algorithm counting reference IPA Notices SIGPLAN 15. cesd 2020-02-08. Accessed: index.html peps/pep-0442/ e 4 aeojc finalization. object safe – 442 Pep ai na.Gnrto cvnig o-irpiehg performance high algorithm. non-disruptive reclamation A storage scavenging: Generation immix. Ungar. counting David S reference Kathryn with and gloves Yang, the Xi off Taking Blackburn, Michael counting McKinley. Stephen reference Shahriyar, two Rifat of analysis and Implementation algorithms. Salkild. D Jon and mark/sweep bridge to gc. jyni-how counting in reference collection Garbage Richthofer. Stefan jython. in arXiv:1404.6390 cpython-extensions preprint native Jyni-using Richthofer. Stefan 2020-01-15. cessed: libet. Quod 01-15. systems. 2019/01/pypy-for-low-latency-systems.html low-latency for Pypy pypy. com/2013/10/incremental-garbage-collector-in-pypy.html in collector garbage Incremental 2020-01-14. cessed: Pygobject. Pygame. manual. reference api Python/c 1988. , . . . Faculty Models, Computational and Science Plasmeijer. puter Jacobus Marinus and Eekelen, van MCJD Pepels, EJH http://pychess.org/about/ https://www.pygame.org/wiki/about https://pygobject.readthedocs.io/en/latest/ https://quodlibet.readthedocs.io/en/latest/ atrstei,Uiest olg,London College, University thesis, Master’s cesd 2020-02-02. Accessed: . http://pypy.org/ 81)9–1,2013. 48(10):93–110, , cesd 2020-01-22. Accessed: . https://www.python.org/ ri rpitarXiv:1607.00825 preprint arXiv 2014. , https://docs.python.org/3/c-api/ C ipa notices Sigplan ACM https://morepypy.blogspot.com/ https://www.python.org/dev/ cesd 2020-02-08. Accessed: . https://morepypy.blogspot. eateto hoeia Com- Theoretical of Department . cesd 2020-01-14. Accessed: . cesd 2020-02-08. Accessed: . 95:5–6,1984. 19(5):157–167, , cesd 2020-01- Accessed: . 2016. , 1987. , cesd 2020- Accessed: . cyclic A arXiv ACM Ac- . Ac- . . Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. [VCF] USVLNE UACNI n RN EJ.Ra iegame time games. Real computer single-player FEIJÓ. for BRUNO models and loop CONCI, AURA VALENTE, LUIS 89 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. h eoe ausaetefitdepnn fa xoeta rwhfnto,wihwas which function, growth exponential an of exponent fitted the are values denoted The the increasing by behaviour, scaling their on tested been also have microbenchmarks The typically is It parameter. each for runs all over calculated was in deviation described standard as The process, benchmarking the of results aggregated additional, the are These udaial n au fzr en,ta h loih rbbyhsaconstant a scales has probably probably algorithm algorithm the the that that means, algorithm zero means, the of two that runtime. value of means, a value one and of a quadratically value linearily, A scales method. probably curve_fit scipy’s using calculated below: interval given The is chapter. and benchmarking differs the variant in and described benchmark as each variable, for respective the of power is benchmarks application for deviation The data. much benchmarks. higher. some too generally for been except have low, would rather this as included, not are results raw The 5. Chapter Results Benchmark Additional • • • ipeCycle Simple rs Cycles Cross rs eeec bt directions) (both Reference Cross – – – – – – – – – on:2 count: ie 2 size: og:2 nongc: on:2 count: ie 2 size: rs:2 cross: on:2 count: c 2 rc: 2 nonrc: 8 8 5 2 - 5 2 - 2 - 7 5 8 10 8 17 2 - 2 - 2 - 2 - 2 - 17 14 2 - 14 16 14 17 17 19 Appendix 91 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

92

. . . 1.1 1.3 6.8 0.8 1.8 0.9 2.8 1.4 0.5 0.5 0.4 1.0 ∅

0.8 1.9 0.7 0.7 1.3 0.7 1.7 0.4 0.3 0.6 1.0 nongc 0.4 Max

ass(ms) Pauses 0.9 9.3 0.9 0.4 0.6 1.4 1.1 0.7 0.7 0.5 0.8 size 0.8

2.2 9.3 0.8 4.3 0.8 6.3 1.5 0.5 0.3 0.2 1.1 count 2.1

.703 .70.07 0.07 0.37 0.07 0.07 0.05 0.22 0.14 0.03 0.05 0.05 0.08 ∅

0.04 0.09 0.17 0.06 0.09 0.05 0.18 0.10 0.02 0.07 0.06 0.06 nongc Mean

0.02 0.47 0.06 0.06 0.03 0.20 0.18 0.04 0.06 0.05 0.12 size 0.11

0.11 0.48 0.08 0.07 0.06 0.28 0.13 0.03 0.04 0.03 0.08 count 0.05

.000 .20.01 0.02 0.02 0.00 0.00 0.01 0.01 0.01 0.00 0.01 0.00 0.00 ∅

0.00 0.00 0.01 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 nongc Total

0.01 0.00 0.01 0.00 0.00 size 0.01 0.01 0.01 0.00 0.00 0.00 0.01

ie(s) Time

0.01 0.00 0.01 0.00 0.01 count 0.00 0.05 0.03 0.01 0.01 0.02 0.02

.000 .10.00 0.01 0.01 0.00 0.00 0.00 0.00 0.00 .000 .20.00 0.02 0.01 0.00 ∅

0.00 0.00 0.00 0.00 0.00 nongc 0.00 0.00 0.00 0.00 0.00 0.00 0.00

GC

0.00 0.00 0.00 0.00 0.00 size 0.01 0.00 0.01 0.00 0.00 0.00 0.01

0.01 0.00 0.00 0.00 0.00 count 0.01 0.04 0.03 0.00 0.01 0.02 0.02

2 0 2 7 0 1 1 5 1 2 6 4 ∅

4 0 0 0 2 nongc 4 0 0 4 5 0

5 Max

eoy(MB) Memory

6 1 2 2 2 size 0 3 4 1 0 0 0

11 0 0 0 10 count 0 3 13 9 0 0 0

4 3 2 5 2 0 2 3 2 2 2 2 ∅

7 0 0 0 5 nongc 1 0 0 1 4 3 1 Mean

5 4 1 5 1 size 3 5 5 2 5 5 4

2 2 0 0 2 count 1 1 1 2 2 2 2

Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark

%alive 0% 0%alive 100% alive 50%

al :BnhakRsls-Sadr eito ipeCce2 Cycle Simple - Deviation Standard - Results Benchmark 1: Table 14 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Table 2: Benchmark Results - Standard Deviation - Cross Cycles 214

0% alive 50% alive 100% alive Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k size 14 1 1 1 8 5 4 6 10 3 10 5 cross 6 2 6 7 8 4 10 3 10 12 7 9

Mean count 6 0 1 1 9 102 5 4 6 5 5 3 ∅ 9 1 3 3 9 37 6 4 9 7 7 6 size 14 0 0 0 16 12 3 0 16 12 7 0 cross 3 10 3 6 7 7 3 4 5 2 6 5 Memory (MB) Max count 5 0 2 3 7 14 1 0 5 1 2 0 ∅ 7 4 2 3 10 11 3 1 9 5 5 2 size 0.06 0.09 0.03 0.03 0.03 0.12 0.04 0.05 0.03 0.09 0.18 0.12 cross 0.02 0.08 0.33 0.19 0.02 0.05 0.39 0.18 0.03 0.37 0.08 0.41

GC count 0.03 0.03 0.03 0.03 0.02 0.93 0.08 0.06 0.02 0.11 0.04 0.07 ∅ 0.04 0.07 0.13 0.08 0.02 0.37 0.17 0.10 0.03 0.19 0.10 0.20 size 0.11 0.09 0.03 0.04 0.03 0.14 0.04 0.06 0.02 0.09 0.19 0.13 Time (s) cross 0.03 0.08 0.34 0.18 0.02 0.05 0.39 0.16 0.03 0.40 0.08 0.43

Total count 0.03 0.04 0.03 0.04 0.03 0.95 0.10 0.07 0.03 0.13 0.05 0.08 ∅ 0.06 0.07 0.14 0.09 0.03 0.38 0.18 0.10 0.03 0.21 0.11 0.21 size 0.24 0.17 0.04 0.05 0.10 0.39 0.04 0.10 0.09 0.31 0.10 0.16 cross 0.09 0.22 0.00 0.00 0.07 0.17 0.00 0.00 0.13 1.44 0.00 0.00

Mean count 0.12 0.05 0.03 0.05 0.08 1.67 0.07 0.11 0.08 0.23 0.02 0.07 ∅ 0.15 0.15 0.03 0.04 0.08 0.74 0.04 0.07 0.10 0.66 0.04 0.08 size 5.0 5.3 2.4 1.5 6.7 17.1 5.2 4.9 6.4 26.5 15.7 12.4 cross 5.6 7.2 5.5 4.0 5.0 10.3 30.6 4.7 7.4 88.9 12.6 3.3 Pauses (ms)

Max count 7.7 0.5 0.4 1.5 4.6 270.4 14.2 1.6 6.0 20.2 2.9 5.4 ∅ 6.1 4.3 2.8 2.3 5.5 99.3 16.7 3.7 6.6 45.2 10.4 7.0 93 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

94

. . . 1.3 1.4 5.2 0.7 0.2 0.6 2.3 0.5 0.6 0.3 0.5 0.8 ∅

1.9 4.4 0.8 0.2 0.7 2.0 0.6 0.3 0.5 0.5 1.3 rc 1.6 Max

ass(ms) Pauses 0.9 1.8 0.2 0.1 0.2 0.2 0.3 0.2 0.0 0.1 0.3 nonrc 1.7

1.4 9.2 1.1 0.2 0.9 4.6 0.6 1.2 0.2 0.9 0.9 count 0.6

.902 .60.07 0.06 0.20 0.09 0.06 0.04 0.14 0.07 0.06 0.08 0.06 0.08 ∅

0.07 0.07 0.27 0.13 0.02 0.02 0.19 0.06 0.10 0.16 0.05 0.07 rc Mean

0.05 0.09 0.04 0.06 0.07 0.04 0.05 0.05 0.05 0.06 0.05 nonrc 0.08

0.05 0.25 0.09 0.09 0.03 0.18 0.10 0.04 0.04 0.06 0.13 count 0.06

.000 .10.01 0.01 0.01 0.00 0.00 0.00 0.01 0.00 0.00 0.01 0.00 0.00 ∅

0.01 0.02 0.01 0.00 0.00 0.00 0.01 0.00 0.01 0.01 0.00 0.00 rc Total

0.00 0.00 0.00 0.00 0.00 nonrc 0.01 0.00 0.00 0.00 0.00 0.00 0.00

ie(s) Time

0.01 0.01 0.00 0.00 0.01 count 0.01 0.01 0.01 0.01 0.01 0.00 0.01

.000 .00.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 .000 .10.00 0.01 0.01 0.00 ∅

0.00 0.00 0.01 0.00 0.00 rc 0.00 0.01 0.01 0.00 0.00 0.00 0.00

GC

0.00 0.00 0.00 0.00 0.00 nonrc 0.01 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.01 count 0.01 0.01 0.01 0.00 0.01 0.00 0.01

3 4 0 3 2 1 1 2 1 2 2 4 ∅

3 1 1 0 0 rc 1 2 4 3 0 0

0 Max

eoy(MB) Memory

2 4 2 3 1 nonrc 0 0 1 3 8 10 0

5 0 1 0 5 count 3 4 0 6 0 2 1

2 5 3 6 5 2 3 3 5 5 3 5 ∅

6 4 1 5 1 rc 5 5 3 6 1 3 4 Mean

6 8 1 5 6 nonrc 8 7 5 2 6 8 1

7 3 3 0 2 count 2 2 2 7 1 4 4

Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark

%alive 0% 0%alive 100% alive 50%

al :BnhakRsls-Sadr eito rs eeec 2 Reference Cross - Deviation Standard - Results Benchmark 3: Table r onon-rc) to (rc 14 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Table 4: Benchmark Results - Standard Deviation - Cross Reference 214 (non-rc to rc)

0% alive 50% alive 100% alive Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k count 6 3 4 4 8 5 5 5 3 1 3 2 nonrc 8 1 4 6 5 5 1 1 1 6 8 5

Mean rc 5 0 0 0 6 1 4 4 7 5 4 3 ∅ 6 1 3 4 7 4 3 3 4 4 5 3 count 5 0 0 0 11 8 5 4 7 9 4 4 nonrc 4 2 0 3 5 4 3 2 2 4 5 2 Memory (MB) Max rc 3 0 0 3 4 0 0 0 6 7 0 0 ∅ 4 1 0 2 7 4 3 2 5 7 3 2 count 0.00 0.00 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.01 0.01 0.00 nonrc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

GC rc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.01 0.00 ∅ 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.01 0.00 count 0.00 0.01 0.00 0.00 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.00 Time (s) nonrc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Total rc 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.01 0.01 0.00 ∅ 0.00 0.00 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.01 0.01 0.00 count 0.06 0.11 0.03 0.06 0.14 0.21 0.04 0.07 0.04 0.08 0.07 0.04 nonrc 0.04 0.05 0.02 0.02 0.10 0.06 0.04 0.04 0.05 0.05 0.02 0.04

Mean rc 0.04 0.07 0.04 0.05 0.03 0.11 0.03 0.04 0.06 0.29 0.02 0.06 ∅ 0.04 0.08 0.03 0.05 0.09 0.13 0.04 0.05 0.05 0.14 0.04 0.05 count 0.8 0.4 0.7 1.0 0.7 4.0 1.3 0.3 0.4 2.2 0.9 1.2 nonrc 0.0 0.2 0.0 0.0 0.2 0.2 0.2 0.4 0.3 0.5 0.1 0.2 Pauses (ms)

Max rc 0.7 1.4 0.9 0.8 0.4 1.6 1.0 0.2 0.7 2.3 0.2 1.3 ∅ 0.5 0.7 0.6 0.6 0.4 1.9 0.8 0.3 0.5 1.7 0.4 0.9 95 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek. 96 al :BnhakRsls-Sadr eito plcto Benchmarks Application - Deviation Standard - Results Benchmark 5: Table

Pauses (ms) Time (s) Memory (MB)

Max Mean GC Max Mean ∅ ∅ ∅ ∅ ∅ udLibet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome Libet Quod Pygame PyChess Tweaks Gnome Music Gnome .38009 .170.0204 0.0187 0.0199 0.0318 0.0088 0.0210 0.1222 0.0040 0.0030 Base .313 .52.28 2.25 1.31 1.43 1.64 1.53 1.07 1.54 .005 .20.45 0.52 0.58 0.60 0.81 0.46 1.62 0.83 3.41 0.83 0.62 2.82 0.65 2.80 0.35 0.35 1.31 0.57 0.42 . . . 2.6 3.0 4.0 3.1 4.5 1.8 6.2 0.7 2.2 0.0110 0.0466 0.0268 0.0062 0.0092 Mark 0.86 0.42 1.88 1.15 2.25 0.68 0.46 1.58 0.67 1.95 0.25 0.34 0.47 0.64 1.18 3.0 1.6 7.0 2.2 6.3 0.0302 0.0346 0.0136 0.0086 0.0066 Inc5k 2.67 0.26 6.77 0.93 0.61 1.36 1.62 3.45 0.63 0.61 0.99 0.22 0.14 0.57 0.67 5.8 1.7 3.5 0.6 3.3 Inc50k 0.0268 0.0504 0.0141 0.0032 0.0074 2.12 0.49 6.68 1.26 0.84 1.34 1.83 3.72 0.78 0.54 0.72 0.26 0.25 0.24 0.78 6.1 1.4 2.6 0.4 2.7 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Table 6: Benchmark Results - Scaling - Simple Cycle

0% alive 50% alive 100% alive Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k count 0.8653 0.1693 0.1744 0.1706 0.8629 0.7111 0.7221 0.7128 0.8742 0.8298 0.8373 0.8367 size 0.8246 0.5440 0.5315 0.5373 0.8250 0.7658 0.7755 0.7691 0.8229 0.8403 0.8404 0.8363

Mean nongc 0.8319 0.5785 0.5782 0.5811 0.8155 0.7734 0.7654 0.7666 0.8120 0.7963 0.7962 0.7979

count 0.8957 0.0826 0.0888 0.0891 0.8971 0.7871 0.7848 0.7843 0.9038 0.8933 0.9012 0.8973 size 0.8875 0.3856 0.4091 0.4103 0.8864 0.7765 0.8099 0.7921 0.8861 0.8942 0.9033 0.8992 Memory (MB) Max nongc 0.8912 0.4065 0.4321 0.4320 0.8851 0.8117 0.7956 0.7934 0.8799 0.8697 0.8647 0.8682

count 1.3271 1.0416 1.0344 1.0369 1.3211 1.5306 1.5445 1.5320 1.3331 1.3326 1.3046 1.3446 size 1.2140 1.7069 1.6176 1.5899 1.2079 1.6024 1.4821 1.4634 1.1979 1.4199 1.3372 1.3317

GC nongc 1.2061 1.9926 1.8079 1.8001 1.2062 1.5549 1.5284 1.5145 1.2068 1.2488 1.2466 1.2759

count 1.2350 1.0152 1.0137 1.0144 1.2335 1.4809 1.4875 1.4735 1.2425 1.3034 1.2712 1.3046 Time (s) size 1.1610 1.5284 1.4651 1.4438 1.1551 1.5427 1.4346 1.4176 1.1469 1.3860 1.3033 1.2975

Total nongc 1.1537 1.8052 1.6203 1.6163 1.1557 1.4810 1.4445 1.4311 1.1565 1.2228 1.2146 1.2393

count 0.5458 -0.0851 -0.0438 -0.0596 0.5466 0.7241 0.2034 0.5450 0.5526 0.6793 0.2128 0.5008 size 0.5143 0.3516 -0.1265 0.2172 0.5114 0.7473 0.0524 0.4283 0.5088 0.7274 0.1410 0.4214

Mean nongc 0.5149 0.6646 0.4883 0.4853 0.5155 0.7400 0.6458 0.6348 0.5163 0.6618 0.6298 0.6461

count 1.1249 0.0359 0.0649 0.0399 1.1063 1.1060 1.1378 1.0302 1.1200 1.0905 0.9977 1.0461 size 1.0307 0.7617 0.5973 0.6300 1.0229 1.1660 1.0060 0.9158 1.0071 1.1775 0.9979 0.9970 Pauses (ms)

Max nongc 1.0256 1.0791 0.6484 0.6458 1.0148 1.1385 1.1246 1.1245 1.0206 1.0437 0.9349 0.9513 97 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

98

1.1464 1.2952 1.0271 0.9399 1.1611 1.1047 0.2637 0.2572 0.1628 1.1054 count 1.0476 1.0772 Max

ass(ms) Pauses 1.1257 1.1110 1.0992 1.0872 1.3330 1.0995 0.9554 0.9199 1.2291 1.1117 cross 1.0104 0.9814

1.1463 1.0183 0.9830 1.0061 0.9903 1.0078 0.6450 0.8648 0.9123 1.0180 size 1.0892 1.0234

0.1863 -0.0478 0.4389 0.1483 0.2168 0.0019 0.4078 0.1816 -0.1729 -0.1565 -0.1661 0.2050 count Mean

0.4786 0.2311 -1.7382 -1.6365 0.4623 0.2346 -1.7668 -1.6326 0.2978 0.2322 cross -1.7564 -1.6299

0.3420 0.2017 0.1784 -0.0679 0.3080 0.2208 0.0389 -0.0405 0.1389 0.2355 size 0.1749 -0.1249

1.0990 1.2121 1.1517 1.1001 1.0406 1.1237 1.1588 1.0360 0.9709 0.9768 0.9854 1.0420 count Total

1.0425 1.1617 1.1509 1.2464 1.0506 cross 1.2477 1.1940 1.1406 1.0475 1.2060 1.1842 1.2407

ie(s) Time

0.9850 1.1646 1.0893 1.1942 0.9933 size 1.0957 1.1588 1.1137 0.9852 1.0477 1.0935 1.0946

1.0773 0.9907 0.9948 1.0055 1.0816 count 1.1190 1.2517 1.1771 1.1704 1.0662 1.1622 1.1997

GC

1.0785 1.2120 1.2018 1.3012 1.0881 cross 1.2949 1.2316 1.1642 1.0837 1.2523 1.2279 1.2950

1.0051 1.2254 1.1200 1.2483 1.0109 size 1.1205 1.1968 1.1403 1.0047 1.0755 1.1224 1.1245

0.9610 0.1692 0.1747 0.0653 0.9608 count 0.9367 0.9598 0.9493 0.9624 0.9156 0.9218

0.9474 Max

eoy(MB) Memory

0.9584 0.8218 0.8204 0.5762 0.9605 cross 0.9598 0.9574 0.9512 0.9622 0.8953 0.8941 0.9297

0.9577 0.4374 0.6393 0.5117 0.9568 size 0.9550 0.9557 0.9539 0.9595 0.8417 0.8953 0.9022

0.9886 0.2516 0.2543 0.1387 0.9929 count 0.9104 0.9422 0.9802 1.0491 0.8550 0.8831 0.9014 Mean

0.9846 0.8018 0.7950 0.6629 0.9880 cross 0.9328 0.9333 0.9795 0.9922 0.9078 0.9044 0.9264

0.9172 0.5781 0.6566 0.6002 0.9161 size 0.9422 0.9446 0.8907 0.9223 0.8068 0.8634 0.8035

Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark

%alive 0% 0%alive 100% alive 50% al :BnhakRsls-Saig-CosCycles Cross - Scaling - Results Benchmark 7: Table Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

Table 8: Benchmark Results - Scaling - Cross Reference (rc to non-rc)

0% alive 50% alive 100% alive Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k Base Mark Inc5k Inc50k count 0.9144 0.1437 0.1747 0.1658 0.9105 0.8183 0.8701 0.8977 0.9150 0.9027 0.9553 0.9092 nonrc 0.9534 0.9588 0.9711 0.9746 0.9537 0.9294 0.9268 0.9293 0.9516 0.9536 0.9759 0.9564

Mean rc 0.8309 0.5512 0.5371 0.5307 0.8201 0.7637 0.7985 0.7677 0.8237 0.8385 0.8356 0.8388

count 0.9510 0.0701 0.0938 0.0918 0.9433 0.8719 0.9057 0.9524 0.9482 0.9474 0.9523 0.9695 nonrc 0.9696 1.0127 1.0383 1.0376 0.9714 0.9774 0.9654 0.9659 0.9703 0.9710 0.9702 0.9701 Memory (MB) Max rc 0.8931 0.3825 0.4101 0.4053 0.8869 0.7767 0.8109 0.7912 0.8840 0.8916 0.9026 0.9018

count 1.0140 1.0053 1.0084 0.9728 0.9945 1.1563 1.1602 1.1605 1.0097 1.1294 1.2357 1.1499 nonrc 0.9600 0.9814 0.9891 0.9712 0.9589 0.9568 0.9450 0.9299 0.9462 0.9554 0.9659 0.9506

GC rc 1.2097 1.6740 1.5678 1.5924 1.2213 1.5610 1.4388 1.4865 1.1996 1.4315 1.3308 1.3501

count 0.9937 0.9885 0.9930 0.9568 0.9732 1.1158 1.1217 1.1153 0.9889 1.1059 1.1957 1.1201 Time (s) nonrc 0.9572 0.9713 0.9787 0.9591 0.9552 0.9531 0.9435 0.9257 0.9425 0.9523 0.9631 0.9468

Total rc 1.1587 1.4974 1.4211 1.4434 1.1684 1.5028 1.3943 1.4385 1.1479 1.3950 1.2983 1.3160

count 0.2791 -0.0666 -0.0848 -0.1024 0.2315 0.4268 0.0754 0.2008 0.2755 0.4446 0.0657 0.1969 nonrc 0.0713 -0.0053 0.0614 0.0513 0.0719 0.0335 0.0920 0.0949 0.0743 0.0771 0.0566 0.1207

Mean rc 0.5120 0.3345 -0.1190 0.2330 0.5214 0.7182 0.0474 0.4354 0.5117 0.7224 0.1347 0.4428

count 0.9492 0.1924 0.1956 0.1924 0.9244 1.0708 0.9613 1.0675 0.9449 1.1688 1.0368 1.0415 nonrc 0.9890 0.0492 0.0819 0.0674 0.9851 0.8589 0.6878 0.9025 0.9717 0.9667 0.5315 0.9977 Pauses (ms)

Max rc 1.0114 0.7268 0.5673 0.6271 1.0250 1.1199 0.9915 0.9446 1.0157 1.2109 1.0125 1.0060 99 Die approbierte gedruckte Originalversion dieser Diplomarbeit ist an der TU Wien Bibliothek verfügbar. The approved original version of this thesis is available in print at TU Wien Bibliothek.

100

1.1484 1.0229 0.9803 0.9686 1.0889 1.0218 0.7641 0.7476 1.0101 1.0380 rc 1.0012 0.9723 Max

ass(ms) Pauses 0.0813 0.0727 0.0911 0.0968 0.0875 0.0936 0.0968 0.1003 0.0735 0.0746 nonrc 0.0783 0.0848

1.0724 1.0740 1.0005 1.0677 1.0540 1.0791 0.2655 0.2619 0.2787 1.0603 count 0.9339 1.0680

0.4324 0.1403 0.7040 0.5219 0.4315 0.0627 0.7207 0.5107 0.3723 -0.0277 0.7110 0.5218 rc Mean

-0.0046 0.0002 0.0472 0.0540 0.0089 -0.0015 0.0508 0.0620 -0.0067 -0.0115 nonrc 0.0087 0.0178

0.1662 -0.0691 0.1900 -0.0235 0.1742 0.0997 -0.1669 -0.1415 -0.0577 0.5022 count 0.0651 -0.1930

1.2975 1.2639 1.3581 1.1655 1.4079 1.3779 1.4477 1.1461 1.6805 1.6659 1.8310 1.1641 rc Total

0.9630 0.9834 0.9822 0.9767 0.9826 nonrc 0.9613 0.9711 0.9765 0.9785 0.9622 0.9514 0.9567

ie(s) Time

1.0183 0.9740 0.9774 0.9913 1.2797 count 1.0406 1.1697 1.0730 1.0069 1.0401 1.1294 1.0683

1.2007 1.8012 1.7750 1.9626 1.2191 rc 1.3313 1.2943 1.3916 1.2177 1.4498 1.4184 1.4949

GC

0.9693 0.9936 0.9915 0.9855 0.9931 nonrc 0.9648 0.9758 0.9819 0.9835 0.9666 0.9557 0.9624

1.0681 1.0033 1.0012 1.0269 1.3971 count 1.0603 1.2160 1.0975 1.0355 1.0733 1.1905 1.1147

0.8880 0.5655 0.5595 0.5381 0.8798 rc 0.8973 0.9035 0.8877 0.8801 0.7871 0.7934

0.7848 Max

eoy(MB) Memory

0.9529 1.0363 1.0383 1.0127 1.0125 nonrc 0.9685 0.9696 0.9684 0.9688 0.9513 0.9544 0.9572

0.9334 0.0786 0.0815 0.0755 0.8912 count 0.9335 0.9345 0.9489 0.9471 0.8433 0.8878 0.9151

0.8229 0.6828 0.6838 0.6811 0.8113 rc 0.8401 0.8367 0.8323 0.8143 0.7690 0.7758 0.7709 Mean

0.9294 0.9742 0.9737 0.9634 0.9641 nonrc 0.9758 0.9732 0.9743 0.9739 0.9369 0.9401 0.9396

0.9002 0.1515 0.1529 0.1486 0.8523 count 0.8728 0.9425 0.8865 0.9247 0.8305 0.8841 0.8228

Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base Inc50k Inc5k Mark Base

%alive 0% 0%alive 100% alive 50% al :BnhakRsls-Saig-CosRfrne(o-ct rc) to (non-rc Reference Cross - Scaling - Results Benchmark 9: Table