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

Storage query performance optimization #334

Merged
merged 2 commits into from
Apr 8, 2022

Conversation

ntduan
Copy link
Collaborator

@ntduan ntduan commented Apr 1, 2022

fix #332

@ntduan ntduan requested review from zjb0807 and shunjizhan April 1, 2022 00:15
@ntduan ntduan force-pushed the storage-query-performance-optimization branch from 124dd31 to 119f27e Compare April 4, 2022 23:58
@ntduan ntduan force-pushed the storage-query-performance-optimization branch from 431d2e1 to f944bee Compare April 8, 2022 00:53
@ntduan ntduan merged commit 8f27555 into master Apr 8, 2022
@ntduan ntduan deleted the storage-query-performance-optimization branch April 8, 2022 01:18
@shunjizhan
Copy link
Collaborator

shunjizhan commented Apr 8, 2022

question: why don't we cache blockHash => Storage, and instead cache registry => Storage? It seems that we are repeating this deterministic query (is this line actually not deterministic?)

const registry = await this.api.getBlockRegistry(u8aToU8a(blockHash));

Also, do we have a limit for the cache? It can grow very big in long term

@ntduan
Copy link
Collaborator Author

ntduan commented Apr 10, 2022

question: why don't we cache blockHash => Storage, and instead cache registry => Storage? It seems that we are repeating this deterministic query (is this line actually not deterministic?)

const registry = await this.api.getBlockRegistry(u8aToU8a(blockHash));

Also, do we have a limit for the cache? It can grow very big in long term

Because the registry only changes when the chain version is upgraded. This will not be very frequent.

apiAt creates a new object every time, which can cause a significant performance overhead. https://github.com/polkadot-js/api/blob/master/packages/api/src/base/Init.ts#L120

@ntduan ntduan mentioned this pull request Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved concurrency performance
2 participants