-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Enable manual shrinkage of Dict #45004
Conversation
return d | ||
end | ||
rehash!(d, newsz) | ||
newsz = _tablesz(cld(3 * newsz, 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_tablesz
seems necessary not to rehash for newsz
leading the to same 2^x size.
end | ||
rehash!(d, newsz) | ||
newsz = _tablesz(cld(3 * newsz, 2)) | ||
return newsz == oldsz ? d : rehash!(d, newsz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worthwhile to make this a ranged check for newsz > oldsz * 2 || newsz < oldsz \div 2
, So we only resize if it is significantly different from the size it already is? Otherwise, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be significantly different since it goes through _tablesz
now (rounded to 2^x), as I highlighted in the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, now I understand the comment better. The _tablesz
means it is a power-of-2, so it is either exact, or it is different by a least a power of 2.
Bisected this commit seems to have introduced the regression within |
This reverts commit 8c61f40.
Based on the discussion in #44778, there seems to be no reason to disable manual shrinkage of
Dict
by callingsizehint!
any more. The only counterintuitive side effect (I'm aware of) is that merging two sparseDict
s may lead to a single denser one because ofjulia/base/abstractdict.jl
Lines 218 to 222 in 6106e6c