Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3391: improve sync header map r=driftluo a=zhangsoledad <!-- Thank you for contributing to nervosnetwork/ckb! If you haven't already, please read [CONTRIBUTING](https://github.com/nervosnetwork/ckb/blob/develop/CONTRIBUTING.md) document. If you're unsure about anything, just ask; somebody should be along to answer within a day or two. PR Title Format: 1. module [, module2, module3]: what's changed 2. *: what's changed --> ### What problem does this PR solve? * Optimize the implementation of header map to improve the speed of header synchronization from 11924/s to 14377/s, about 20% improvement. * Human-friendly configuration ### What is changed and how it works? - Asynchronous batch write to hard disk when memory limit is exceeded. - Replace the implementation of header map bankend. Rocksdb has some drawbacks in this scenario, Rocksdb cannot give feedback on whether the key is overwritten when writing, nor can it distinguish between successful or not found when deleting, it's inefficient and looks silly to retrieve a value just to check if it exists or not. ``` RocksDBBackend::contains_key duration 4041 ns RocksDBBackend::remove duration 7000 ns RocksDBBackend::insert duration 10750 ns Sometimes it deteriorates into the following, because of the inconvenience of implementation: RocksDBBackend::contains_key duration 10750 ns RocksDBBackend::remove duration 13000 ns RocksDBBackend::insert duration 21583 ns ----------------------------- SledBackend::contains_key duration 2666 ns SledBackend::remove duration 2583 ns SledBackend::insert_batch 35503541/10028 ns (3540 ns) ``` ### Check List <!--REMOVE the items that are not applicable--> Tests <!-- At least one of them must be included. --> - Unit test - Integration test - Manual test (add detailed scripts or steps below) - No code ci-runs-only: [ quick_checks,linters ] ### Release note <!-- Choose from None, Title Only and Note. Bugfixes or new features need a release note. --> ```release-note Title Only: Include only the PR title in the release note. ``` Co-authored-by: zhangsoledad <[email protected]>
- Loading branch information