Open Bug 1888768 Opened 2 months ago Updated 2 months ago

AST explorer spends a lot of time in PostWriteBarrier(although we are as fast as Chrome here)

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

People

(Reporter: mayankleoboy1, Unassigned)

References

(Blocks 1 open bug, )

Details

Attachments

(1 file)

6.71 MB, application/x-javascript
Details

Go to https://astexplorer.net/
From the top bar, select "Markdown" as the input language

Copy and paste the attached sample text.

Nightly: https://share.firefox.dev/3TH9xga (5.5s)
Chrome: https://share.firefox.dev/49hsYBW

Maybe something to improve?

Attached file moz bundle.js
See Also: → 1814928
Summary: AST explorer spends a lot of time tin GCBarriers (although we are as fast as Chrome here) → AST explorer spends a lot of time in GCBarriers (although we are as fast as Chrome here)
Summary: AST explorer spends a lot of time in GCBarriers (although we are as fast as Chrome here) → AST explorer spends a lot of time in PostWriteBarrier(although we are as fast as Chrome here)

And here is a profile for a larger sample text file : https://share.firefox.dev/3xhDRGK

See Also: → 1888775
Severity: -- → S3
Priority: -- → P3

Looks like 32% of our active time is being spent in js::NativeObject::elementsRangePostWriteBarrier, which scans through a range of elements looking for the first nursery-allocated object and adds the remaining chunk of the range after it finds one. This should be fast if we're hitting quickly, so it's likely that there are few (or no) nursery-allocated objects in this range, in which case we will scan the entire range.

I haven't actually dug into the source code of the website, but it seems likely that we're repeatedly calling array.splice with a very large array. If we aren't introducing any new nursery allocations, then after the first minor GC everything will be tenured and we will do the full scan every time.

We could maybe consider capping the length of the scan that we're willing to do. For example, maybe we only scan 1000 elements, and then after that, even if we haven't found a nursery object, we add the remaining range to the store buffer. But that might just push the work to GC time instead.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: