core/rawdb: freezer batch write (#23462)
This change is a rewrite of the freezer code.
When writing ancient chain data to the freezer, the previous version first encoded each
individual item to a temporary buffer, then wrote the buffer. For small item sizes (for
example, in the block hash freezer table), this strategy causes a lot of system calls for
writing tiny chunks of data. It also allocated a lot of temporary []byte buffers.
In the new version, we instead encode multiple items into a re-useable batch buffer, which
is then written to the file all at once. This avoids performing a system call for every
inserted item.
To make the internal batching work, the ancient database API had to be changed. While
integrating this new API in BlockChain.InsertReceiptChain, additional optimizations were
also added there.
Co-authored-by:
Felix Lange <fjl@twurst.com>
Showing
- core/blockchain.go 82 additions, 117 deletionscore/blockchain.go
- core/blockchain_test.go 80 additions, 41 deletionscore/blockchain_test.go
- core/error.go 2 additions, 0 deletionscore/error.go
- core/rawdb/accessors_chain.go 69 additions, 23 deletionscore/rawdb/accessors_chain.go
- core/rawdb/accessors_chain_test.go 144 additions, 2 deletionscore/rawdb/accessors_chain_test.go
- core/rawdb/database.go 5 additions, 7 deletionscore/rawdb/database.go
- core/rawdb/freezer.go 136 additions, 96 deletionscore/rawdb/freezer.go
- core/rawdb/freezer_batch.go 248 additions, 0 deletionscore/rawdb/freezer_batch.go
- core/rawdb/freezer_table.go 58 additions, 111 deletionscore/rawdb/freezer_table.go
- core/rawdb/freezer_table_test.go 209 additions, 187 deletionscore/rawdb/freezer_table_test.go
- core/rawdb/freezer_test.go 301 additions, 0 deletionscore/rawdb/freezer_test.go
- core/rawdb/table.go 3 additions, 4 deletionscore/rawdb/table.go
- ethdb/database.go 13 additions, 3 deletionsethdb/database.go
Loading
Please register or sign in to comment