Separate reading & writing into scoped threads #1129
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the index is on a SSD, sync perfomance should improve.
When the blocks' data is stored on a HDD, it takes ~3h to finish the initial sync (without full compactions, which take an additional ~1h):
![2024-12-22_19-56](https://private-user-images.githubusercontent.com/9900/398003836-d05db531-db14-4101-8f23-e5ca479b86df.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzIyNDksIm5iZiI6MTczOTMzMTk0OSwicGF0aCI6Ii85OTAwLzM5ODAwMzgzNi1kMDVkYjUzMS1kYjE0LTQxMDEtOGYyMy1lNWNhNDc5Yjg2ZGYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDM0NTQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzcwODljZGZhYWZkNjIzMDRhNzhmMDU1OWY3MTk5NjlhMmQyMGMzMDgxYWUwNTU5OGQ1MDcxMzA0ZjlhZTE3NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.l3fWK2j5ftEBcKectk8Z8ak4MsOigJiw1SnazJHoGlw)
Most of the time is spent waiting for p2p messages (i.e. bitcoind reading blocks from the spinning disk):
![2024-12-22_19-57](https://private-user-images.githubusercontent.com/9900/398003833-d527a8b3-aa16-4b15-b15c-4685fa8c1f04.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzIyNDksIm5iZiI6MTczOTMzMTk0OSwicGF0aCI6Ii85OTAwLzM5ODAwMzgzMy1kNTI3YThiMy1hYTE2LTRiMTUtYjE1Yy00Njg1ZmE4YzFmMDQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDM0NTQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjNhYmQ0NGM0ZDIyYTFkMTEwYjQxYjRkMmM3Njk3OGQ5Mjg2NTQ2MjhhOGFjYjdjODBiOGNiMTEwNDU5NzkxMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.1XVVp2Uj3Fyfv5GQajKsA-qWoIt9bnX1Gie_0RD6pMY)
Writing the index is done in parallel with the reading:
![2024-12-22_19-58](https://private-user-images.githubusercontent.com/9900/398003832-abf9120c-6638-4d36-9c6e-8ce889a1ecbe.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzIyNDksIm5iZiI6MTczOTMzMTk0OSwicGF0aCI6Ii85OTAwLzM5ODAwMzgzMi1hYmY5MTIwYy02NjM4LTRkMzYtOWM2ZS04Y2U4ODlhMWVjYmUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDM0NTQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmE1NTFjYTFlOWEwN2RiM2RiYTIwMDVhNmY5MDM3MDI0NjllMTUwMDgzMmZiYzhkZGIxMjE1MzdhZGY5MzI5NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.nf-2HgXeUmIhtLMCusY4h6hiucr-ruWF6Yl_k_KhIJA)