-
Notifications
You must be signed in to change notification settings - Fork 138
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
Introduce benchmark for the smallIntegerValueCache
#2936
Introduce benchmark for the smallIntegerValueCache
#2936
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.
Can you please also post the results for the two benchmarks?
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.
Thank you for adding the benchmarks!
Something seems off in the cached version, either in the benchmark or the reporting for it:
BenchmarkSmallIntegerValueCache-10 456 2576811 ns/op 46 B/op 0 allocs/op
BenchmarkIntegerCreationWithoutCache-10 368 3275893 ns/op 4089900 B/op 204002 allocs/op
How come the cached version has 0 allocations? I'd expect it to allocate less, but at least something
Using the value, e.g. by calling Sprintf, the results look a bit better and show the cache saves quite some allocations and isn't slower 👍 |
Co-authored-by: Bastian Müller <[email protected]>
@SupunS Added the results on my machine as well in the description. The cache does seem to help. @turbolent Had to use |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/range-type #2936 +/- ##
===================================================
Coverage 79.63% 79.63%
===================================================
Files 336 336
Lines 79754 79754
===================================================
Hits 63511 63511
Misses 13875 13875
Partials 2368 2368
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Very nice to have cache for small integers. 👏
It is optimized to use register there probably. |
@turbolent @SupunS Shall we merge this? The results look fine and I think it'll be nice to check-in the 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.
Looks good!
My only concern is the sprintf()
call is affecting the benchmark numbers quite a bit (i.e: sprintf is more expensive than the number creation). But seems there is no other way to avoid optimizing away.
I don't think we need to merge this in actually, the benchmarks were just a means to see if the caching approach is worthwhile. We usually have benchmarks checked in for things we do not want to regress performance on, as well as like Supun pointed out, the benchmarks are tricky to get right / are not ideal in the current form. It was still very valuable to have these benchmarks to give us data to make decisions 🙏 |
Work towards #2871
Description
Introduces benchmark for the
smallIntegerValueCache
.Results on my machine
Without Cache
Command:
go test -benchmem -run=^$ -bench ^BenchmarkIntegerCreationWithoutCache$ github.com/onflow/cadence/runtime/interpreter
With Cache
Command:
go test -benchmem -run=^$ -bench ^BenchmarkSmallIntegerValueCache$ github.com/onflow/cadence/runtime/interpreter
master
branchFiles changed
in the Github PR explorer