Bug 426193 - Styler freezes forever on certain input files
Summary: Styler freezes forever on certain input files
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Editor (show other bugs)
Version: 5.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 5.0 RC1   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2014-01-20 16:24 EST by Mark Macdonald CLA
Modified: 2014-01-29 09:57 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Macdonald CLA 2014-01-20 16:24:04 EST
1. Open doctrine.js from the orion source code (bundles/org.eclipse.orion.client.ui/web/doctrine/doctrine.js)
2. The entire tab freezes and never recovers

If you remove lines 44, 45 (which each contain a 4100-character-long string literal) the file opens with no problems. If you rename it to .txt instead of .js, it also opens fine.
Comment 1 Mark Macdonald CLA 2014-01-23 15:07:39 EST
esprima.js has a similar problem. It uses the same gigantic regex strings as doctrine
Comment 2 Grant Gayed CLA 2014-01-24 14:41:48 EST
It's not actually hung, but is performing extremely slow.  RegExp evaluations get increasingly slower in Chrome as the test string gets larger (ie.- a few seconds at the 200 character mark), and the problematic lines in doctrine.js are > 4200 characters each.

For now I've released a char count check that skips over lines that are long enough to cause a noticeable performance problem.  Will continue to investigate whether a better fix can be implemented.  Commit: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=63df4903e4ee1a01d53c9a5c9356e1da74f868a5 .
Comment 3 Grant Gayed CLA 2014-01-24 17:02:27 EST
I'm reasonably sure that better performance can be achieved through better regex's (less backtracking in particular).  However with the 5.0M2 cut-off looming I'm hesitant to tinker with these because it's easy to introduce subtle problems.  Will focus on these during the 5.0RC1 period.
Comment 4 Grant Gayed CLA 2014-01-28 15:42:31 EST
Tracked the underlying issue down the regex's for JS multi-line strings, so these have been adjusted and the character count limit is now removed.  Fixed > 20140128, commit: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=5595de4ce388cd8dc3a0f11539ff885652c5c0eb .