Closed Bug 1894012 Opened 9 months ago Closed 8 months ago

Investigate a way to find which missing allocation sites would be beneficial to add

Categories

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

task

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(6 files)

Adding an allocation site to track GC thing tenuring is not simple and there are a huge number places where we could do this. Adding them also has an overhead in terms of tracking and updating the associated data structures. It would be great if there was a way to find out which sites could be added to get the most benefit.

Possibly we could have a way to automatically add alloc sites in debug builds or in a special build (it's likely that this wouldn't be efficient enough for production use) and then report which sites were most effective and finding pretenuring opportunities.

Severity: -- → N/A
Priority: -- → P3
Depends on: 1895462
Assignee: nobody → jcoppeard

This is follow on from bug 1894012. This allows hash tables to be used as
keys and values in hash tables that are used with WeakCache as we'll do in
these patches.

So we can use the frame iterater effectively, compile this in GC zeal builds as
well as debug builds. I added a new macro for this feature,
JS_CHECK_UNSAFE_CALL_WITH_ABI.

Currently we work this out by other means but it's simpler to store it directly
using the top bits of the bytecode offset.

I figure it's OK to only use 30 bits to store the offset since we store it in
28 bits in RetAddrEntry, although I couldn't find it documented how many bits
are actually required.

This adds a new kind of 'missing' allocation site and uses them to replace the
unknown alloction site when used from baseline. These count allocations and
promotions like normal sites but do not actually pretenure anything. Since this
requires extra machinery it is only supported in GC zeal builds.

This feature is enabled by setting the generateMissingAllocSites GC pref.

This adds the script file basename and line number and the bytecode op to the
output and tidies up the format to make it more regular.

There can be a large number of these so it's useful to restict the ones
reported by filtering on their attributes.

The feature can be enabled by passing --gc-param generateMissingAllocSites=1 to the shell.

Reporting can be enabled by setting an environment variable to filter the sites to output, e.g. JS_GC_REPORT_PRETENURE=100,missing,long

Example output:

~/clone/dev/js/src$ JS_GC_REPORT_PRETENURE=100,missing,unknown,long ./opt-build/shell --gc-param generateMissingAllocSites=1 --no-ion ~/software/matrix-react-bench/dist/main.js > /dev/null
...
Pretenuring info after minor GC 3 for OUT_OF_NURSERY reason with promotion rate 65.8%:
  Site             Zone             Location             BytecodeOp   SiteKind  TraceKind NAllocs  Promotes PRate  State
    0x78f3e127d550   0x78f3e384ae00 main.js:55           New          missing   JS Object      618      618 100.0% LongLived
    0x78f3e123cbb0   0x78f3e384ae00 self-hosted:3917     Call         missing   JS Object     1299     1299 100.0% LongLived
    0x78f3e384b5d8   0x78f3e384ae00                                   unknown   JS Object     6925     6307        Unknown
    0x78f3e384b628   0x78f3e384ae00                                   unknown   JS String     9925     2842        Unknown
  6 alloc sites created, 76 active, 2 pretenured, 0 invalidated
Pretenuring info after minor GC 4 for OUT_OF_NURSERY reason with promotion rate 93.5%:
  Site             Zone             Location             BytecodeOp   SiteKind  TraceKind NAllocs  Promotes PRate  State
    0x78f3e127d0a0   0x78f3e384ae00 main.js:55           New          missing   JS Object     1237     1237 100.0% LongLived
    0x78f3e127d550   0x78f3e384ae00 main.js:55           New          missing   JS Object     2807     2807 100.0% LongLived
    0x78f3e384b5d8   0x78f3e384ae00                                   unknown   JS Object     4049     4049        Unknown
  0 alloc sites created, 7 active, 1 pretenured, 0 invalidated
...
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/286dde992bd1 Part 0: Add needsSweep method for GC hash tables r=sfink https://hg.mozilla.org/integration/autoland/rev/f9c00b4b832c Part 1: Set JSContext::inUnsafeCallWithABI flag in GC zeal builds r=jandem https://hg.mozilla.org/integration/autoland/rev/47a8323cadda Part 2: Store the AllocSite's kind explicitly r=jandem https://hg.mozilla.org/integration/autoland/rev/b1644f447bbe Part 3: Generate alloc sites for nursery allocations that don't have them in baseline code r=jandem https://hg.mozilla.org/integration/autoland/rev/26dd27a8e66c Part 4: Report more data on alloc sites when using JS_GC_REPORT_PRETENURE r=jandem https://hg.mozilla.org/integration/autoland/rev/ee495c070184 Part 5: Add a way to filter reported alloc sites using the environment variable r=jandem

Backed out for causing SM bustages in JSScript.h

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: /builds/worker/checkouts/gecko/js/src/vm/JSScript.h:1591:15: error: inline function 'js::BaseScript::hasBaselineScript' is not defined [-Werror,-Wundefined-inline]
Flags: needinfo?(jcoppeard)
Flags: needinfo?(jcoppeard)
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/041f7d0ceeb8 Part 0: Add needsSweep method for GC hash tables r=sfink https://hg.mozilla.org/integration/autoland/rev/481ef9d2c08b Part 1: Set JSContext::inUnsafeCallWithABI flag in GC zeal builds r=jandem https://hg.mozilla.org/integration/autoland/rev/357acd25ef9e Part 2: Store the AllocSite's kind explicitly r=jandem https://hg.mozilla.org/integration/autoland/rev/e98c27b09176 Part 3: Generate alloc sites for nursery allocations that don't have them in baseline code r=jandem https://hg.mozilla.org/integration/autoland/rev/65359d316b12 Part 4: Report more data on alloc sites when using JS_GC_REPORT_PRETENURE r=jandem https://hg.mozilla.org/integration/autoland/rev/2c3eb3176e7b Part 5: Add a way to filter reported alloc sites using the environment variable r=jandem

Here are the results of running the speedometer3 benchmark with this enabled, with some post processing to summarize. This shows missing allocation sites that would have been pretenured, grouped by bytecode and trace kind:

BytecodeOp       TraceKind Sites    Allocs       Promotions
New              Object        351       306791       303885
Lambda           Object        578       287667       287303
SuperCall        Object         93       170621       170552
Call             Object        278       160650       160543
PushLexicalE     Object        100        40687        40623
Add              String         57        17360        17193
Rest             Object         11        17097        17097
StrictSetPro     Object         17         3618         3616
GetElem          Object         10         2000         2000
GetProp          Object          1         1852         1852
SpreadSuperC     Object          3         1352         1308
Iter             String          9         1030         1030
PushVarEnv       Object          1          176          176
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: