-
Notifications
You must be signed in to change notification settings - Fork 445
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
tracer: align structs #2286
tracer: align structs #2286
Conversation
Thanks for working on this! Are there any plans for quantifying the memory improvements this might give us? Are we planning to enforce or strongly encourage struct alignment optimizations going forward? If yes, do we have a plan for that? No worries if we don't have a full plan here. I'm mostly curious, not looking for reasons to push back on this. |
Thanks for the comment @felixge! Detailed documentation of memory enhancement can be found in the attached Jira ticket.
Regarding automating struct alignment optimizations, one concern is that running |
Awesome, thank you so much. Those numbers look promising! What I'd also be curious about is how this translates into memory usage at runtime. Is there any plan do some testing around that?
I think for the vast majority of structs the alignments doesn't matter because we don't create enough instances of them. So enforcing this across the code base in CI doesn't seem necessary unless it's really easy and convenient to setup. As far as ensuring we don't regress on the structs where it matters: That would be nice to have, even if it's just a CI check that complains if a struct goes from optimal alignment to non-optimal alignment. Is that doable? Also: I'm very curious about the motivation for doing all of this. IIRC we had some wins with improving alignment on some key structs (TODO: link), but I'm not sure why we're now looking to do it for all the structs? Again, I'm not against it, just trying to follow along out of curiosity :) |
I talked to the team and we can do benchmark testing to see how memory usage changes before and after this change. Will give an update when the numbers are available!
I enabled the govet in the linter with d305a5c, now the check annotations for potential improvements are available
Let me know if you have other questions! |
Awesome! Thanks for enabling the annotations, that's fantastic 🤩 |
Closing this PR as we are moving all V2 related changes to point against |
What does this PR do?
Use fieldalignment tool to reorder struct fields in ddtrace/tracer, minimize the size of the struct in memory.
Fixed corresponding tests.
Note that two structs inside
ddtrace/tracer
are not reordered because of readability concern: startupInfo and groupedStatsMotivation
AIT-8461
Reviewer's Checklist
For Datadog employees:
@DataDog/security-design-and-guidance
.Unsure? Have a question? Request a review!