-
-
Notifications
You must be signed in to change notification settings - Fork 45
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 memory usage: from atproto import Client #316
Comments
Just this part seems to be responsible for 85MiB
|
Thank you for your report. Here is why it happens: pydantic/pydantic#6620 (comment) TLDR: pydantic copies some stuff into the rust side and it consumes memory; upgrade to the latest pydantic So nothing I can do from my side IMO. You can try to load only the necessary models for your project if the memory usage is critical. |
Validation or having access to models is not critical at all or necessary in my use case. The less memory I can use, the better. Given my limited understanding on how to use your library, I'd love to get some recommendations on how load only minimal amount of models, if any. All I am trying to do is to use API for posting by following your README, which suggests importing Client. Importing Client in turn executes the following line of code, which seems to be the one of the culprits: atproto_client/models/init.py
Also, latest pydantic v2.6.4 is added to my project via dependencies, I have no direct use of it otherwise. |
The current situation is even worse. I tried your commands and it gives me ~170mb on Even when model rebuilding (in A little about TL;DR: I think there is no way to fix it from our side except migrating from pydantic to something else. upd:
pydantic`s model rebuild: https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_rebuild |
I've created a separate isolated repository that contains pure models without additional noise and asked pydantic team about the amount of consumed memory here: pydantic/pydantic#9982 |
is there any solution here @MarshalX ? The reproduction repo has no solution neither the issue created in pydantic. Any idea how to make it work while pydantic fixes the memory issue? |
@toughyear I do not think that this is possible to fix without effort from pydantic team :( |
appreciate the quick response @MarshalX ! |
Merely adding the following line to an empty python script makes memory usage to jump from 0 to 100+MiB:
Tested using the following command on WSL2, python 3.10.6:
(see memory profiler, section: Time-based memory usage)
The text was updated successfully, but these errors were encountered: