Re: Poor performance from stdext::hash_map
From: P.J. Plauger (pjp_at_dinkumware.com)
Date: 06/11/04
- Previous message: Andy Coates: "Poor performance from stdext::hash_map"
- In reply to: Andy Coates: "Poor performance from stdext::hash_map"
- Next in thread: Michael Schlenger: "Re: Poor performance from stdext::hash_map"
- Reply: Michael Schlenger: "Re: Poor performance from stdext::hash_map"
- Reply: Andy Coates: "Re: Poor performance from stdext::hash_map"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 11 Jun 2004 13:19:51 -0400
"Andy Coates" <nothanks@nowhere.com> wrote in message
news:%23H2Mnh6TEHA.3660@tk2msftngp13.phx.gbl...
> I've just noticed that MS are now shipping hash_map and hash_set with
> DevStudio. However, I'm finding that I'm getting worse performance than
the
> standard map container and a lot worse than the MFC CMap. So I'm assuming
> I'm doing something wrong!
This version of hash_map/set is unique in using incremental rehashing.
The benefit is that there is never a point where the code suddenly
decides to stop everything and rebuild the hash table completely.
Equally, you never have to think about the circumstances under which
you'd better force a rehash. Think of the difference between a car
with automatic vs. manual transmission.
What you've seen is the worst aspect of this automatic feature. As
you grow the hash table, it has to incrementally rehash on a regular
basis. There is a way to warn the container that it should be
prepared to grow to a certain size, and hence save all that
intermediate rehashing, but it's currently pretty clunky.
The C++ committee is producing a (non-normative) Technical Report
that adds tons of things to the Standard C++ library. Part of that
tonnage is the template classes unordered_[multi]{map set}, which
form a standardized replacement for the various hash containers
knocking about. We've retooled the underlying machinery for our
hash containers so that it serves equally well for the unordered
containers in the TR. One benefit of that is the addition of a
rehash function to *all* containers, old and new. When it
percolates out to the field, you'll be able to assert manual
control whenever you think it might help, and with much better
notation than you currently have to use.
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
- Previous message: Andy Coates: "Poor performance from stdext::hash_map"
- In reply to: Andy Coates: "Poor performance from stdext::hash_map"
- Next in thread: Michael Schlenger: "Re: Poor performance from stdext::hash_map"
- Reply: Michael Schlenger: "Re: Poor performance from stdext::hash_map"
- Reply: Andy Coates: "Re: Poor performance from stdext::hash_map"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|