Open Bug 1905117 Opened 8 days ago Updated 15 hours ago

Allocate more JS strings with a StringBuffer instead of raw malloc

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

ASSIGNED

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

(Keywords: leave-open)

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
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: