-
Notifications
You must be signed in to change notification settings - Fork 144
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
[FIX] Change to old withCrLf for better performance #1722
base: master
Are you sure you want to change the base?
[FIX] Change to old withCrLf for better performance #1722
Conversation
reduces time from 9 to 4 sec :-) |
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
Outdated
Show resolved
Hide resolved
if (length == 0) return string; | ||
|
||
/* | ||
* Check for an LF or CR/LF and assume the rest of |
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.
This check could also be left away. Especially since it does not work with partly mixed delimiters and does not improve performance either.
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 sure about that one. If there is a really long text with correct line breaks (\r\n) this will save some time. For example withCrLf("\r\n".repeat(100_000_000));
.
On the other hand, as you said, this is not working with partly mixed delimiters. So I'm not really sure how to proceed here.
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 sure about that one. If there is a really long text with correct line breaks (\r\n) this will save some time.
did you measure it? Anyhow Functional correctness beats performance requirements
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.
Using withCrLf("\r\n".repeat(100_000_000));
results in a noticeable performance difference: the operation takes 13ms with the check and 1382ms without it. Given that most strings passed to Display.withCrLf are likely already correctly formatted with proper line breaks, this optimization could significantly impair the overall performance of Eclipse.
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.
13ms with the check and 1382ms without it.
that sounds like a big difference, but its only that fast because the check stops at the first occurrence. the following handling of the String however will still need to walk through the entire string so that in the broader context it may not be a hotspot but negligible
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.
Yes exactly. This only saves time for already correctly formatted strings. I removed the check, it's still better than the regex/replaceAll version.
I would suggest to merge it without the check and if we see that it impairs the performance we can change it.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
Show resolved
Hide resolved
38cec61
to
4cc6304
Compare
c00f633
to
1f6d70c
Compare
1f6d70c
to
277c39c
Compare
Test seems to be unrelated, but I'm not sure... |
Changing back to the old withCrLf coding. Regex is causing performance issues. Furthermore, handling of mixed \n and \r\n is improved. Fixes: eclipse-platform#1718
277c39c
to
a0af9a4
Compare
Changing back to the old withCrLf coding. Regex is causing performance issues.
Furthermore, handling of mixed \n and \r\n is improved.
Fixes: #1718