-
Notifications
You must be signed in to change notification settings - Fork 44
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
Optimize clone method #187
base: main
Are you sure you want to change the base?
Conversation
💚 CLA has been signed |
Thanks for pointing this out! I'm setting up some benchmarks to see how this compares to the current version. |
Thank you please let me know if I can help any way. |
I've done some benchmarks and the results seem odd. All the CPU numbers are neutral-leaning-higher with the new code. I've taken profiles and confirmed that everything is using the new optimized stdlib, and it does save ~10% of copying time (~1% of overall cpu in the benchmarks I ran), but then it loses that time back in increased GC costs. The reported CPU reduction in the stdlib change is more like 85%, so this is a pretty big mismatch. I'm going to do some more testing to try and track this down. One thing to add to the PR, though: the baseline version of |
Thanks @faec for looking into it, I'm curious about what tests you have run. So far I have only used Go's framework for benchmarking and pprof library. If you could point to articles or tools that you're using or referring to, it would be a great help to my learning. Also thanks for pointing out behavior mismatch. I'll add a nil check to maintain the current behavior. |
What does this PR do?
This PR improves the performance of the Clone method for the M type in
mapstr
package.It uses an inbuilt method for cloning maps which is more efficient.
ref: golang/go#58740
Why is it important?
This change is important as the Clone method is used before applying processors in the beats repo each time.
This small optimization will improve the performance of the Beats pipeline by a substantial margin.
Checklist