-
Couldn't load subscription status.
- Fork 3.9k
ARROW-6458: [Java] Remove value boxing/unboxing for ApproxEqualsVisitor #5304
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
Conversation
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.
@liyafan82 I think this change should probably be broken into two different changes. One that avoid boxing/unboxing and a second one that consolidates code. The code consolidation has the potential to actually hurt performance. As part of the boxing/unboxing we should also introduce a performance test to verify it actually improves performance (which can then be used to measure the impact of the code consolidation behind the interface).
It is a good suggestion to split into two issues for the two problems. I will revise the code and provide the performance benchmark accordingly. |
530aa0a to
4ce7f8d
Compare
|
@emkornfield I have split the issue into two, according to your suggestion. Performance benchmark show that there is a performance improvement of over 10%: Before: After |
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.
please add float4 vectors as part of this benchmark.
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.
Sure. I will add benchmarks for float4 to class Float4Benchmarks.
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.
Please consolidate into 1 floatbenchmarks class and a single benchmark. (reasoning behind this: http://insightfullogic.com/2014/May/12/fast-and-megamorphic-what-influences-method-invoca/)
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.
Sure. Thanks for the article. We have also found some problems with megamorphic methods in the current code base. Will improve them later.
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.
For things not on the hot path it probably isn't worth changing. The only reason I'm bringing it up here is because the code seemed to already written to avoid those calls. If there are a lot of places you intend to fix then having a discussion on the mailing list would be a good idea.
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.
Sure. Sounds reasonable.
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 think this change is too much, I think the right thing to do is introduce an interface is to change DiffFunction into two interface.
DiffFunctionFloat {
bool approxEquals(float v1, float v2);
}
DiffFunctionDouble {
bool approxEquals(double v1, double v2);
}
and
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 see. Will revise accordingly.
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.
@emkornfield
I have revised the code to make the changes smaller.
And I have merged the benchmarks to a single class and a single benchmark, according to your suggestion.
The benchmark results are as follows:
Before:
FloatingPointBenchmarks.approxEqualsBenchmark avgt 5 14.480 ± 0.023 us/op
After:
FloatingPointBenchmarks.approxEqualsBenchmark avgt 5 13.517 ± 0.041 us/op
By removing boxing/unboxing, we have a performance improvement of about 6.7%
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.
See comments.
4ce7f8d to
ce46bcf
Compare
ce46bcf to
907c17d
Compare
Codecov Report
@@ Coverage Diff @@
## master #5304 +/- ##
==========================================
+ Coverage 88.59% 89.57% +0.98%
==========================================
Files 950 702 -248
Lines 126185 107156 -19029
Branches 1495 0 -1495
==========================================
- Hits 111791 95990 -15801
+ Misses 14029 11166 -2863
+ Partials 365 0 -365
Continue to review full report at Codecov.
|
|
+1, thank you. |
As discussed in apache#5195 (comment), there are some problems with the current ways of comparing floating point vectors, we solve them in this PR: 1. there are if statements/duplicated members in ApproxEqualsVisitor, making the code redundant and less clear. 2. the comparion of float4 and float8 are based on wrapped objects Float and Double, which may have performance penalty. Closes apache#5304 from liyafan82/fly_0905_float and squashes the following commits: 907c17d <liyafan82> Remove value boxing/unboxing for ApproxEqualsVisitor Authored-by: liyafan82 <fan_li_ya@foxmail.com> Signed-off-by: Micah Kornfield <emkornfield@gmail.com>
As discussed in #5195 (comment), there are some problems with the current ways of comparing floating point vectors, we solve them in this PR: