virtual_vec is a form compatible with
std::vector. The implementation targets extensive vectors that (1) are pushed to continuously and (2) the size is now not identified, (3) web a mounted memory upper inch. This guarantees
O(1) for appending to the dwell. Attain gift the reason for this implementation is experimentation, and it has now not been tested in a production system.
When the vector is instantiated, it reserves a extensive chunk of virtual memory addresses from the operating system. Reminiscence from this tackle space is dedicated to our job because the vector grows. We below no conditions want to reproduction the full vector to a unique tackle space.
This implementation is hardcoded to make exhaust of 4GB virtual tackle for every vector, so that you may web hundreds of these per job. The quantity used to be chosen arbitrarily and may possibly additionally be made bigger or smaller depending to your exhaust case. For evident causes here is fully acceptable to 64-bit systems.
NOTE: Appropriate now this fully builds on Linux (would gladly accept patches to augment assorted OSes). To construct this you correct want to consist of
virtual_vec.cpp and a c++17 (or newer) compiler.
gtest will web to be save in.
To flee the tests:
To flee the tests below valgrind:
Google benchmark will web to be save in.
Below is a table of benchmarks evaluating the performance of
std::vector. The check calls
# elems / sizeof(int64_t) exceeds
All benchmarks are carried out on a
Intel i7-8665U (8) @ 4.800GHz. Time is recorded in CPU time.
One ingredient to agree with in tips is these benchmarks were carried out with
-O3 std::vector will get 10% sooner.
|Storage size||std::vector (ns)||virtual_vec (ns)||diff (%)|