ABC causing massive memory swell #94284
Labels
3.12
bugs and security fixes
performance
Performance or resource usage
type-bug
An unexpected behavior, bug, or error
Bug report
Your environment
Running this takes several minutes and consumes over 20 gbs of memory.
I've checked it against python 3.8-3.10. The issue is just that ABC caches every single issubclass evaluation combined with it searching its entire subclass tree recursively causes it to grind to a halt if you have any significant number of subclass 10k sub classes of ABC and 10k normal classes being compared to the base ABC climbs to over 20 GBs. I am not really sure it is necessary to check the entire subclass tree. I presume it is because of concerns about register calls happening low in the class tree.
It would likely be far more efficient to chase upward the calls to register and place those in the parent classes then to search the entire class hierarchy. This can get really aggressive performance issues if you have any multiple inheritance structures going on as well as those will get checked multiple times.
See these issues.
#92810
pydantic/pydantic#3829
The text was updated successfully, but these errors were encountered: