Case sharing using and finding performance tests for C + + maps

Source: Internet
Author: User
Recently in the performance tuning for the recommended service, the main logic of this service is to use the offline computing model data for each ad in the request to score, and then return the order of these ads, the process of scoring in fact with the data in the request to spell a variety of keys, to check a large map, this calculation is very much, Become the main performance bottleneck, the code is older, using the Boost::unordered_map, in order to solve this problem, find some third-party libraries and standard library compared a bit





Here are ther4.xlargetest results on an AWS machine (note that you must add-o2 when compiling):


std::map<int, int>                                 => 51866903
std::unordered_map<int, int>                       => 3838175
std::unordered_map<int, int, nohashint>            => 3508570
std::unordered_map<int, int>(N)                    => 3804471
boost::unordered_map<int, int>                     => 3291384
boost::unordered_map<int, int, nohashint>          => 3293934
boost::unordered_map<int, int>(N)                  => 3265856
google::dense_hash_map<int, int>                   => 785969
google::dense_hash_map<int, int, nohashint>        => 784455
google::dense_hash_map<int, int>(N)                => 899262
tsl::hopscotch_map<int, int>                       => 654668
tsl::hopscotch_map<int, int, nohashint>            => 680964
tsl::hopscotch_map<int, int>(N)                    => 663607
tsl::robin_map<int, int>                           => 406176
tsl::robin_map<int, int, nohashint>                => 411358
tsl::robin_map<int, int>(N)                        => 409993


Can see Tsl::robin_map performance basically can reach Std::unordered_map 10 times times, this performance and the operating system and the library version also has a certain relationship, the actual production environment is recommended to pull down the code in their own environment test



We used Tsl::robin_map to replace the original BOOST::UNORDERED_MAP, the overall performance increased 5 times times, which also contains some other optimizations, this optimization is a relatively large optimization point


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.