Skip to content

Setting & getting data for the Fast Cache #1

Closed
@ValarDragon

Description

@ValarDragon

We are conceptualizing the fast cache as this direct key value store for latest state. For simplicity of deployment / migration logic, our plan is to make this a secondary copy of latest state in the database. (We do more egregious space overheads with the cosmos pruning strategy, so this is not that bad)

IAVL is divided into two trees, mutable_tree and immutable_tree. Sets only happen on the mutable tree.

Things that need to change and be investigated for getting and setting, and the fast node:

  • mutable tree
    • GetVersioned
      • Change the logic to check the FastNode cache first, then do the GetImmutable logic
    • Set
      • Currently there is a bug right now, where it calls SaveFastNode immediately. Looking at the existing code (which is quite confusing and likely led to the bug), this should only be called during SaveVersion. We should add a new field to MutableTree for unsavedFastNodeChanges, and make that a hash map. Then we have every Set update that. Then in SaveVersion we call SaveFastNode on everything in that map. Preferrably, we iterate over this map in deterministic order. (So by sorting the map keys first)
  • immutable_tree
    • Get
      • Currently it checks if value is nil before the version check. This is reversed, it should check if the version is too new. If so do old logic. If its sufficiently old, then value = nil implies that the node is deleted. So it should return whatever t.root.get(t, key) returns on a non-existent key.
      • (Note we don't care about the index return value we can make it whatever we want. To our knowledge, nothing uses this index return value. At the end, we may decide to make a new function just to preserve API's / be sure, but no need for right now)
    • We also need to test that these changes work. We should make a test function somewhere, to ensure that the FastNodeCache matches the live State. Then we test that in several of the existing tests. Probably easiest to do so after every version in testRandomOperations, in tree_random_test.go

Things needed for migration and iteration are relegated to new issues.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions