-
Notifications
You must be signed in to change notification settings - Fork 478
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
Performance: Escape fields and keys more efficiently #424
Conversation
…g.replace twice per value.
Codecov Report
@@ Coverage Diff @@
## master #424 +/- ##
============================================
+ Coverage 84.86% 84.98% +0.11%
- Complexity 270 274 +4
============================================
Files 19 19
Lines 1183 1192 +9
Branches 119 121 +2
============================================
+ Hits 1004 1013 +9
Misses 118 118
Partials 61 61
Continue to review full report at Codecov.
|
Any numbers about performance improvements ? |
I used jvmtop (https://github.com/patric-r/jvmtop) as a simple profiler. Profiling our application resulted in 14-15% of CPU time to be used in closure |
Another very simple test can be done by executing the following testcase in It creates 2M different lineProtocol Strings in a loop of 1M, single threaded, having to escape 7M keys and 2M values Execution time on my laptop without this merge request: ~7.2sec vs. with merge request: ~1.8sec.
|
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.
looks good to me, just two formatting changes required.
@@ -182,7 +176,7 @@ public Builder fields(final Map<String, Object> fieldsToAdd) { | |||
/** | |||
* Add a time to this point. | |||
* | |||
* @param timeToSet the time for this point | |||
* @param timeToSet the time for this point |
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.
reset this formatting
@@ -205,8 +199,8 @@ public Point build() { | |||
point.setFields(this.fields); | |||
point.setMeasurement(this.measurement); | |||
if (this.time != null) { | |||
point.setTime(this.time); | |||
point.setPrecision(this.precision); | |||
point.setTime(this.time); |
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.
same here
Under heavy load a profiler shows that calling
String.replace()
inFIELD_ESCAPER
orKEY_ESCAPER
is significantly slower than escaping manually by writing directly into the currentStringBuffer
.This pull request does not change behavior but only execution speed