Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider assorted data structure/storage optimizations #646

Open
alnoki opened this issue Nov 29, 2023 · 0 comments
Open

Consider assorted data structure/storage optimizations #646

alnoki opened this issue Nov 29, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@alnoki
Copy link
Member

alnoki commented Nov 29, 2023

  • Simple red black tree for price levels in a single storage item
  • Orders within a price level as ring-buffer based doubly linked list
    • Ring buffer so can know next allocation spot without having to always reshuffle (e.g. like in a vector insert)
      • The allocated vector never changes, just the next and last fields
      • 2d ring buffer could have max elems in a storage node, and have each node be doubly linked list yet again (like BigVector)
    • Hence for O(1) lookup need pointer to table ring buffer and vector ring buffer
  • Except if static space for price levels then need to evict entire level at once
  • Could use btree on its own for all orders, since maker address already 8 bytes and other data probably 30 or so
  • Could use b+ tree
    • Each order has a b+ tree key, which is price concatenated with a boundary flag
    • Basically if you have an order at price 5 and price 6 and need to insert at back of queue for price 5, look at the boundary flag on existing price 5 order (e.g. 000000), and increment by 1, so new order key is5 < 64 | 1 (this is like the dynamic pointer used for AVL queue) and thus goes between the two existing orders in total order search
    • Then need to store B+ access key under user table
@alnoki alnoki added the enhancement New feature or request label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant