Closed Bug 1711063 Opened 4 years ago Closed 4 years ago

Pretenure long-lived plain objects and arrays based on their allocation site

Categories

(Core :: JavaScript: GC, task, P3)

task

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

(Keywords: perf-alert)

Attachments

(11 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

This aims to add an allocation site abstraction and use it to pretenure long lived objects.

This stores a pointer to a new AllocSite sturcture before every nursery cell.
Previously this was used to store a pointer to the zone, and we now have to get
the zone pointer from the AllocSite when necessary.

Since every cell must have such a pointer and we don't want to track all
allocation sites, there is a catch-call site per zone for unknown sites.
There's a second catch-all site which is used for optimized code generated for
known allocation sites by later patches.

This adds an optional AllocSite parameter to the APIs that we will use to
create objects/arrays when JIT code falls back to calling into the VM.

Depends on D115236

This adds logic to process allocation sites used since the last nursery
collection and update their state based on number of allocations made and now
many of those that were tenured.

This also dumps information about allocation sites to stderr if
JS_GC_REPORT_PRETENURING is set.

Depends on D115238

For baseline allocations we still want to track the allocations made and update
the AllocSite whereas for optimized code we want to ignore this entirely and
use the catch-all optimzed site for tracked allocation sites. To allow this,
the patch adds AllocSiteInput which can either be a register holding an
AllocSite pointer or an immediate indicating which catch-all allocation site to
use.

Depends on D115240

This allocates AllocSite instances when stubs are created. There's a limit on
the number created per minor GC to prevent runaway growth of the site list that
must be traversed at the next minor GC.

The fallback by which JIT code calls into the VM has to be different for
baseline/optimzed code because we still track allocations in baseline code. (It
might be possible to use the same one and have the baseline fallback just use
the unknow site. I think this would violate some assertions but they could
perhaps be relaxed)

Depends on D115241

Unfortunately we often end up optimizing code before a minor GC happens and we
realize that we should be pretenuring a site. This invalidates JIT code when we
decide to pretenure a site.

Depends on D115242

This allows us to detect 'young' tenured arenas which are arenas that have been created since the last major GC.

Depends on D115494

This is a bunch of heuristics to detect when sites that were short-lived become
long-lived and vice versa.

For the former we check the promotion rate for the whole nursery and the tenure
count for the optimized site in each zone. For the latter we look at tenured
objects that die in their first GC.

When then happens we discard JIT code and reset the allocation sites using the
list in the JitScript. This happens in one of two ways: if we are already
discarding JIT code then we reset the allocation sites for any remaining JIT
scripts, or if not we check all scripts in the zone and discard scripts
individually. This is so we don't add another script iteration if we're already
doing this for discarding JIT code.

Depends on D115495

Adds tests for pretenuring, not pretenuring and recovery in both directions,
for plain object and array creation.

Depends on D115496

Attachment #9222635 - Attachment description: Bug 1711063 - Part 8: Add isYoung flag to Arenas that is set on creation and cleared on sweep r?sfink → Bug 1711063 - Part 8: Add isNewlyCreated flag to Arenas that is set on creation and cleared on sweep r?sfink
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/375dea224b27 Part 1: Add gc::AllocSite class and store a pointer to an instance in the nursery cell header r=jandem https://hg.mozilla.org/integration/autoland/rev/c6b66ee2c5f1 Part 2: Add AllocSite parameter to various APIs that will be used to create new objects and arrays r=jandem https://hg.mozilla.org/integration/autoland/rev/4c02be7ed57c Part 3: Process allocation sites on minor GC r=jandem https://hg.mozilla.org/integration/autoland/rev/e03161d49696 Part 4: Add the ability to pass an allocation site when assembling inline allocations r=jandem https://hg.mozilla.org/integration/autoland/rev/1eb11eaf4089 Part 5: Track allocation sites for new plain object and new array optimized stubs r=jandem https://hg.mozilla.org/integration/autoland/rev/d5f2380c3962 Part 6: Invalidate any JIT code that has already been compiled when an allocation site is determined to be long-lived r=jandem https://hg.mozilla.org/integration/autoland/rev/9a01131eb966 Part 7: Refactor the interface to Zone::discardJitCode to use an options struct in preparation for adding more options r=jandem https://hg.mozilla.org/integration/autoland/rev/13737f4e5ff9 Part 8: Add isNewlyCreated flag to Arenas that is set on creation and cleared on sweep r=sfink https://hg.mozilla.org/integration/autoland/rev/48527c5dd40c Part 9: Recover when allocation patterns change r=jandem,sfink https://hg.mozilla.org/integration/autoland/rev/2413939a6c9f Part 10: Add tests for pretenuring behaviour r=jandem https://hg.mozilla.org/integration/autoland/rev/f8bcefb8c732 Part 11: Add telemetry for pretenuring using the existing unused historgram r=sfink

== Change summary for alert #30277 (as of Wed, 02 Jun 2021 17:24:19 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
12% octane-sm linux64-shippable 19,439.79 -> 21,785.50

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=30277

Regressions: 1714936
Regressions: 1714530
Regressions: 1723942
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: