Open Bug 1444470 Opened 7 years ago Updated 1 year ago

JS stack capture for error disables LiveSavedFrameCache

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: jimb, Unassigned)

References

(Blocks 1 open bug)

Details

At present, capturing stacks for Error objects places a fixed limit on the number of frames captured (MaxFrames(128), [1]), which disables the LiveSavedFrameCache[2]. This seems unnecessary, and we might be able to avoid 'a lot' (data needed) of stack walking if we enabled it. I'm not sure why the cache is disabled when MaxFrames is specified. One reason could be that the stacks in the cache may be longer than the requested length. But creating a truncated stack actually makes sharing SavedFrame tails unlikely (since the root is chosen essentially arbitrarily), so this probably wastes memory, rather than saving memory. It's true that stacks truncated due to a MaxFrames limit should not be placed in the cache; subsequent lookups might be using different limits, for which cached truncated frames would be incorrect. One fix would be to change the rule for MaxFrames captures, such that if a longer stack were already cached, it would be returned. This makes MaxFrames' results a little less predictable, but it could only improve its speed and memory consumption. The long chains were going to be held alive anyway by the cache. [1]: https://searchfox.org/mozilla-central/rev/588d8120aa11738657da93e09a03378bcd1ba8ec/js/src/jsexn.cpp#362-369 [2]: https://searchfox.org/mozilla-central/rev/588d8120aa11738657da93e09a03378bcd1ba8ec/js/src/vm/SavedStacks.cpp#1379-1380
Priority: -- → P3
Severity: normal → S3

This still seems to be true.

Blocks: sm-api
Severity: S3 → N/A
You need to log in before you can comment on or make changes to this bug.