Skip to content

Commit

Permalink
correct calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshkaj committed Apr 20, 2018
1 parent e4a4a8d commit 4e2f6b7
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions include/engine/unpacking_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,52 @@ class UnpackingCache
// https://github.com/Project-OSRM/osrm-backend/issues/4798#issue-288608332)

// LRU CACHE IMPLEMENTATION HAS THESE TWO STORAGE CONTAINERS
// Key is of size: std::uint32_t * 2 + (unsigned char) * 1 + unsigned * 1
// = 4 * 2 + 1 * 1 + 4 * 1 = 21
// Key is of size: std::uint32_t * 2 + (unsigned char) * 1
// = 4 * 2 + 1 * 1 = 9
// map: n * Key + n * EdgeDuration
// = n * 21 bytes + n * std::int32_t
// = n * 21 bytes + n * 4 bytes
// = n * 25 bytes
// = n * 9 bytes + n * std::int32_t
// = n * 9 bytes + n * 4 bytes
// = n * 13 bytes
// list: n * Key
// = n * 21 bytes
// Total = n * (25 + 21) = n * 46 bytes
// = n * 9 bytes
// Total = n * (13 + 9) = n * 22 bytes
// Total cache size: 500 mb = 500 * 1024 *1024 bytes = 524288000 bytes

// THREAD LOCAL STORAGE
// Number of lines we need = 524288000 / 46 / number of threads = 11397565 / number of threads
// 16 threads: 11397565 / 16 = 712347
// 8 threads: 11397565 / 8 = 1424695
// 4 threads: 11397565 / 4 = 2849391
// 2 threads: 11397565 / 2 = 5698782
// THREAD LOCAL STORAGE (500 mb)
// Number of lines we need = 524288000 / 22 / number of threads = 23831272 / number of threads
// 16 threads: 23831272 / 16 = 1489454
// 8 threads: 23831272 / 8 = 2978909
// 4 threads: 23831272 / 4 = 5957818
// 2 threads: 23831272 / 2 = 11915636

// THREAD LOCAL STORAGE (1024 mb)
// Number of lines we need = 1073741824 / 22 / number of threads = 48806446 / number of threads
// 16 threads: 48806446 / 16 = 3050402
// 8 threads: 48806446 / 8 = 6100805
// 4 threads: 48806446 / 4 = 12201611
// 2 threads: 48806446 / 2 = 24403223

// LRU CACHE IMPLEMENTATION HAS THESE TWO STORAGE CONTAINERS
// Key is of size: std::uint32_t * 2 + (unsigned char) * 1 + unsigned * 1
// = 4 * 2 + 1 * 1 + 4 * 1 = 13
// map: n * Key + n * EdgeDuration
// = n * 13 bytes + n * std::int32_t
// = n * 13 bytes + n * 4 bytes
// = n * 17 bytes
// list: n * Key
// = n * 13 bytes
// Total = n * (17 + 13) = n * 30 bytes
// Total cache size: 500 mb = 500 * 1024 *1024 bytes = 524288000 bytes
// Total cache size: 1024 mb = 1024 * 1024 *1024 bytes = 1073741824 bytes
// Total cache size: 250 mb = 250 * 1024 *1024 bytes = 262144000 bytes

// SHARED STORAGE CACHE
// Number of lines we need for shared storage cache = 524288000 / 20 = 26214400
// Number of lines for shared storage cache 1024 mb = 524288000 / 30 = 17476266
// Number of lines for shared storage cache 500 mb = 1073741824 / 30 = 35791394
// Number of lines for shared storage cache 250 mb = 262144000 / 30 = 8738133


UnpackingCache(unsigned timestamp) : m_cache(712347), m_current_data_timestamp(timestamp){};
UnpackingCache(unsigned timestamp) : m_cache(8738133), m_current_data_timestamp(timestamp){};

UnpackingCache(std::size_t cache_size, unsigned timestamp)
: m_cache(cache_size), m_current_data_timestamp(timestamp){};
Expand Down

0 comments on commit 4e2f6b7

Please sign in to comment.