-
-
Notifications
You must be signed in to change notification settings - Fork 57
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 memory usage by reordering fields #299
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.
TIL
a44aa13
to
0534dcc
Compare
What do you think about the Makefile change @ccoVeille @dylanhitt ? It makes |
Yes I like it. Will say maybe we shouldn't be installing things on people machines so implicitly. I tend to use like a |
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.
I don't think anything like this is needed.
You are building an API service, with OpenAPI features.
Here it's about optimizing bytes of memory on a framework, that stay still between 2 API calls.
If someone needs memory efficient solution, I'm afraid to say they will never use a framework like fuego, I mean any framework.
I would like to discourage you to go in this direction that is making the struct less readable. Fields are no longer grouped by feature. The maintenance will be a pain.
For me it's pure "oh it's good feature we should try"
So unless you have a benchmark that shows a change of at least 20% I'm term of speed or memory consumption, I would say NOGO
wait a minute what? I'm sorry, but I don't follow.
A fuego context and fuego response is gonna be created on every API call for some using this framwork? If i have an API with 1000 concurrent calls (which I do). You're allocating a context for all 1000 api calls. |
Like this struct alone could be created |
I'm sorry. I didn't expect my reply to lead to such reactions. Is fuego highly optimized for ultra fast performance? I cannot tell. The recent PRs I reviewed were about adding feature, not about looking for insane performance I'm not saying the changes in this PR have no consequences at all. It's proven, known, documented, there are linters about it. My point is "are they noticeable?" on fuego. But will it has a consequence of server bills? A noticeable consequence on performance? What I can see is the consequence on readability/maintainability. You talked about an allocation on every http calls, but what is it compared the cost in memory of receiving and returning the HTTP messages ? For me such optimization should be on compiler side. But it isn't unfortunately. Also, such optimization provides an easy fix for small memory optimization. But this is far from being a way to improve a framework performance. It's very good optimization when dealing with millions of data to sort in memory, yes. But here, I'm doubtful. That's why I asked for benchmarks. If you think the readability is still OK after such "optimization", why not. |
Again I'm not really understanding your point here either. This would be entirely on the user using fuego. We won't know their body or requestbody it's up to them to optimize their own structs. The best we can do is optimize what we can control when someone wants to squeak out some performance where they can. |
And to answer readability. No I don't really see an impact/maintenance over grouping struct fields. If we really cared so much about this I would much rather focus on better commits/concise PRs than I would the grouping of the struct. Git can at least tell a story. |
I apparently fail to explain why I think (hypothesis) it will have quite no consequences on the end user. At the same time, I think that I'm getting you upset or disappointed, because of what I said, I'm sorry about that. Also, you think it could (here another hypothesis) have noticeable consequences for the performance. I conceeded there will be improvement, my point is about the fact I don't think the could be noticed. I can be wrong, and it won't be a problem to me. I asked for a benchmark, because I would like to get something that can be checked/compared. Maybe @EwenQuim can tell what he thinks about it. Maybe he made a benchmark |
I'm not upset or disappointed. I'm just not understanding the point being made. I don't know what
When I read that it sounds like you're saying is that "the code in fuego really only is responsible for 2 API calls so why optimize"? I do agree that the majority of the optimization is really dependent on our users. Fuego specifically
vs this branch
So ~16 Bytes per request. |
Thanks for doing the benchmark. |
Don’t worry @ccoVeille, everything is all right! I understand this approach might be cumbersome for readability in most cases, so I’ll remove changes for most structs and the linter. No more forced alignement! However, it still makes sense to optimize memory usage for certain structs, especially |
26b1894
to
43b404a
Compare
Just a dumb PR to reduce memory usage and improve performance by simply realigning struct fields.
I can't believe this has to be done manually—obviously, the compiler should handle it.
This also enables all govet linters in the CI (including the
fieldalignment
check).We'll wait for #285 to see the improvement or lack thereof.