MichaelFabrizio / KeyVector

C++ memory bootstrapping library
MIT License
0 stars 0 forks source link

Paging for KeyVector object #5

Open MichaelFabrizio opened 4 months ago

MichaelFabrizio commented 4 months ago

There is a theoretical maximum distance in address space between an index key K, and the associated value V, currently:

Address Distance = (N - K + 1) * sizeof(IndexType) + K * sizeof(ValueType) + (Constant Padding)

Where N is the "Max Key" (user specified), and K can be any arbitrary number on the range 0 <= K <= N.

It's important to note that Address Distance scales linearly with N. This means that when N becomes large enough you will start getting L1 cache misses, then L2, then L3 etc.

The solution to this is to implement paging, which will balance out the performance of KeyVector more evenly for higher number collections. It will allow us to create Max Keys that are arbitrarily high.

This will involve some significant algorithm changes. My hope is to develop it in private until I get a working model.

If any of this interested you, feel free to share your thoughts.