Closed Bug 1367878 Opened 7 years ago Closed 2 years ago

RegExp handling shows up in Facebook profile

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INCOMPLETE
Performance Impact low

People

(Reporter: smaug, Unassigned)

Details

(Keywords: perf)

No longer blocks: 1366960
Blocks: 1366960
Whiteboard: [qf]
Whiteboard: [qf] → [qf:p1]
js::irregexp::CompilePattern takes 133ms (mostly js::irregexp::*::Emit), and as far as I know, this code is not interruptible as of today. I see 2 "simple" ways to approach this problem, which both have pitfalls: 1/ We could add checks to call the interruption callback in the *::Emit functions, such that we can stack event loops, but we would add JS race issues in facebook. 2/ Quantum DOM would save us by making sure we can switch between multiple threads, but this would not solve the 133ms facebook-only pause. Does this issue exists also in Chrome, or did they changed irregexp to better handle this parsing issue?
Flags: needinfo?(bugs)
Bobby, do we have some way to capture some kind of profiles on Chrome?
Flags: needinfo?(bugs) → needinfo?(bchien)
A native profiler should be usable to profile Chrome manually if someone wants to verify whether they hit the same irregexp code or not.
Last time I tried, Chrome builds didn't have symbols included.
(In reply to Olli Pettay [:smaug] from comment #2) > Bobby, do we have some way to capture some kind of profiles on Chrome? Mike, could you help Olli to capture the profiles? Thanks.
Flags: needinfo?(bchien) → needinfo?(mlien)
(In reply to Bobby Chien [:bchien] from comment #5) > (In reply to Olli Pettay [:smaug] from comment #2) > > Bobby, do we have some way to capture some kind of profiles on Chrome? > > Mike, could you help Olli to capture the profiles? Thanks. We only have Chrome's tracing log, e.g., https://tinyurl.com/mzen5lo, and just like Olli mentioned it doesn't have symbols.
Flags: needinfo?(mlien)
71ms was spent in js::irregexp::NativeRegExpMacroAssembler::BindBacktrack which has a linear search, this seems something we can improve. I'll check how it behaves usually.
(In reply to Ting-Yu Chou [:ting] from comment #7) > 71ms was spent in js::irregexp::NativeRegExpMacroAssembler::BindBacktrack > which has a linear search, this seems something we can improve. I'll check > how it behaves usually. Hmm, I don't see this symbol from the profile that I just captured on Nightly 20170710100245.
I didn't see this in either Firefox nightly or in Google Chrome profile (by searching for regexp in the profiled native stack). Also given the reported number in bug 1366960 (76% = 172 ms), I think the regular exception processing happens long *after* the chat tab is opened and doesn't slow down the opening of the tab. It does jank the browser, but it's a separate issue. We should unblock 1366960.
unblock per comment 9.
No longer blocks: 1366960
Whiteboard: [qf:p1] → [qf:p2]
Keywords: perf
(In reply to Nicolas B. Pierron [:nbp] from comment #1) > js::irregexp::CompilePattern takes 133ms (mostly js::irregexp::*::Emit), and > as far as I know, this code is not interruptible as of today. > > I see 2 "simple" ways to approach this problem, which both have pitfalls: > 1/ We could add checks to call the interruption callback in the *::Emit > functions, such that we can stack event loops, but we would add JS race > issues in facebook. > 2/ Quantum DOM would save us by making sure we can switch between multiple > threads, but this would not solve the 133ms facebook-only pause. > > Does this issue exists also in Chrome, or did they changed irregexp to > better handle this parsing issue? Would it be possible to do the irregexp jit-compile in the background and use the VM-based regexp impl until then? Siimilar to how we background Ion-compilation?
Sean can you take a look to see if there is something we can do here? Do we need to update our fork from Chrome's
Flags: needinfo?(sstangl)
Whiteboard: [qf:p2] → [qf:p3]
We should first check if this is still a problem; I fixed a number of regex-related perf issues this year. If it still shows up we can look at a profile to see where we're spending our time.
Performance Impact: --- → P3
Whiteboard: [qf:p3]
Flags: needinfo?(sstangl)

We've updated our regexp import (multiple times since), and 5 years is a long time in Facebook time... if it shows up again, let's open a new bug.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.