Closed Bug 1905117 Opened 1 year ago Closed 1 year ago

Allocate more JS strings with a StringBuffer instead of raw malloc

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(5 files)

I have some patches that add support for StringBuffer to JSString::OwnedChars, and then uses this to allocate more JS strings with string buffers instead of raw malloc.

This patch adds a usesStringBuffer argument to checkStringCharsArena so that
we can have this check and comment in one place.

This adds an enum to OwnedChars to make it easier to add a new kind of allocation in
the next patch.

Also removes the new_ and newValidLength overloads that were added for string
buffers because we can now use the OwnedChars version.

If there are more than 500 bytes of string data, use a StringBuffer instead of raw malloc.
This helps avoid memory usage regressions because for shorter strings StringBuffer has
relatively more overhead.

Keywords: leave-open
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/15b620ae11bf part 1 - Tidy up checkStringCharsArena checks. r=sfink https://hg.mozilla.org/integration/autoland/rev/1e290c561e40 part 2 - Refactor OwnedChars to prepare for StringBuffer support. r=sfink https://hg.mozilla.org/integration/autoland/rev/ee041ddb584c part 3 - Add StringBuffer support to OwnedChars. r=sfink
Severity: -- → N/A
Priority: -- → P2

This avoids some regressions on a few Speedometer 3 (async) sub tests.

The problem is likely more jemalloc lock contention during GC when using the
main malloc heap. Using SpiderMonkey's string buffer arena avoids that and
matches previous behavior better.

Ill let the sheriffs confirm, but this change appear to have caused 15% regressions on some tests: https://treeherder.mozilla.org/perfherder/alerts?id=995&hideDwnToInv=0

Regressions: 1906352
Keywords: leave-open
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6fe78640acb3 part 4 - Allocate a StringBuffer in AllocChars for longer strings. r=sfink https://hg.mozilla.org/integration/autoland/rev/0584adf37451 part 5 - Use JS string arena for StringBuffers allocated in SpiderMonkey. r=sfink,emilio
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch
Whiteboard: [sp3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: