Skip to content

[backport] SI-7710 fix memory performance of RegexParsers in jdk7u6+ #3860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2014

Conversation

gourlaysama
Copy link
Contributor

Backport of scala/scala-parser-combinators@91584dc.

See scala/scala-parser-combinators#17.


Starting with 1.7.0_06 [1], String.substring no longer reuses the internal
char array of the String but make a copy instead. Since we call
subSequence twice for every input character, this results in horrible
parse performance and GC.

With the benchmark from the (duplicate) ticket SI-8542, I get:

BEFORE:
parseAll(new StringReader(String))
For 100 items: 49 ms
For 500 items: 97 ms
For 1000 items: 155 ms
For 5000 items: 113 ms
For 10000 items: 188 ms
For 50000 items: 1437 ms
===
parseAll(String)
For 100 items: 4 ms
For 500 items: 67 ms
For 1000 items: 372 ms
For 5000 items: 5693 ms
For 10000 items: 23126 ms
For 50000 items: 657665 ms

AFTER:
parseAll(new StringReader(String))
For 100 items: 43 ms
For 500 items: 118 ms
For 1000 items: 217 ms
For 5000 items: 192 ms
For 10000 items: 196 ms
For 50000 items: 1424 ms
===
parseAll(String)
For 100 items: 2 ms
For 500 items: 8 ms
For 1000 items: 16 ms
For 5000 items: 79 ms
For 10000 items: 161 ms
For 50000 items: 636 ms

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6924259

@gourlaysama
Copy link
Contributor Author

This is weird. Should Mima complain about adding a new package private class? Also, Mima was happy with this exact same commit in the scala-parser-combinators repository...

And as an added bonus, I don't get the same error when I run ant test.bc locally...

@gourlaysama
Copy link
Contributor Author

Ok, with ant clean build-opt test.bc, mima gives me the same error.

@adriaanm: can I whitelist that class? I am not sure of anything when it comes to mima. Or I can make it a private class in the RegexParsers trait...

@lrytz
Copy link
Member

lrytz commented Aug 12, 2014

@gourlaysama the change is binary compatible in both directions as far as I can tell, so you can add the class to the whitelist.

Backport of scala/scala-parser-combinators@91584dc.

---

Starting with 1.7.0_06 [1], String.substring no longer reuses the internal
char array of the String but make a copy instead. Since we call
subSequence twice for *every* input character, this results in horrible
parse performance and GC.

With the benchmark from the (duplicate) ticket SI-8542, I get:

BEFORE:
    parseAll(new StringReader(String))
    For 100 items: 49 ms
    For 500 items: 97 ms
    For 1000 items: 155 ms
    For 5000 items: 113 ms
    For 10000 items: 188 ms
    For 50000 items: 1437 ms
    ===
    parseAll(String)
    For 100 items: 4 ms
    For 500 items: 67 ms
    For 1000 items: 372 ms
    For 5000 items: 5693 ms
    For 10000 items: 23126 ms
    For 50000 items: 657665 ms

AFTER:
    parseAll(new StringReader(String))
    For 100 items: 43 ms
    For 500 items: 118 ms
    For 1000 items: 217 ms
    For 5000 items: 192 ms
    For 10000 items: 196 ms
    For 50000 items: 1424 ms
    ===
    parseAll(String)
    For 100 items: 2 ms
    For 500 items: 8 ms
    For 1000 items: 16 ms
    For 5000 items: 79 ms
    For 10000 items: 161 ms
    For 50000 items: 636 ms

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6924259
@gourlaysama
Copy link
Contributor Author

@lrytz done :)

@gkossakowski
Copy link
Contributor

LGTM

gkossakowski added a commit that referenced this pull request Aug 19, 2014
[backport] SI-7710 fix memory performance of RegexParsers in jdk7u6+
@gkossakowski gkossakowski merged commit ac7e102 into scala:2.10.x Aug 19, 2014
@gourlaysama gourlaysama deleted the wip/t7710-backport branch August 26, 2014 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants