Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

perf(state): add state cache for trieDB #404

Merged
merged 12 commits into from
Aug 10, 2020

Conversation

KaoImin
Copy link

@KaoImin KaoImin commented Aug 7, 2020

What this PR does / why we need it:
Implement an approximately fixed size cache through HashMap. It caches the data used in the latest block, and it will be flushed when committing a block. The size of the cache is 2000, however, this does not mean that it can only store 2000 data. When the data in the cache is more than 2000 when the cache is refreshed, it will be randomly deleted to 2000. The random seed is the largest prime number within 50000, 49999.

Which issue(s) this PR fixes:

Fixes #

Which docs this PR relation:

Ref nervosnetwork/muta-docs#55

Which toolchain this PR adaption:

No Breaking Change

Special notes for your reviewer:

@KaoImin KaoImin requested a review from yejiayu August 7, 2020 07:45
@yejiayu
Copy link
Contributor

yejiayu commented Aug 7, 2020

Add the benchmark of the executor? You need to make sure that it create a new MPT each time.

@yejiayu
Copy link
Contributor

yejiayu commented Aug 9, 2020

Can you show a result of perf to this PR descriptions?

use rocksdb::{Options, WriteBatch, DB};

use common_apm::metrics::storage::{on_storage_get_state, on_storage_put_state};
use protocol::{ProtocolError, ProtocolErrorKind, ProtocolResult};

const RAND_SEED: u64 = 49999;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it have any relationship with cache length?

Copy link
Author

Choose a reason for hiding this comment

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

Nothing.

@yejiayu
Copy link
Contributor

yejiayu commented Aug 10, 2020

/lgtm

@muta-robot muta-robot removed the lgtm #8ef42e label Aug 10, 2020
@yejiayu
Copy link
Contributor

yejiayu commented Aug 10, 2020

/hold

@yejiayu
Copy link
Contributor

yejiayu commented Aug 10, 2020

/hold cancel

@yejiayu
Copy link
Contributor

yejiayu commented Aug 10, 2020

/lgtm

@muta-robot muta-robot added the lgtm #8ef42e label Aug 10, 2020
@muta-robot muta-robot merged commit 2a08c14 into nervosnetwork:master Aug 10, 2020
@yejiayu yejiayu self-requested a review August 10, 2020 10:34
@muta-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yejiayu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@KaoImin KaoImin deleted the refactor-mempool branch August 13, 2020 03:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants