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

feat(init): speed up initialization #392

Merged
merged 1 commit into from
Jun 6, 2022
Merged

Conversation

jansegre
Copy link
Member

@jansegre jansegre commented Apr 12, 2022

Using the latest snapshot (data-20220303175324.tar.gz) as a base, initialization is about 60% faster when using all existing in-disk indexes (some indexes are still in-memory only), and about 120% faster than using all in-disk indexes but rebuilding them on every initialization (the current behavior before this PR):

  • cold run (all indexes rebuilt, in-disk will be reused later):
    2022-05-11 20:55:29 [info     ] [hathor.indexes.manager] loaded                         blocks=2267901 height=2259960 total_dt=~3509s tx_count=2895834 tx_rate=825.1686592546121 txs=627933
    
  • hot run (only in-memory indexes are rebuilt):
    2022-05-11 21:29:53 [info     ] [hathor.indexes.manager] loaded                         blocks=2267901 height=2259960 total_dt=~1596s tx_count=2895834 tx_rate=1814.152552360921 txs=627933
    
  • hot run (all in-memory indexes are rebuilt, no in-disk index is used):
    2022-05-11 22:19:42 [info     ] [hathor.indexes.manager] loaded                         blocks=2267901 height=2259960 total_dt=~2615s tx_count=2895834 tx_rate=1107.2753905973273 txs=627933
    

But still in-disk indexes are not enabled by default, they require cli argument --x-rocksdb-indexes.

Last bits:

  • hathor/indexes/address_index.py:36 tx_meta.voided_by should not be skipped, add a test for that
  • hathor/indexes/deps_index.py:110 check whether the it really makes sense to filter-out voided txs
  • hathor/indexes/tips_index.py:63 check whether looking at validation.is_final makes sense for all indexes
  • hathor/indexes/manager.py:44 check if soft-voided txs are handled correctly
  • hathor/indexes/manager.py:147 move iterator selector to the storage and only consider DFS sort when a flag is used

@jansegre jansegre requested a review from msbrogli as a code owner April 12, 2022 19:34
@jansegre jansegre self-assigned this Apr 12, 2022
@jansegre jansegre marked this pull request as draft April 12, 2022 19:35
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch from fcadac4 to f13f2b1 Compare April 26, 2022 19:20
@jansegre jansegre changed the title feat(init): speed up tips-index initialization feat(init): speed up initialization Apr 29, 2022
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch 8 times, most recently from 6395d65 to f37ecdc Compare May 9, 2022 19:26
@codecov
Copy link

codecov bot commented May 9, 2022

Codecov Report

Merging #392 (038731a) into dev (52ec99c) will decrease coverage by 0.01%.
The diff coverage is 85.67%.

❗ Current head 038731a differs from pull request most recent head 718bc00. Consider uploading reports for the commit 718bc00 to get more accurate results

@@            Coverage Diff             @@
##              dev     #392      +/-   ##
==========================================
- Coverage   82.65%   82.63%   -0.02%     
==========================================
  Files         174      175       +1     
  Lines       15939    16228     +289     
  Branches     2503     2550      +47     
==========================================
+ Hits        13174    13410     +236     
- Misses       2309     2342      +33     
- Partials      456      476      +20     
Impacted Files Coverage Δ
hathor/manager.py 67.89% <44.92%> (-5.02%) ⬇️
hathor/indexes/rocksdb_mempool_tips_index.py 64.00% <60.00%> (-31.00%) ⬇️
hathor/indexes/rocksdb_deps_index.py 61.18% <66.66%> (-0.36%) ⬇️
hathor/indexes/tips_index.py 97.56% <84.61%> (-2.44%) ⬇️
hathor/indexes/manager.py 94.27% <91.95%> (+0.10%) ⬆️
hathor/transaction/storage/transaction_storage.py 94.51% <95.16%> (-0.22%) ⬇️
hathor/indexes/rocksdb_utils.py 71.62% <95.65%> (-22.83%) ⬇️
hathor/exception.py 100.00% <100.00%> (ø)
hathor/indexes/address_index.py 93.10% <100.00%> (+0.79%) ⬆️
hathor/indexes/base_index.py 100.00% <100.00%> (ø)
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52ec99c...718bc00. Read the comment docs.

hathor/indexes/base_index.py Outdated Show resolved Hide resolved
hathor/manager.py Outdated Show resolved Hide resolved
hathor/manager.py Outdated Show resolved Hide resolved
hathor/manager.py Outdated Show resolved Hide resolved
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch 2 times, most recently from 8173a0f to 83701ca Compare May 18, 2022 17:46
@jansegre jansegre marked this pull request as ready for review May 19, 2022 19:28
@jansegre jansegre requested a review from pedroferreira1 May 19, 2022 19:28
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch from 83701ca to 7e6587d Compare May 19, 2022 19:30
hathor/cli/quick_test.py Outdated Show resolved Hide resolved
hathor/indexes/address_index.py Outdated Show resolved Hide resolved
hathor/indexes/deps_index.py Show resolved Hide resolved
hathor/indexes/memory_address_index.py Outdated Show resolved Hide resolved
hathor/transaction/base_transaction.py Show resolved Hide resolved
hathor/transaction/base_transaction.py Show resolved Hide resolved
hathor/indexes/rocksdb_timestamp_index.py Show resolved Hide resolved
hathor/indexes/tips_index.py Show resolved Hide resolved
hathor/indexes/tokens_index.py Show resolved Hide resolved
tests/tx/test_indexes3.py Show resolved Hide resolved
hathor/indexes/manager.py Show resolved Hide resolved
hathor/indexes/manager.py Outdated Show resolved Hide resolved
hathor/indexes/manager.py Show resolved Hide resolved
hathor/indexes/manager.py Show resolved Hide resolved
hathor/indexes/manager.py Outdated Show resolved Hide resolved
hathor/indexes/manager.py Show resolved Hide resolved
hathor/manager.py Outdated Show resolved Hide resolved
hathor/transaction/storage/transaction_storage.py Outdated Show resolved Hide resolved
tests/tx/test_indexes3.py Outdated Show resolved Hide resolved
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch 5 times, most recently from f7c25de to e16499c Compare May 25, 2022 23:35
hathor/manager.py Outdated Show resolved Hide resolved
tests/tx/test_indexes3.py Show resolved Hide resolved
hathor/indexes/memory_address_index.py Show resolved Hide resolved
hathor/indexes/rocksdb_utils.py Show resolved Hide resolved
hathor/indexes/deps_index.py Show resolved Hide resolved
hathor/indexes/tokens_index.py Show resolved Hide resolved
hathor/indexes/manager.py Show resolved Hide resolved
hathor/transaction/storage/transaction_storage.py Outdated Show resolved Hide resolved
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch 2 times, most recently from 038731a to cde83cb Compare June 2, 2022 22:02
hathor/manager.py Show resolved Hide resolved
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch from cde83cb to f4d7f46 Compare June 3, 2022 17:42
@jansegre jansegre mentioned this pull request Jun 6, 2022
@jansegre jansegre force-pushed the feat/speedup-tipsindex-init branch from f4d7f46 to 718bc00 Compare June 6, 2022 21:24
@jansegre jansegre merged commit 7f37146 into dev Jun 6, 2022
@jansegre jansegre deleted the feat/speedup-tipsindex-init branch June 6, 2022 23:01
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.

3 participants