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

Performance Issue When Retrieving Trie Node #1509

Closed
ajlopez opened this issue Apr 25, 2021 · 0 comments
Closed

Performance Issue When Retrieving Trie Node #1509

ajlopez opened this issue Apr 25, 2021 · 0 comments

Comments

@ajlopez
Copy link
Contributor

ajlopez commented Apr 25, 2021

In TrieNodeImpl there is this code:

    @Override
    public Optional<Trie> retrieve(byte[] hash) {
        byte[] message = this.store.get(hash);
        if (message == null) {
            return Optional.empty();
        }

        Trie trie = Trie.fromMessage(message, this);
        savedTries.add(trie);
        return Optional.of(trie);
    }

The issue is the line:

        savedTries.add(trie);

Adding the trie node to the set savedTries IMPLIES to execute Trie.getHash() that involves a hash calculation that it is not cheap.

Ie exporting testnet state at height 1784654 executing:

co.rsk.cli.tools.ExportState 1784654 --testnet

WITH the add operation: 150_000 retrieved nodes per hour
WITHOUT the add operation: 180_000 retrieved nodes per hour

Proposal 1

Remove the use of that set, and replace the already save trie node logic by another one that involves less memory and operations

Proposal 2

Inject the hash into trie node in the Trie.fromMessage deserialization logic

There is WIP (Work In Progress) to solve this issue in https://github.com/ajlopez/rskj/tree/triefix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants