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

[Merged by Bors] - in memory index with atx data for consensus layer #5013

Closed
wants to merge 46 commits into from

Conversation

dshulyak
Copy link
Contributor

@dshulyak dshulyak commented Sep 14, 2023

closes: #4164

this change introduces index with minimal data about identities which is required for consensus. the goal is to have predictable latency on the codepath that are sensitive to it, such as proposals and even more hare messages. the number of issues with that will only grow when sql db size won't fit in page cache (so querying vrf nonce and atx data will hit the disk often).

cached data per identity:

  • weight
  • height and base height
  • vrf nonce
  • malicious boolean

the data is added to the cache either on startup or when new atx is received. nonce may be loaded from previous atx if it wasn't included in this one. when block from epoch X is applied, we will evict epochs starting from X-capacity. index is configured to fit same number of epochs that fit in the tortoise window, this enables to self-healing during this period.

internally we store data indexed by epoch for simple eviction, and each epoch has an index by atx.

memory estimate for 1_000_000 identities is ~140MB

@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #5013 (fbf6667) into develop (6da9e61) will increase coverage by 0.1%.
Report is 2 commits behind head on develop.
The diff coverage is 93.1%.

@@            Coverage Diff            @@
##           develop   #5013     +/-   ##
=========================================
+ Coverage     77.7%   77.9%   +0.1%     
=========================================
  Files          262     264      +2     
  Lines        31112   31375    +263     
=========================================
+ Hits         24204   24461    +257     
- Misses        5403    5410      +7     
+ Partials      1505    1504      -1     
Files Coverage Δ
atxsdata/data.go 100.0% <100.0%> (ø)
atxsdata/warmup.go 100.0% <100.0%> (ø)
common/types/verified_activation.go 100.0% <100.0%> (ø)
mesh/mesh.go 64.3% <100.0%> (+0.1%) ⬆️
proposals/eligibility_validator.go 97.7% <100.0%> (-2.3%) ⬇️
sql/database.go 73.3% <ø> (+1.6%) ⬆️
proposals/handler.go 88.2% <97.7%> (+0.7%) ⬆️
datastore/store.go 70.3% <75.0%> (-2.3%) ⬇️
node/node.go 65.0% <81.2%> (+<0.1%) ⬆️
activation/handler.go 76.7% <81.2%> (+0.4%) ⬆️
... and 1 more

... and 2 files with indirect coverage changes

@dshulyak
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Sep 19, 2023
@bors
Copy link

bors bot commented Sep 19, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@dshulyak
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Sep 21, 2023
@bors
Copy link

bors bot commented Sep 21, 2023

try

Build failed:

@dshulyak dshulyak changed the title in memory btree index with atx data for consensus layer in memory index with atx data for consensus layer Oct 22, 2023
@dshulyak dshulyak marked this pull request as draft October 22, 2023 11:29
@dshulyak
Copy link
Contributor Author

dshulyak commented Oct 23, 2023

will create a separate to follow to adjust those places in a different pr

where it will be used?

- no atx queries in ballot/proposal handlers (implemented in this change)
- no identity and atx queries in hare
- no atx queries in block generator
- atx queries during mesh hash resolution

will allow to

- drop atxs data from tortoise
- drop lru cache for atxs and identities

@dshulyak dshulyak marked this pull request as ready for review October 23, 2023 05:52
@dshulyak
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Oct 23, 2023
@bors
Copy link

bors bot commented Oct 23, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@dshulyak
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Oct 23, 2023
@bors
Copy link

bors bot commented Oct 23, 2023

try

Build failed:

@dshulyak
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Oct 23, 2023
@bors
Copy link

bors bot commented Oct 23, 2023

try

Build failed:

atxsdata/data.go Outdated Show resolved Hide resolved
atxsdata/warmup.go Outdated Show resolved Hide resolved
atxsdata/data.go Outdated Show resolved Hide resolved
atxsdata/data.go Outdated Show resolved Hide resolved
@dshulyak
Copy link
Contributor Author

bors merge

bors bot pushed a commit that referenced this pull request Oct 24, 2023
closes: #4164

this change introduces index with minimal data about identities which is required for consensus. the goal is to have predictable latency on the codepath that are sensitive to it, such as proposals and even more hare messages. the number of issues with that will only grow when sql db size won't fit in page cache (so querying vrf nonce and atx data will hit the disk often).

cached data per identity:
- weight
- height and base height
- vrf nonce
- malicious boolean

the data is added to the cache either on startup or when new atx is received. nonce may be loaded from previous atx if it wasn't included in this one. when block from epoch X is applied, we will evict epochs starting from X-capacity. index is configured to fit same number of epochs that fit in the tortoise window, this enables to self-healing during this period.

internally we store data indexed by epoch for simple eviction, and each epoch has an index by atx.

memory estimate for 1_000_000 identities is ~140MB
@bors
Copy link

bors bot commented Oct 24, 2023

Pull request successfully merged into develop.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title in memory index with atx data for consensus layer [Merged by Bors] - in memory index with atx data for consensus layer Oct 24, 2023
@bors bors bot closed this Oct 24, 2023
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.

cache: reduce amount of data stored in atxs cache and store all such headers for current and next epoch
3 participants