Is there a parallel processing implementation of HashMap for Java? Is it even possible?

Looking for the magical parallelhashmap class

More succinctly, can you use multiple threads to speed up HashMap lookup? Is there any implementation that has already performed this operation?

In my project, we need to maintain a large object map in memory We never modify the map after creating it, so the map is strictly read-only However, read and lookup performance on this map is critical to the success of the application The system on which the application is installed usually has many available hardware threads However, our lookup uses only a single thread to retrieve values from the HashMap Does the divide and conquer approach of using multiple threads (possibly in the pool) help to improve lookup speed?

Most of my Google searches have no results - they return a lot of results about concurrency problems rather than solutions Any suggestion will be appreciated, but if you know the out of the box solution, it's great

It is also worth noting that all keys and values are immutable Hash code values are pre - computed and stored in the object itself when instantiated

As for the implementation details, there are about 35000 projects in the map Keys and values are objects The key is a custom lookup key and the value is a string At present, we can process about 5000 lookups per second (including some other logical overhead, but the main bottleneck is the map implementation itself) However, in order to meet our future performance requirements, I hope to get about 10000 lookups per second By most normal standards, we are currently implementing fast - we just need it faster

In our 35000 value map, we have an average hash code conflict, so I guess the distribution of hash codes is quite reasonable

Solution

Therefore, your hash code is precomputed and the equals function is fast - in this case, your HashMap should be very fast

Have you analyzed your application to prove that HashMap is indeed a bottleneck?

If you have multiple application threads, they should be able to perform their own fetches from HashMap at the same time - because you haven't modified the map, you don't need to synchronize the fetches externally Can an application that uses hash mapping take full advantage of all hardware threads?

Because the contents of the hash table are immutable, it may be worth checking perfect hashing – with a perfect hash function, you should not conflict or need links in the hash table, which may improve performance I don't know the Java implementation at hand, but in C / C + +, there is GPERF

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>