Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Conversation

@gyuho
Copy link
Contributor

@gyuho gyuho commented Dec 15, 2021

Cache for each "Verified" call and evict on "Reject". To optimize VM.lookback calls.

@gyuho gyuho changed the title vm: use LRU for block cache [AV-1087] vm: use LRU for block cache Dec 15, 2021
vm/chain_vm.go Outdated
}

func (vm *VM) Accepted(b *chain.StatelessBlock) {
// still keep in LRU cache for following "getBlock" calls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to change the status of the block in memory if you are going to use the cached version later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, it may still say processing, etc.

// manually delete
delete(vm.verifiedBlocks, blkID)

blk2, err := vm.getBlock(blkID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a case that the values are correct after Accept when fetching from the cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be checked via

	if !reflect.DeepEqual(blk, blk2) {
		t.Fatalf("block expected %+v, got %+v", blk, blk2)
	}

?

Checks all status + heights... etc.

@gyuho gyuho merged commit 723bc3c into ava-labs:master Dec 26, 2021
@gyuho gyuho deleted the cache-lookback branch December 26, 2021 20:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants