Closed
Bug 921176
Opened 11 years ago
Closed 6 years ago
Share JSRuntime::staticStrings between runtimes
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 964059
People
(Reporter: terrence, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [MemShrink:P3])
JSRuntime::staticStrings is a mapping from small integers to the atom for that integer. This is a fast path for int->atom->id conversion during getElement. This table is currently 36KiB, stored inline in the JSRuntime. For B2G and workers, we should be able to easily save a bunch of memory by reducing the size of this table at the cost of extra overhead for a larger number of indexed accesses using small numbers.
Updated•11 years ago
|
Whiteboard: [MemShrink]
Updated•11 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P3]
Comment 1•11 years ago
|
||
JSRuntime::staticStrings is identical for every JSRuntime, right? Is there some way to share it among runtimes?
Comment 2•11 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #1)
> JSRuntime::staticStrings is identical for every JSRuntime, right? Is there
> some way to share it among runtimes?
I don't know much about it, but I felt that it was lazily filled by the parser.
Comment 5•11 years ago
|
||
The runtime's static strings and common names are not identical for every runtime, since the atoms in them are specialized on that particular runtime. If we were able to share atoms between runtimes (bug 964059) then the tables would be identical and we could use a single set for all runtimes.
Depends on: 964059
Comment 6•11 years ago
|
||
How are static strings not identical between runtimes? I can't see how they would differ. ("Common names" might differ; I don't know what those are.)
Having a global static strings table instead of one per runtime is definitely a good idea. I'm much more wary about shrinking the number of elements in the static strings table -- we currently don't use static strings as much as we could. I've seen about:memory results where we have MBs worth of single-char ASCII strings, which really should be handled via static strings, and I'm planning to try to get them used more, because it will save memory and reduce pressure on the GC.
Comment 7•11 years ago
|
||
The contents of the strings are the same, but the physical pointers are different. If we shared a table between runtimes right now then one runtime could have pointers to another runtime and potentially run into trouble (races, crashes, ...) when e.g. that other runtime is doing an incremental GC. Some more in bug 964059. Now, this case is likely simpler than that bug since the static strings can't actually be collected, but since 964059 subsumes this and makes additional improvements to memory usage it seems better to me to do that one and then get this for free rather than doing this one separately.
Comment 8•11 years ago
|
||
Great! Sharing the table between runtimes would be great. Making the table smaller (as comment 0 suggested) would not be great, IMO. I've changed the bug title accordingly.
Summary: Minimize JSRuntime::staticStrings on B2G and workers → Share JSRuntime::staticStrings between runtimes
Assignee | ||
Updated•10 years ago
|
Assignee: general → nobody
Comment 9•6 years ago
|
||
Is this implemented now? I saw a comment that said that permanent atoms are now shared between runtimes, and I assume static strings fall under that category.
Flags: needinfo?(jcoppeard)
Comment 10•6 years ago
|
||
Yes, this happened in bug 964059 (note this didn't end up sharing all atoms as implied by the title).
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(jcoppeard)
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•