-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Automatically disable http client tracing / logging when approaching memory limit #45974
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
Comments
I agree that this can be a problem. Especially when writing cli code such as daemons, batch jobs, migrations or such, which can do a huge amount of calls. Otoh I am not too sure about the proposed solution: I think that either a dev has the need to trace all calls, or he does not need the trace at all. Often one is interested in call nr. 357.432 out of 1.000.000, but without knowing its exact position in advance. We might of f.e. start spooling to disk as soon as close to memory_limit, but A) that is not a safe science. There is always the risk of going over it by fetching data, and B) even disks get full |
We could go with a FIFO approach for traces, with a buffer of eg 10000 items max. That would apply to any collection of data collected for the profiler. |
Thank you for this suggestion. |
Lets keep it open |
Thank you for this suggestion. |
Just a quick reminder to make a comment on this. If I don't hear anything I'll close this. |
Keep |
Thank you for this suggestion. |
I think this is still open - https://symfony-devs.slack.com/archives/C3EQ7S3MJ/p1705526254152239 |
Thank you for this suggestion. |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Description
I consume API responses in parallel that can be very big and also multiplex the response handling using the Symfony HTTP client which works great. You can run into memory limits easily which is understandable and which I can tune by selecting which request/responses to process in parallel. This is under my control.
But I've noticed that the even bigger problem for the memory limit is the tracing of the profiler and the SQL logger in the dev environment. So things can easily work in prod mode but in dev mode even twice the amount of memory won't be enough. This is kind of annoying and makes it hard to estimate how much memory is needed or how to tune things when developing.
There are two memory offenders:
This does not seem to work anymore since Introduce logging middleware doctrine/dbal#4967 which always logs the sql statements.
So even if there were workarounds for these problems, it still requires alot of debugging and manual solutions.
I think it should be possible to have good profiling and logs while not overdo it to prevent out of memory issues.
What I would propose:
The http client and the cache component would measure the memory consumption in debug mode when doing http requests or inserting cache items and if the used memory is approaching the memory limit, then they should automatically disable content tracing and logging for those items. Or it could at least truncate the data.
This approach would probably also work for other parts of the dev profiling. As the http client and cache can process large amounts of data, I think this is a good first step.
The text was updated successfully, but these errors were encountered: