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

Keep track of number of set elements in map #33

Merged
merged 1 commit into from
May 7, 2017

Conversation

jonhoo
Copy link
Contributor

@jonhoo jonhoo commented Apr 13, 2017

This allows much more efficient versions of len() and is_empty(), and also enables ExactSizeIterator to be implemented for VecMap's iterators.

Fixes #32

This allows much more efficient versions of len() and is_empty(), and
also enables ExactSizeIterator to be implemented for VecMap's iterators.

Fixes contain-rs#32
@Gankra
Copy link
Contributor

Gankra commented Apr 16, 2017

Could you add some more test cases to make sure all your changes are right? One thing off the top of my head: read some elements from the iterators and check that size_hint updates accordingly.

@jonhoo
Copy link
Contributor Author

jonhoo commented Apr 17, 2017

@Gankra
Copy link
Contributor

Gankra commented Apr 17, 2017

Oh wow, haha great! That's what I get for reviewing while falling asleep!

Lemme just double check with some people before hitting merge.

@Gankra
Copy link
Contributor

Gankra commented Apr 17, 2017

hey @kbknapp you (clap-rs) seem to be the biggest user of VecMap; any thoughts on whether this would improve your use case, or just add overhead?

@kbknapp
Copy link

kbknapp commented Apr 19, 2017

@gankro I recently switched to a bare Vec in my particular use case that would have benefited the most from this change. However, I would be interested to some benches as to whether the added branches affect the common cases in any meaningful way.

I have some worst case scenarios where len() could be called several times per arg (assuming LLVM doesn't optimize it down to one), and when going through thousands, or tens of thousands of args (such as shell glob expansions) this change could have net positive on this particular use case should I go back to VecMap (which is entirely possible).

Of course keeping in mind in the grand scheme of things, this is probably a very, very small portion of the total execution time.


That's kind of a non-answer of, "This change doesn't affect my use case right now at all." with the caveat of I'd like to see some benches for potential future use 😜

@jonhoo
Copy link
Contributor Author

jonhoo commented Apr 19, 2017

To me, this was mostly about the large (and potentially unexpected) slowdown for len() and is_empty() being more severe than the performance penalty of the on extra branch in insert and remove (which I suspect the branch predictor will also be really good at predicting). I'm currently working towards a major deadline, so unfortunately don't have time to run performance experiments at the moment, but I suspect that they'll show the impact to be minimal.

@kbknapp what kind of benchmark results is it you'd like to see? In particular, what's the workload you have in mind where this would arise (closed-loop add/remove from the map?)

@ofek
Copy link

ofek commented Apr 30, 2017

Let's keep this alive.

@jonhoo
Copy link
Contributor Author

jonhoo commented May 7, 2017

@gankro @kbknapp bump

@Gankra Gankra merged commit b16934c into contain-rs:master May 7, 2017
@Gankra
Copy link
Contributor

Gankra commented May 7, 2017

Let's just go ahead with this. Should be trivial overhead.......

@jonhoo
Copy link
Contributor Author

jonhoo commented May 7, 2017

Nice! @gankro can you also do a (minor?) version bump?
EDIT: Actually, I guess it should maybe be major given the serde bump.

@Gankra
Copy link
Contributor

Gankra commented May 8, 2017

0.8.0 published

jonhoo added a commit to mit-pdos/noria that referenced this pull request May 8, 2017
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.

None yet

4 participants