Open Bug 1562816 Opened 6 years ago Updated 3 years ago

Investigate pretenuring strings by allocation site

Categories

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

enhancement

Tracking

()

People

(Reporter: sfink, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(9 files)

Currently, string pretenuring is done on a whole-Zone basis (if too many strings are getting tenured, we permanently stop allocating them from the nursery and allocate directly in the tenured heap). This is a very coarse heuristic. It would be far better to be able to make the decision per allocation site. We can only do that for objects right now, because their ObjectGroup is tied to an allocation site, but strings do not have anything analogous.

https://ai.google/research/pubs/pub43823 describes V8's implementation of this. They associate a "memento" with nursery-allocated items created by the baseline compiler (only), and accumulate statistics during tenuring (at which time the memento is discarded.)

We are already carrying extra data with JSStrings (the Zone*), so it would be fairly straightforward to add a memento. One option for the memento would be script pointer + bytecode offset, or a hash derived from that. Another option would be to just generate sequential or random ids and embed them in our Baseline-compiled code only, and propagate them through to the Ion-compiled code (to choose where to allocate; Ion presumably would not continue to collect allocate site-specific counts.)

The V8 system appears to record both total allocations at a site, as well as counting up how many were tenured, so they have a true percentage tenured per allocation site.

Note that if we do deduplication during string tenuring, then we really want an allocation site that produces lots of duplicates to allocate in the nursery. We might want to factor that into the heuristic, in addition to the allocation count and tenure percentage. But that's a lesser-order consideration that only matters for moderately high tenuring percentages.

Priority: -- → P3
Depends on: 1700291
Blocks: 1700291
No longer depends on: 1700291
Assignee: nobody → jcoppeard
Depends on: 1723487

I've implemented most of this but don't yet have data to show that it's a win over what we already have. I'll post the patches I have so far.

This tests whether certain kinds of allocation produce tenured or nursery
allocations (whereas existing tests check the number of major/minor GCs).

Depends on D121954

Attachment #9235035 - Attachment description: WIP: Bug 1562816 - Pretenur string concatenation (WIP) → WIP: Bug 1562816 - Pretenure string concatenation (WIP)
Attachment #9235037 - Attachment description: WIP: Bug 1562816 - Pretenur the result of the String constructor → WIP: Bug 1562816 - Pretenure the result of the String constructor
Severity: normal normal → S3 S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: