Le 13/08/2011 11:42, Pallav singh a écrit :
> Hi All ,
>
> i have data coming at variable rate and basic requirement was look up
> and insertion should be very Fast
> i used STL MAP for that , but when data was very HUGE(10 GB data was
> to be stored in MAP ), its performance degraded.
>
> Time to fetch data based on KEY increases exponentially.
>
> when I use unordered_map of C++0x to store data, it got reduced
> significantly.
>
> Is there any Other container provided by Boost or Ace Framework, which
> i can use to reduce my Look up time more.
>
> Thanks
> Pallav Singh
>
>
As you have 10GB of data, your OS is likely to swap, explaining the
performance issue (except is you have 10GB RAM ?). Moreover, even if
you have the RAM needed, RAM access isn't as fast as cache access.
So, maybe should you use something like a B-Tree with the number of
childs per node adapted to your processor cache, so you could get a
O(logK N) (with K the number of childs and N the number of elements),
and reducing RAM accesses by adapting to your cache processor.
But I'm not sure whether retrieving, say, 1Mo of data from RAM to
processor cache is better or worse in performance than retrieving 10
times 100Ko from RAM to cache.
However, if your OS is swapping (if you have not enough memory), then
the B-Tree is very likely to improve performance, compared to std::map.
Compared to std::unordered_map, I'm not sure which one is the best.
A B-tree is an improvement of a std::map for large amounts of data,
an unordered_map could also be improved.
For example, reserve enough buckets on the creation of the unordered_map,
of create a better hash function.
Then, maybe will some libraries offer you more data structures.
So, my advices :
- Try B-Trees
- For unordered_map :
- Reserve enough buckets to avoid re-hashing
- Provide a good hash function (examine the space your keys are in,
and try to make it fit with the most large space of integers, with
as little collisions as possible)
- Finally, maybe are there some other data structures I don't know yet.
Cheers & hth.,
Leo
|