-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
High CPU usage after upgrade #445
Comments
Interesting. That's quite a large upgrade though, a ton of things have changed. Are you using You can likely resolve your issue by switching to |
I am using
Will try |
BaseConverter won't help if you're using Well, the root issue is that you're probably recreating the same class a lot in your tests. Let me give you some context. But if you, for example, have a test that recreates the same class (or a converter) over and over again, you'll effectively create a leak there since all this source code will keep getting stored there, and To me this indicates an inefficiency in your tests, any chance you could not generate so many converters or classes and hooks? Even if I worked around this in cattrs, it's still kind of bad practice. That said, import linecache
print(linecache.cache) |
Yes, I tried to avoid recreation of classes/converters at some places and it helped a bit but still there are places where I can't get rid of them. I was going through
Do we need this in case of |
Hm, you might be right. We can put that into the It might not help though. If you have classes that you can't control they'll enter that You're just recompiling the exact same handlers over and over again, right? So the source code will be identical every time. I'm thinking there could be an optimization opportunity here where we could look for the |
Okay. In middle of something, won't be able to raise it today. Please see if you can else I will take a look later. Thanks |
Try this branch: https://github.com/python-attrs/cattrs/tree/tin/linecache-opt |
Yes It is working now. Thank you for quick responses & optimisations. |
Cool, will release this soon. |
We are using cattrs for config validation purpose of our tests in Asynchronous framework. Thousands of tests run every minute. We upgraded from 1.5.0 to 23.1.2 which has major changes on how cattrs back-end works. The cpu touches 100% in couple of mins. After profiling we found that cache (linecache) was the reason for high cpu usage. We disabled the caching (including detailed validations) with
_cattrs_use_linecache=False
which helped a bit, now it takes couple of hours (3-4h) to reach cpu to 100.We see
generate_unique_filename
is still taking lot of time.Is there any other way to handle this in cattrs latest version?
The text was updated successfully, but these errors were encountered: