Closed Bug 582770 (asymmGC) Opened 14 years ago Closed 6 years ago

Multiple mutator support for GC instances

Categories

(Tamarin Graveyard :: Garbage Collection (mmGC), defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX
Future

People

(Reporter: siwilkin, Unassigned)

References

Details

(Whiteboard: Tracking Asymmetric-GC)

Attachments

(4 obsolete files)

Attached file Initial patch (obsolete) (deleted) —
Using threads for internal VM functions is currently difficult as an instance of MMgc's managed memory allocator/collector, GC, will support only a single mutator. Internal VM threads will need to allocate or access managed ABC metadata objects and VM objects, hence they would appear as (unsupported) concurrent mutators to their containing VM's GC instance. This patch, combined with the thread-safepointing implementation (bug 575544) addresses this issue by allowing a GC to be shared between a single ActionScript-executing application thread, and any number of internal VM threads. The design report for this work is currently an internal document that I'm working to get on to bugzilla. In the mean time, email me if you want a copy, and below is also a brief summary. Note the current implementation requires plenty of optimizations, particularly on allocation and write-barrier fast-paths. These will be added to this bug in due course. Summary: The overall model is for application-threads to retain the GC::ThreadEnter/Exit() mechanism of claiming exclusive ownership of a GC. VM-threads on the other hand use a different entry-point, which simply informs a GC that they wish to 'attach'. A GC maintains a list of attached VM-threads, which may concurrently (with each other and an applciation-thread) allocate managed objects and mutate the GC's managed object graph. A VM-thread may attach or detach from a GC at any point, independently of any application-thread ownership of the GC. Note that VM-threads are not tied to any particular VM instance, they may attach to any VM's GC. Hence, VM-threads can be shared across VM instances, allowing, for example, compilation threads to service a whole Flash Player process. A VM-thread may not, however, attach to multiple GC's at the same time, or recursively attach to the same GC. These patterns are required for an application-thread's execution, but are unnecessary for a VM-thread that we assume will be non-reentrant when calling out of VM code. From a GC engineering perspective it is attractive to allow any mutator thread to become the collector thread if its allocation request triggers a collection phase (or, better still, have a dedicated collector thread). Neither of these are possible however, as they would be disruptive to finalization semantics within client-code. Specifically, the ZCT-reap and sweep/finalize phases eagerly invoke collected objects' finalizers, hence, VM-threads would likely execute application-thread code when acting as a collector. We are therefore compelled to use only the application-thread in all collection phases except incremental-marking. In the current avmshell proof-of-concept, however, two builds are available: * AVMFEATURE_THREADSAFE_GC_CLIENT_COLLECT, where the application-thread acts as the collector in all phases. * AVMFEATURE_THREADSAFE_GC, where any thread can act as collector (as all finalizers within the VM, GC and shell code-bases are thread agnostic). Having only the application-thread available as a collector imposes some extra complications for VM-threads. Specifically, if the allocation request of a VM-thread triggers a collection, then it must be suspended until the collection occurs; hence to prevent deadlocks, the following must be enforced: * While requesting an allocation, a VM-thread cannot hold any lock which is acquirable by an application-thread (in mutator code). * An application-thread cannot be suspended in mutator code pending a notification from a VM-thread. The first of these constraints is difficult to work-around in an efficient way, however, it is a corner-case scenario and doesn't severely impact what can be done with VM-threads. The second of the constraints is much more important to remove, particularly in the context of cleanly shutting down a VM instance. Specifically, when an application-thread shuts down a VM's GC instance, something must be done with it's attached VM-threads which are blocked awaiting a collection. The two solutions to this are: * Allow failed allocations (or throw some exception) within VM-threads when an application-thread is no long available for collection work. * Provide a 'wait' construct that re-purposes an application-thread to act as a dedicated collector-thread whilst suspended in mutator code. The first of these is very unattractive as it breaks the existing allocation guarantees of MMgc. The second solution is much cleaner, and has been implemented as a general solution within the GCCollectorCondition class. For an example of its utility beyond VM-shutdown, see the ExecutorFuture implementation of the 'future' concurrency construct, which allows an application-thread to wait on a future executed within a VM-thread. A final design point for discussion is a policy decision: if an allocation request from a VM-thread cannot be satisfied, should all of the GC's mutators be stopped so that the application-thread can transition into a collector phase preemptively? Or should a VM-thread wait until the application thread naturally transitions into a collection phase based on its own allocation characteristics? In the current implementation (when configured so that only the application-thread performs all collector phases), VM-threads to do not normally trigger phase transitions, instead they wait for the application-thread to naturally enter the required phase (except, of course, when the application-thread is acting as a dedicated collector via GCCollectorCondition).
Depends on: 555760, 555765, 575544
Blocks: 582772
Attached patch Initial patch (obsolete) (deleted) — Splinter Review
Attachment #461034 - Attachment is obsolete: true
Blocks: 582782
Blocks: 582817
Attached patch Latest. MMgc module changes only. (obsolete) (deleted) — Splinter Review
In this revision: - Rebased onto new object-header bits layout, including MMGC_FASTBITS. - Rebased onto newly-factored GCPolicyManager. - Incremental WB fast-paths are now lock-free (updates are via atomic primitives). Enable via MMGC_THREADSAFE_GC_FAST_WB. - Reference counting WB fast-paths are now synchronization-free on the main-thread. (An RCObject whose reference count is modified by a VM-thread has similar semantics to that as the current 'sticky' state). Enable via MMGC_THREADSAFE_GC_FAST_WBRC. - Most reference counting WB fast-paths now do not inspect thread identity. A new set of barrier macros are defined (with a GUARDED suffix), that test thread identity, the existing macros do not. The idea is that client and user class definitions, client C++ code, JITed AS code and the interpreter will all use the existing macros without modification, whereas VM code can use the guarded versions at some level of conservativeness. (More explanation to follow on this design.) Enable via MMGC_THREADSAFE_GC_FAST_WBRC_WITH_CONTEXT. - Each mutator now has a private quick-list for fast-path allocations, and a private budget/policy that is managed by the GCPolicyManager (with per-mutator budgets being balanced/biased from a global budget). Enable via MMGC_THREADSAFE_GC_FAST_ALLOC. - Growing/shitfing of a GC instance's pageMap structure now happens from within a safepoint. This will probably not be needed when the sparse pageMap patch lands. - Safepoint tasks are now expressed as functors (implement the Runnable interface). Includes an initial implementation of safepoint profiling. - Major cleanup/constification of GCAlloc. An experimental feature is also included, which is currently unstable and disabled by default: - MMGC_THREADSAFE_GC_FAST_WBRC_DIST. Builds on MMGC_THREADSAFE_GC_FAST_WBRC by maintaining a distributed reference count for RCObjects in thread-private delta tables. This allows RCObjects who have reference counts updated by VM-threads to be available for reaping (accurate reference counts are calculated before a reap). Bookkeeping complications are brought by manually freeing RCObjects; currently some corner cases are not handled properly, hence the feature is disabled.
Attachment #461039 - Attachment is obsolete: true
Attached patch Latest. core and shell changes. (obsolete) (deleted) — Splinter Review
A separate patch of changes to core (and shell), rather than MMgc. Mostly comprised of write-barrier modifications, mutator-side setup of GCCollectorConditions, and addition of relevant AVMFEATURES to the build system. Note these patches are poluted with ifdefs from both dependent and supporting patches. An experimental, incomplete feature is also included (disabled by default): - MMGC_THREADSAFE_GC_FAST_RCOBJECT_CTOR. An attempt to remove thread identity tests from RCObject ctors (following a similar pattern and argument to that of MMGC_THREADSAFE_GC_FAST_WBRC_WITH_CONTEXT).
Blocks: 600723
Note: Simon has been maintaining a branch here: http://asteam.macromedia.com/hg/users/siwilkin/multithreaded-tamarin so one is likely to want to look there rather than at the currently attached patches, (though of course the current patches may represent a useful snapshot of his work).
Priority: -- → P4
Target Milestone: --- → flash10.x - Serrano
Assignee: nobody → siwilkin
Status: NEW → ASSIGNED
Depends on: 609809, 609810
Depends on: 618439
Attachment #474967 - Attachment is obsolete: true
Attachment #474968 - Attachment is obsolete: true
Depends on: 621085
Depends on: 621084
Depends on: 621086
Rather than be the home for monolithic AsymmGC patches, this is now the tracking bug for the feature. Speculative patch stack (those marked with * require factoring out of the original monolithic patch): // VMPI threading extensions bug 555760 // C++ concurrency library bug 555765 // Safepoints bug 575544 // Refactor asymmGC-prep-gcalloc-constify (bug 621084) asymmGC-prep-gccallbacks (bug 621085) asymmGC-feature-declarations (bug 621086) // Collector thread-safety asymmGC-owner-thread-safepointable (bug tbc) *asymmGC-thread-support (bug tbc) *asymmGC-vmthread-entry (bug tbc) *asymmGC-safepoint-tasks (bug tbc) // Mutator thread-safety (only main-thread allocates) asymmGC-gcalloca (bug tbc) *asymmGC-wb (bug tbc) *asymmGC-wbrc (bug tbc) asymmGC-pagemap (bug tbc) // Mutator thread-safety (all mutators allocate) asymmGC-policymanager (bug tbc) asymmGC-gcalloc (bug tbc) asymmGC-guarded-rc-core (bug tbc) asymmGC-profiling-sampler (bug tbc)
The above patch stack corresponds to rev 162 of the patch queue. The patch queue repo is available here: http://asteam.corp.adobe.com/hg/users/fklockii/tr-patch-queues
Depends on: 622827
Depends on: 622954
Depends on: 623095
Speculative patch stack as of MQ rev 177: (those marked with * require factoring out of the original monolithic patch): // VMPI threading extensions bug 555760 // C++ concurrency library bug 555765 // Safepoints bug 575544 // Refactor asymmGC-prep-gcalloc-constify (bug 621084) asymmGC-prep-gccallbacks (bug 621085) asymmGC-feature-declarations (bug 621086) // Collector thread-safety asymmGC-owner-thread-safepointable (bug 622827) asymmGC-thread-support (bug 622954) asymmGC-vmthread-entry (bug 623095) *asymmGC-safepoint-tasks (bug tbc) // Mutator thread-safety (only main-thread allocates) asymmGC-gcalloca (bug tbc) *asymmGC-wb (bug tbc) *asymmGC-wbrc (bug tbc) asymmGC-pagemap (bug tbc) // Mutator thread-safety (all mutators allocate) asymmGC-policymanager (bug tbc) asymmGC-gcalloc (bug tbc) asymmGC-guarded-rc-core (bug tbc) asymmGC-profiling-sampler (bug tbc)
Depends on: 623205
Depends on: 623233
Depends on: 623293
Speculative patch stack as of MQ rev 184: (those marked with * require factoring out of the original monolithic patch): // VMPI threading extensions bug 555760 // C++ concurrency library bug 555765 // Safepoints bug 575544 // Refactor asymmGC-prep-gcalloc-constify (bug 621084) asymmGC-prep-gccallbacks (bug 621085) asymmGC-feature-declarations (bug 621086) // Collector thread-safety asymmGC-owner-thread-safepointable (bug 622827) asymmGC-thread-support (bug 622954) asymmGC-vmthread-entry (bug 623095) asymmGC-safepoint-tasks (bug 623205) // Mutator thread-safety (only main-thread allocates) asymmGC-gcalloca (bug 623233) asymmGC-pagemap (bug 623293) *asymmGC-wb (bug tbc) *asymmGC-wbrc (bug tbc) // Mutator thread-safety (all mutators allocate) asymmGC-policymanager (bug tbc) asymmGC-gcalloc (bug tbc) asymmGC-guarded-rc-core (bug tbc) asymmGC-profiling-sampler (bug tbc)
Depends on: 623618
Depends on: 623762
Depends on: 623802
Speculative patch stack as of MQ rev 190: (those marked with * require factoring out of the original monolithic patch): // VMPI threading extensions bug 555760 // C++ concurrency library bug 555765 // Safepoints bug 575544 // Refactor asymmGC-prep-gcalloc-constify (bug 621084) asymmGC-prep-gccallbacks (bug 621085) asymmGC-feature-declarations (bug 621086) // Collector thread-safety asymmGC-owner-thread-safepointable (bug 622827) asymmGC-thread-support (bug 622954) asymmGC-vmthread-entry (bug 623095) asymmGC-safepoint-tasks (bug 623205) // Mutator thread-safety (only main-thread allocates) asymmGC-gcalloca (bug 623233) asymmGC-pagemap (bug 623293) asymmGC-gcbits (bug 623618) asymmGC-wb (bug 623762) asymmGC-wbrc (bug 623802) asymmGC-guarded-rc-core (bug tbc) // Mutator thread-safety (all mutators allocate) asymmGC-policymanager (bug tbc) asymmGC-gcalloc (bug tbc) *asymmGC-weakrefs (bug tbc) asymmGC-profiling-sampler (bug tbc)
Depends on: 623993
Depends on: 617198
Depends on: 624023
Patch stack as of MQ rev 198: // VMPI threading extensions bug 555760 // C++ concurrency library bug 555765 // Safepoints bug 575544 // Refactor asymmGC-prep-gcalloc-constify (bug 621084) asymmGC-prep-gccallbacks (bug 621085) asymmGC-feature-declarations (bug 621086) // Collector thread-safety asymmGC-owner-thread-safepointable (bug 622827) asymmGC-thread-support (bug 622954) asymmGC-vmthread-entry (bug 623095) asymmGC-safepoint-tasks (bug 623205) // Mutator thread-safety (only main-thread allocates) asymmGC-gcalloca (bug 623233) asymmGC-pagemap (bug 623293) asymmGC-gcbits (bug 623618) asymmGC-wb (bug 623762) asymmGC-wbrc (bug 623802) asymmGC-guarded-rc-core (bug 623993) // Mutator thread-safety (all mutators allocate) asymmGC-gcalloc (bug 624023) asymmGC-profiling-sampler (bug 617198) asymmGC-weakrefs (bug tbc, to be extracted from asymmGC-gcalloc)
Whiteboard: Tracking Assymetric_GC
Whiteboard: Tracking Assymetric_GC → Tracking Asymmetric_GC
Alias: asymmGC-tracking
Whiteboard: Tracking Asymmetric_GC → Tracking Asymmetric-GC
Depends on: 629269
asymmGC-weakrefs (bug 629269)
An Excel spreadsheet containing performance numbers (for TR rev 6090 / patch queue rev 261) is being maintained here: http://asteam.corp.adobe.com/builds/downloads/siwilkin/asym_gc_perf.xlsm
(In reply to comment #12) > An Excel spreadsheet containing performance numbers (for TR rev 6090 / patch > queue rev 261) is being maintained here: > > http://asteam.corp.adobe.com/builds/downloads/siwilkin/asym_gc_perf.xlsm This spreadsheet is less useful than it could be, because zero-entries in the datasets are making the resulting charts have big drops at the end, and the rendering automatically zooms out, so that the real variation in the earlier entries is masked. Where's gnuplot when you need it. (Kidding.) Seriously though, can we change the spreadsheet generation process to eliminate these garbage entries in some way?
(In reply to comment #13) > (In reply to comment #12) > Seriously though, can we change the spreadsheet generation process to eliminate > these garbage entries in some way? The spreadsheet is a work-in-progress that I'm working with cpeyer on. I've added cpeyer to the cc list.
Assignee: siwilkin → fklockii
Priority: P4 → P3
Target Milestone: Q3 11 - Serrano → Q1 12 - Brannan
Depends on: 649895
Depends on: 649920
Blocks: 650108
AsymmGC patch stack as of MQ rev 282, TR rev 6090: asymmGC-feature-declarations (bug 621086) asymmGC-owner-thread-safepointable (bug 622827) asymmGC-thread-support (bug 622954) asymmGC-vmthread-entry (bug 623095) asymmGC-safepoint-tasks (bug 623205) asymmGC-gcalloca (bug 623233) asymmGC-pagemap (bug 623293) asymmGC-gcbits (bug 623618) asymmGC-wb (bug 623762) asymmGC-wbrc (bug 623802) asymmGC-guarded-rc-core (bug 623993) asymmGC-gcalloc (bug 624023) asymmGC-gccollectorcondition (bug 649895) asymmGC-autocollectiondisable (bug 649920) asymmGC-weakrefs (bug 629269) asymmGC-profiling-sampler (bug 617198)
Assignee: fklockii → nobody
Alias: asymmGC-tracking → asymmGC
Flags: flashplayer-qrb+
Target Milestone: Q1 12 - Brannan → Future
No assignee, updating the status.
Status: ASSIGNED → NEW
No assignee, updating the status.
No assignee, updating the status.
No assignee, updating the status.
Tamarin is a dead project now. Mass WONTFIX.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
Tamarin isn't maintained anymore. WONTFIX remaining bugs.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: