-
Notifications
You must be signed in to change notification settings - Fork 19
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
pkg: Create generic AttributesStore #276
pkg: Create generic AttributesStore #276
Conversation
Rather than creating many implementations of the AttributesStore per type, let's use the new Go generic types. Starting to use this code as a library I was wondering if this was possible. Turns out it is.
@metalmatze I had thought about that at one point but I had a bad experience with Go generics in terms of performance. It might have changed (or my memory is bad), but if I remember correctly, Go generics aren't completely zero-cost. Since these attribute stores are on the hot path, I think it would be good to verify the performance impact with the command |
I'm having trouble understanding how the
Now, there's a generated.json file that can be passed to the
If I read the source code correctly, the first tool generates a file with batchSize 20. We may need many of these files. Here's the data of my run: https://gist.github.com/metalmatze/70ce17f8818c2fb8579d1c424c3bd6f4 Is |
@metalmatze Sorry, reviewing a PR on Thanksgiving evening before going to bed isn't the best idea in the world... On the substance, I still think we need to verify the performance impact, but it wasn't the right tool :-) |
Happy Thanksgiving! 🦃 Here are the results: https://gist.github.com/metalmatze/f6b635f261c4e1a017f143c4e9232d55 As you said, there are some performance hits, but you need to decide how impactful they are. I'm totally fine closing this PR if you think there's too much overhead. |
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.
The performance difference seems small enough to justify the gain in maintainability. I think this improvement can be included in the next release.
Adding @jmacd for visibility.
Thanks, @metalmatze. |
Rather than creating many implementations of the AttributesStore per type, let's use the new Go generic types.
Starting to use this code as a library I was wondering if this was possible. Turns out it is.