I am currently doing a performance testing of a C++ program. I need to bulk insert to a std::unordered_map or some other similar open source structure. I am inserting 30-40 char strings as key-value pairs and noticed an interesting behaviour. When code is first executed (Clion), it took 20 seconds to complete, I repeated the test (changing nothing), it was 14s, then again 8s, 4s, the code now runs around 3s. I should repeat, the only expensive operation in my code is bulk unordered_map insert, multithreaded with std::lock_guard<std::mutex>.
Another information that is important is that I am reading these keys and values from files. So I thought about some file caching happening in Ubuntu. But I was doing the same thing with different mechanisms and never experienced such a thing. Then I thought about some RAM allocation trick that may be keeping most of the map intact after the program is ended. But I am doing nothing to make that happen.
Why is this happening ? More than that, how can I reset this ? I need to do objective tests because my code will run in multiple servers without any pre-caching what so ever.
Thanks.