-
Notifications
You must be signed in to change notification settings - Fork 93
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
Improve XML scanner memory #1206
Conversation
Signed-off-by: azerr <azerr@redhat.com>
This PR improves the XML scanner memory by using static int fields pattern instead of creating for each parse the int array pattern. If you run https://github.com/eclipse/lemminx/blob/master/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/performance/XMLScannerPerformance.java you can see the memory which takes around 200MB to parse the large file: If you start this XMLScannerPerformance inmaster branch, it takes around 300-400MB: |
@@ -126,7 +126,7 @@ public boolean advanceIfChar(int ch) { | |||
return false; | |||
} | |||
|
|||
public boolean advanceIfChars(int... ch) { | |||
public boolean advanceIfChars(int[] ch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a perf penalty when declaring varargs here? You could still call stream.advanceIfChars(END_COMMENT_PATTERN) with an actual array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer updating to int array to force to use of static array. If we let varargs, it means that we could not define static array for future improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok fair enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not tested but LGTM
Thanks @fbricon ! |
Improve XML scanner memory
Signed-off-by: azerr azerr@redhat.com