-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
PERF: Fix performance regression due to CoW ref tracking #51390
Conversation
Can we also gate the handling of refs behind the CoW mode to avoid perf regressions like these when CoW is off (not for this PR but for the future)? |
2 things are not behind CoW:
With this implementation, the more costly part is checking the ref, which is hidden behind CoW. There is no real efficient way of hiding everything (at least I can't see one right now) |
Cool, as long as adding the ref doesn't take too much fine(I don't think it would), this is fine then. |
This was cheap with the WeakSet when I checked where we spent the most time, since we are basically doing the same, I think we are good |
Certainly fine to merge this (it's basically just reverting a change that was done in the original PR, AFAIU?) One thing I am wondering: do we know if we have (sufficient) benchmarks that hit the |
Yes this is how it was implemented initially You are correct, that it slows down the has_reference check. Two points why I think this is a better idea right now:
I'll investigate this further, but wanted to get this into the rc |
Hi @phofl, I think this commit may be related to the problem at #54352. Each weakref.ref ocupies 72 bytes of memory even after it's a dead , which accumulates invisibly on tons of operations (e.g. Index.view called during df.copy). The gap is probably a little closer too if you consider the extreme case of the weakref.WeakSet() having always length 1 when the current list version keeps allocating memory. Do you think it's worth it to revert this commit? |
We can clear the list more often, that would be an approach worth considering as well |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.WeakSet caused a slowdown in these two benchmarks. Switching to a list for now, we will try to opimize this