-
Notifications
You must be signed in to change notification settings - Fork 712
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
Custom encoder for latest maps #1709
Conversation
What did you use to test this? It may be worth experimenting with but after looking at profiles from the service most of the CPU is consumed in I saw a two potential small improvements though:
|
return | ||
} | ||
|
||
length := r.ReadMapStart() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
- Cuts out intermediate type - Should be backwards compatible with existing reports.
ed4c66d
to
8628554
Compare
I've stuck this on the service-scope-app instance on dev. Gathered a before and after profile. Before:
After
A modest improvement then, not as much as I'd hoped for. ConstMap should still help I hope. |
Interestingly the overall effect is larger than I thought it would be, almost 10%: before:
after:
|
//m.Map.ForEach(func(key string, value interface{}) { | ||
// r.EncodeString(1, key) | ||
// encoder.Encode(value.(LatestEntry)) | ||
//}) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
I notice that we already have benchmarks for this code in |
Very glad to see there are already tests for latest_map encode & decode. Thanks for the patch. It's great to see quantifiable performance improvements. Please ping me when you're done responding to comments. |
I don't think so
No
TBH I've not found the benchmarks to be particularly useful. |
@jml PTAL |
If this is the common experience then perhaps we should delete them. Not for this PR though. Thanks, |
@tomwilkie Did you make multiple measurements? Note that load balancing is not uniform right now, so it could be that simply the load balancing changed after re-deploying (I have experienced this when making my own measurements). |
I did not, so take the measurement with a pinch of salt. Although I suspect unequal load balancing would have move than 10% difference. And load balancing is better than we think (I think). But all performance measurements should be taken with a pinch of salt. |
Implement a custom encoder for latest maps, instead of round tripping through a temporary map.
In a very unscientific test, LatestMap decoding went from about 5% CPU to nothing (it was unmeasurable).See below for better numbersAs it stands, this change won't be backward compatible. But if we like this approach, it can be made so with a little work.Is now backwards compatible. Have not implemented optimised encode - which prove this.