Skip to content
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

Add IdSet and fix IdDict performance problem #26054

Merged
merged 3 commits into from
Feb 24, 2018
Merged

Add IdSet and fix IdDict performance problem #26054

merged 3 commits into from
Feb 24, 2018

Conversation

Keno
Copy link
Member

@Keno Keno commented Feb 14, 2018

https://github.com/Keno/NewOptimizer.jl requires various sets and dicts. Since those are currently not available at inference time, I'm changing it to use IdDicts. However, until now there was no Set analogue for IdDict, so this PR provides that. Additionally, this fixes #26043, which was causing disastrous performance when using IdDicts rather than Dicts in the new optimizer.


filter!(f, d::IdSet) = unsafe_filter!(f, d)

function union!(s::IdSet{T}, itr) where T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing copy of this method should probably be expanded to AbstractSet instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@Keno Keno force-pushed the kf/idset branch 2 times, most recently from 843a2cf to cbc0be9 Compare February 14, 2018 21:03
@Keno
Copy link
Member Author

Keno commented Feb 15, 2018

CircleCI seems to have started running out of memory, but other than that, this seems good. @JeffBezanson any further review?

@vtjnash
Copy link
Member

vtjnash commented Feb 15, 2018

Can we get some local performance numbers? From Travis logs, it looks like this just over doubled the build time and increased the size by ~20-30% for the compiler, but those numbers aren't usually particularly reliable.

@vtjnash
Copy link
Member

vtjnash commented Feb 24, 2018

Alright, well, this seems to be a pre-req for #26079 now. So, bump?

@Keno
Copy link
Member Author

Keno commented Feb 24, 2018

Was just int he process of rebasing and looking at performance.

To provide an efficient `length` method.

Fixes #26043
which is as Set is to Dict. To be used in the new optimizer.
Currently unexported.
@Keno
Copy link
Member Author

Keno commented Feb 24, 2018

I see about a 1.3s increase in time to build basecompiler.ji (about 5%) and a 1% increase in basecompiler size. I think that's ok.

@Keno
Copy link
Member Author

Keno commented Feb 26, 2018

nanosoldier saw performance regressions in bitset on yesterday's nightly run (https://github.com/JuliaCI/BaseBenchmarkReports/blob/656af6a7f0e5c93b5e0fa03c9e412307c3e46531/daily_2018_2_25/report.md). This seems like the most likely candidate. Investigating.

Keno added a commit that referenced this pull request Feb 26, 2018
In #26054, I generalized `Set`'s union! method to apply to AbstractSet.
Set's union! method tries to optimize common cases where the number of
possible values of the set type are small. However, to do this, it repeatedly
calls the set's length method. This is bad for `BitSet` for two reasons:
1. Its `length` method is O(N) in the number of elements.
2. The check isn't actually useful, since the eltype of `BitSet` is always
    Int and it's impossible to have a BitSet that already contains all integers.

This simply special cases `union!` on BitSet to use the same implementation it did previously.
@cstjean
Copy link
Contributor

cstjean commented Sep 21, 2018

IdSet is not exported. Is there any reason why, or was that an omission?

@StefanKarpinski
Copy link
Member

As long as we're confident that the API is what we want, I can't see why we wouldn't export it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IdDict length function is O(N)
5 participants