perf(db): reuse MDBX DBIs for the same tx#18292
Conversation
b3df477 to
20904ce
Compare
| @@ -75,10 +80,18 @@ impl<K: TransactionKind> Tx<K> { | |||
|
|
|||
| /// Gets a table database handle if it exists, otherwise creates it. | |||
There was a problem hiding this comment.
unfamiliar with the internals here, but can we safely assume that this will always exist for the duration of the transaction?
maybe @shekhirin knows
There was a problem hiding this comment.
MDBX_dbi is an index/pointer to the actual table handle stored in the DB environment, which will live until the end of the environment, basically the end of the program for Reth, or until it is explicitly closed via mdbx_dbi_close, which we don't and shouldn't do.
Since we don't dynamically create new tables at runtime (right?), the best practice is to pre-create all these table handles at startup time, then share their MDBX_dbis across all transactions.
Otherwise, (repeatedly) calling mdbx_dbi_open at runtime is very expensive. In the code path I showed earlier in #18284, 2.5 / 5.1 ~ 49% of the get (stage checkpoint) is spent on open_db, which likely returns the same MDBX_dbi anyway. Just much more expensive as it needs to execute a transaction, creates contention at the DB-level, etc.
There was a problem hiding this comment.
That sounds correct, confirmed with MDBX documentation https://libmdbx.dqdkfa.ru/group__c__dbi.html#ga9bef4a9fdf27655e9343bbbf8b6fc5a1
|
What would be risks you foresee with this impl? Whether it is using data that's not up to date due to mvcc or any kind of deadlock? Very exciting work! |
@gakonst Not an MDBX expert, but it looks pretty straightforward from their docs and source, sir. Unless we dynamically create and close tables at runtime (not seeing why Reth would need to), the table handles and their DBIs (index/pointer) are essentially constant after initialisation, across the whole program's lifetime. To be sure, I did a quick check at Erigon; they indeed open all DBIs once at startup time: Then look it up instead of calling To be even more sure, we should double-check existing code and write comments to warn against re-creating tables (like with different flags) and closing DBIs after initialisation. |
|
Would be awesome if you could reth-bench and see if there's e2e perf improvement given we heavily use opened transactions on a block by block basis -- does this carry over there too? |
My observations yesterday:
I'm also very curious about E2E benchmark results (especially for block building & RPC), but I will need my colleagues' help and the kids to return to school first! |
If I understand correctly, in Reth, the set of key-value tables changes rarely and only from version to version, but it is constant when the application is running. If so, then you should (actually must to avoid dummy overhead) open the DBI handles once immediately after opening and/or creating the database, or after completing the migration/upgrade of the data schema. This approach allows to use a global variables for DBI-handles for all tables, without the need for any synchronization of access/using ones and concern about the lifetime (it is not even necessary to close). So this could be applied safe (without a risk of regressions). Ask in the libmdbx' telegram group if in doubt. |
|
Here are some quick DB benchmarks on my PC rebased on 119ed88:
I'll try to run the stage benchmarks tomorrow. E2E may take more time. Meeting Monday was too brutal... |
20904ce to
ca6ea90
Compare
|
Stage benchmarks are mostly broken, so I only have this quick one:
@mattsse @gakonst Can someone from your team help with |
ca6ea90 to
3c93c20
Compare
|
@mattsse @gakonst Ok, I could run This branch on 3e4c0cc: Speedup:
|
shekhirin
left a comment
There was a problem hiding this comment.
LGTM, this is such an obvious change to do 🙈 Thanks for this! I'm going to merge this and we will run our internal nodes on main for a while before releasing it, so I feel pretty confident.
In the future we can even get rid of DashMap overhead by creating all DBI handles on startup.
I'll find some time next week! |
* feat: optionally disable balance check for `EthTransactionValidator` (paradigmxyz#18086) * feat(optimism): Launch `FlashBlockService` when websocket URL is provided in `OpEthApi` (paradigmxyz#18077) * feat: add NoopNetwork example (paradigmxyz#18093) * feat: add helper for provider with wallet (paradigmxyz#18085) * feat(optimism): Add `flashblocks_url` as part of rollup args of the `op-reth` CLI (paradigmxyz#18094) * perf(engine): only fetch headers instead of full blocks for tree tasks (paradigmxyz#18088) * feat(optimism): Implement conversion of `ExecutionPayloadBaseV1` into `OpNextBlockEnvAttributes` (paradigmxyz#18097) * feat(optimism): Remove builder of next block environment from `FlashBlockService` (paradigmxyz#18100) * refactor: make transaction validator functions reusable (paradigmxyz#17929) Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com> * feat: add module manipulation methods and RPC server arg helpers (paradigmxyz#18084) * chore(reth-optimism-cli): use OpTypedTransaction::eip2718_encode (paradigmxyz#18105) * ci: remove expected failures (paradigmxyz#18099) * feat: add EIP-7934 block size check to validateBuilderSubmissionV5 (paradigmxyz#18111) * chore: include err in log (paradigmxyz#18119) * fix(optimism): Prevent old pending flashblock from being returned from `pending_flashblock` (paradigmxyz#18103) * chore: make `caller_gas_allowance` an RPC trait method (paradigmxyz#18101) * fix(optimism): Fix endless poll on the FlashBlockService (paradigmxyz#18120) * chore: add prewarm traces (paradigmxyz#18117) * refactor(eth-wire): remove EthVersion::total_messages in favor of EthMessageID::max (paradigmxyz#17999) * fix(engine): Prevent instant miner from creating empty blocks (paradigmxyz#18108) Signed-off-by: 7suyash7 <suyashnyn1@gmail.com> * perf(engine): only clone headers instead of full blocks for tree tasks (paradigmxyz#18116) * fix(optimism): Verify that flashblocks are not old according to canon state (paradigmxyz#18123) * fix: import should count on the delta (paradigmxyz#17819) Signed-off-by: tmel <tmel0103@gmail.com> Signed-off-by: tmelhao <tmel0103@gmail.com> Co-authored-by: tmel <tmel0103@gmail.com> * feat: Forward transactions to a specified endpoint (paradigmxyz#17444) Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com> * feat(net): implement support of subprotocols (paradigmxyz#18080) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * fix(optimism): Fail if latest and base flashblock parent are different (paradigmxyz#18132) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * fix(txpool): ensure fee changes are updated (paradigmxyz#18137) * refactor: merge `EthTransactionValidator` and `EthTransactionValidatorInner` (paradigmxyz#18129) * docs(op): op chains don't require deposit contracts, so as dev chain (paradigmxyz#17988) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * feat: generalize impl EngineValidatorAddOn for OpAddOns (paradigmxyz#18141) * perf(engine): pre-allocate Vec capacity in payload processor (paradigmxyz#18148) * perf(engine): pre-allocate channel handles in prewarm task (paradigmxyz#18147) * chore(reth-optimism-storage): small refactor code (paradigmxyz#18104) * fix(trie): Fix call to update_account in witness (paradigmxyz#18154) * feat(optimism): add FlashblocksRx getter (paradigmxyz#18155) * perf(reth-invalid-block-hooks): use Reverts::eq reduce clone (paradigmxyz#18159) * perf(optimism): Pass noop provider to skip state root calculations for flashblocks (paradigmxyz#18161) * chore: Add 0x prefix and use macro (paradigmxyz#18156) * fix(optimism): find fb attrs in base fb (paradigmxyz#18164) * chore(deps): bump actions/upload-pages-artifact from 3 to 4 (paradigmxyz#18076) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * perf: optimize single-element collection creation (paradigmxyz#18168) * ci: Fix .PHONY declaration for install-reth-bench target in Makefile (paradigmxyz#18152) * fix: correct logical error in delete_outside_range error message (paradigmxyz#18031) * refactor: remove unnecessary PathBuf clone in CLI help generator (paradigmxyz#18172) * chore: simplify dev signed tx conversions (paradigmxyz#18171) * chore(deps): weekly `cargo update` (paradigmxyz#18174) Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> * perf(stages): optimize unwind operation by fetching headers instead full blocks (paradigmxyz#18139) * chore: avoid using hashmap hashers directly (paradigmxyz#18176) * feat: enhance engine tree metrics (paradigmxyz#18000) * perf(txpool): eliminate allocations in basefee enforcement (paradigmxyz#18162) * perf(optimism): use cached db in `FlashblockService` (paradigmxyz#18125) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * refactor(optimism): Extract responsibility to connect to a flashblock websocket stream (paradigmxyz#18158) * test ci on main * feat(examples): added txpoolExt_clearTxpool to existing example (paradigmxyz#18175) * fix: Pass prefix set from init_from_state_dump into compute_state_root (paradigmxyz#18185) * test(optimism): Cover successful decoding of websocket messages in `WsFlashBlockStream` (paradigmxyz#18163) * test(optimism): Cover the failure case of decoding a non-binary message in `WsFlashBlockStream` (paradigmxyz#18166) * test(optimism): Cover the case of stream returning errors in `WsFlashBlockStream` (paradigmxyz#18167) * test(optimism): Cover the case of repeatedly failing to connect to websocket in `WsFlashBlockStream` (paradigmxyz#18169) * dprint * fixes * fixes * fix: struct serialization to match actual fields (paradigmxyz#18189) * test(optimism): Test that streaming flashblocks from remote source is successful (paradigmxyz#18170) * fixes * fixes * fixes * resort * fixes * chore: simplify flashblocks poll logic (paradigmxyz#18194) Co-authored-by: julio4 <30329843+julio4@users.noreply.github.com> Co-authored-by: Roman Hodulák <roman.hodulak@polyglot-software.com> * fixes * chore: impl ExecutorTx for withtxenv (paradigmxyz#18202) * perf: prepare flashblock txs (paradigmxyz#18201) Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com> * fixes * local tar * try fork * try fork * fix: spawn flashblocks service as blocking (paradigmxyz#18214) * fixes * revert: "perf(txpool): eliminate allocations in basefee enforcement" (paradigmxyz#18215) * fix: incorrect blob fee comparison (paradigmxyz#18216) * fixes * add an extra check * add an extra check * fix(optimism): Prevent repeated executions of current flashblock sequence (paradigmxyz#18224) * fixes * try fix * added another check * added another check * test(optimism): Test that sequence stops before a gap (paradigmxyz#18228) * feat(optimism): Warn if `FlashBlockService` has stopped (paradigmxyz#18227) * chore: safe None check (paradigmxyz#18225) * chore: improve flashblock logs (paradigmxyz#18232) * fix(download): use updated merkle base URL (paradigmxyz#18236) * fixes * fixes * chore(engine): add better logs and spans for execution (paradigmxyz#18240) * chore(trie): use instrument instead of manual span (paradigmxyz#18239) * fix: filter zero storage values when computing withdrawals root in genesis header (paradigmxyz#18213) * enable by default * perf(reth-optimism-flashblocks): rm redundant clone (paradigmxyz#18196) * perf(txpool): eliminate allocations in basefee enforcement (paradigmxyz#18218) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * fixes * docs: update urls in docs (paradigmxyz#18245) * feat(optimism): Respond to ping messages with pong in `WsFlashBlockStream` (paradigmxyz#18212) * removed one check is_some * with new release * test(optimism): Test that `WsFlashBlockStream` pongs a ping (paradigmxyz#18217) * fixes * fixes * chore: downgrade debug to trace for peer reputation logs (paradigmxyz#18250) * feat: added amsterdam to hardforks * use alloy config * chore: unify engine downloader targets (paradigmxyz#18248) * fix(optimism): Compare parent hash and latest hash to invalidate cached flashblock (paradigmxyz#18238) * feat(optimism): Decode text messages in `WsFlashBlockStream` (paradigmxyz#18257) * chore: remove redundant payload trait bounds (paradigmxyz#18262) * hivd * feat(optimism): Respond to close messages in `WsFlashBlockStream` (paradigmxyz#18256) * fix(optimism): Reconnect if ws stream ends in `WsFlashBlockStream` (paradigmxyz#18226) * test(optimism): Test that UTF-8 encoded messages are received in `WsFlashBlockStream` (paradigmxyz#18269) * chore: log prune settings on unwind (paradigmxyz#18270) * feat:db * new tarball * new tarball * chore: extract `validate_against_parent_gas_limit` into separate fn (paradigmxyz#18277) * perf: rm redundant collect (paradigmxyz#18281) * fixes * fixes * 100 * rerun * rerun * rerun * tracing * perf: build local pending block without updates (paradigmxyz#18271) * perf(db): do not heap-allocate the stage key per query (paradigmxyz#18284) * chore(txpool): add sanity tests for blob fee bit handling (paradigmxyz#18258) * fix: check prune checkpoints for unwind target limit (paradigmxyz#18263) * perf: optimize send raw batching (paradigmxyz#18280) * perf: specialize single batch request (paradigmxyz#18289) * chore: delist unused deps with `cargo-machete` (paradigmxyz#18259) * test(optimism): Test that close message is responded to in `WsFlashBlockStream` (paradigmxyz#18268) * tracing * fixes * perf: specialize validate_transactions_with_origin for task validator (paradigmxyz#18288) * feat(metrics): add `TxPoolValidatorMetrics` to track inflight validation jobs (paradigmxyz#18295) * fixes * fixes * feat(gpo): add default fee price argument (paradigmxyz#18297) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * fixes * feat: introduce setting for delegated txs slots (paradigmxyz#18298) * feat: expose `EvmEnv` to `caller_gas_allowance` (paradigmxyz#18302) * perf: specialize len 1 (paradigmxyz#18307) * trace * chore: fix various typos in comments and documentation (paradigmxyz#18296) * perf(e2e-test-utils): optimize block checking by fetching header instead of full block (paradigmxyz#18254) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * feat: introduce maybe_pending method to StateProviderFactory (paradigmxyz#18260) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * chore: clippy happy (paradigmxyz#18310) * more trace * feat(download): support zst archives in reth download (paradigmxyz#18237) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * with new types * rerun * rerun * rerun * chore: introduce validationtask with capacity (paradigmxyz#18291) * chore(deps): weekly `cargo update` (paradigmxyz#18312) Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> * fix(rpc): error code `eth_sendRawTransactionSync` timeout (paradigmxyz#18252) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * fixes * fixe * fixes * fixes * chore(trie): dont warn on blinded node reveals (paradigmxyz#18317) * refactor(optimism): Extract pending block building responsibility out of `FlashBlockService` (paradigmxyz#18247) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * rerun * refactor: change PendingPool and PendingTransaction visibility to pub (paradigmxyz#18267) * refactor(engine): persistence logic (paradigmxyz#18318) * feat(optimism): flashblock completed sequences (paradigmxyz#18272) * fix * feat(trie): Add helper sub-command (paradigmxyz#18301) * ci: pin Rust to 1.88 when building for Windows in Cross (paradigmxyz#18320) * docs(reth-bench): fix markdown (paradigmxyz#18322) * fix(bench): fix deadlock in test data generation (paradigmxyz#18321) * fix(stateless): verify_execution_witness doc for pre-state mismatch (paradigmxyz#18319) * fix: DB benches (paradigmxyz#18314) * chore: bump version 1.7.0 (paradigmxyz#18323) * chore: bump docs version 1.7.0 (paradigmxyz#18326) * docs: update public dashboards (paradigmxyz#18331) * chore(trie): use read-only db handle during repair-trie dry-runs (paradigmxyz#18328) * chore(deps): bump actions/setup-go from 5 to 6 (paradigmxyz#18332) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump actions/github-script from 7 to 8 (paradigmxyz#18334) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump actions/stale from 9 to 10 (paradigmxyz#18335) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: cache latest built payload (paradigmxyz#18324) * perf(merkle-stage): only fetch checkpoint in the branch that needs it (paradigmxyz#18339) * fix: properly compute genesis hash (paradigmxyz#18300) * feat(op-reth/flashblocks): subscribe to the flashblock sequences produced (paradigmxyz#18276) Co-authored-by: julio4 <30329843+julio4@users.noreply.github.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * perf(reth-engine-local): use VecDeque reduce removal operations (paradigmxyz#18198) * fix(ci): pin teku image to fix kurtosis-op build (paradigmxyz#18345) * fix(stages): implement entities checkpoint update in merkle stage unwind (paradigmxyz#18131) * rerurn * perf: use debug_assert for parked pool lookup (paradigmxyz#17712) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * refactor(revm): (paradigmxyz#18150) use hardfork activation helpers (paradigmxyz#18349) Co-authored-by: Waiting-Chai <1753609696@qq.com> * feat(stateless): Run EEST tests in stateless block validator & bug fixes (paradigmxyz#18140) Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * feat: support customizable RPC namespace parsers (paradigmxyz#18160) Co-authored-by: Federico Gimenez <federico.gimenez@gmail.com> * fix(prune): TransactionLookup pruning issues with pre-merge expiry (paradigmxyz#18348) * feat(op-sdk): custom precompiles (paradigmxyz#18350) * fix: fix search in vocs doc (paradigmxyz#18354) * merge * fix * fix: add is_osaka check before erroring in default_ethereum_payload (paradigmxyz#18355) * perf: optimize canonical_hashes_range with Vec::with_capacity pre-allocation + benchmark (paradigmxyz#18072) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * feat: add some ethapi builder fns (paradigmxyz#18358) * fix(docs): include .vocs to retain search-index (paradigmxyz#18363) * feat(engine): check header validity after invalid transaction (paradigmxyz#18356) * fix(engine): avoid block fetching inconsistencies for checks during reorgs (paradigmxyz#18368) * feat: bump hive eest tests (paradigmxyz#18013) * fix: check payload id (paradigmxyz#18370) * perf(trie): Use ParallelSparseTrie (if enabled) for storage tries (paradigmxyz#17959) * fixes * refactor!: more type-safety in cli (paradigmxyz#18375) * feat: add helper aliases for node adapters (paradigmxyz#18366) * fix: relax nonce gap rule if configured (paradigmxyz#18385) * fix(docs): disable jekyll which removes the search-index (paradigmxyz#18388) * fix(docs): mv search-index to dist from .vocs (paradigmxyz#18390) * fix: map EIP-7623 gas floor errors to expected exception type for test compatibility (paradigmxyz#18389) * feat: replace PendingBlockAndReceipts tuple with dedicated struct (paradigmxyz#18395) * fix: still use real chain id for no-op network (paradigmxyz#18382) * chore: use decode_2718_exact for recover raw txs (paradigmxyz#18381) * chore: fixed broken link in history-expiry.mdx (paradigmxyz#18400) * fix(e2e): persist accepted header in CheckPayloadAccepted and align timestamp (paradigmxyz#18275) Co-authored-by: Federico Gimenez <federico.gimenez@gmail.com> Co-authored-by: Federico Gimenez <fgimenez@users.noreply.github.com> * chore: update e2e-test-utils code owners (paradigmxyz#18397) * perf(db): reuse MDBX DBIs for the same tx (paradigmxyz#18292) * feat(txpool): break down queued transaction states into specific reasons (paradigmxyz#18106) Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * fix: dont update canon chain to ancestor for opstack (paradigmxyz#18410) * feat(observability): add phase-level observablity to newPayload processing (paradigmxyz#18308) Co-authored-by: YK <chiayongkang@hotmail.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * perf: downsize mempool tx priority from `U256` to `u128` (paradigmxyz#18413) * chore(storage): remove unused `primed_dbis` (paradigmxyz#18415) * feat: fn recovered_tx to indexedTx (paradigmxyz#18421) * feat: add helper to PendingBlockAndReceipts (paradigmxyz#18423) * refactor and cleanup * fmt * fixes * clippy * clippy --------- Signed-off-by: 7suyash7 <suyashnyn1@gmail.com> Signed-off-by: tmel <tmel0103@gmail.com> Signed-off-by: tmelhao <tmel0103@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> Co-authored-by: 0xKitsune <77890308+0xKitsune@users.noreply.github.com> Co-authored-by: Roman Hodulák <roman.hodulak@polyglot-software.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> Co-authored-by: Hai | RISE <150876604+hai-rise@users.noreply.github.com> Co-authored-by: Dharm Singh <153282211+dharmvr1@users.noreply.github.com> Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com> Co-authored-by: nk_ysg <nk_ysg@163.com> Co-authored-by: leniram159 <leniram159@gmail.com> Co-authored-by: Andrea Simeoni <andreasimeoni84@gmail.com> Co-authored-by: Matus Kysel <MatusKysel@users.noreply.github.com> Co-authored-by: Suyash Nayan <89125422+7suyash7@users.noreply.github.com> Co-authored-by: Haotian <303518297@qq.com> Co-authored-by: tmel <tmel0103@gmail.com> Co-authored-by: Louis Brown <48462338+louisbrown0212@users.noreply.github.com> Co-authored-by: Max Bytefield <schoentgenaa@gmail.com> Co-authored-by: Eric Woolsey <ewoolsey@ualberta.ca> Co-authored-by: YK <chiayongkang@hotmail.com> Co-authored-by: Brian Picciano <me@mediocregopher.com> Co-authored-by: Jonas Bostoen <jonasbostoen@fastmail.com> Co-authored-by: quantix9 <quantix9@proton.me> Co-authored-by: Julio <30329843+julio4@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pepes <155114519+dennsikl@users.noreply.github.com> Co-authored-by: James Niken <155266991+dizer-ti@users.noreply.github.com> Co-authored-by: VolodymyrBg <aqdrgg19@gmail.com> Co-authored-by: David Klank <155117116+davidjsonn@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> Co-authored-by: smileclown2024 <167074920+smileclown2024@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Fynn <zcheng1004@gmail.com> Co-authored-by: Soubhik-10 <soubhiksmp2004@gmail.com> Co-authored-by: TMOT <166535397+Timosdev99@users.noreply.github.com> Co-authored-by: Brawn <nftdropped@gmail.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> Co-authored-by: Ivan Wang <wff19940326@gmail.com> Co-authored-by: Mablr <59505383+mablr@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Femi Bankole <llordbanks500@gmail.com> Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com> Co-authored-by: kien-rise <157339831+kien-rise@users.noreply.github.com> Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com> Co-authored-by: radik878 <radikpadik76@gmail.com> Co-authored-by: theo <80177219+theochap@users.noreply.github.com> Co-authored-by: Federico Gimenez <fgimenez@users.noreply.github.com> Co-authored-by: かとり <SarahADavisA@gmail.com> Co-authored-by: malik <aremumalik05@gmail.com> Co-authored-by: Waiting-Chai <1753609696@qq.com> Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com> Co-authored-by: Federico Gimenez <federico.gimenez@gmail.com> Co-authored-by: Léa Narzis <78718413+lean-apple@users.noreply.github.com> Co-authored-by: Rez <rez@berachain.com> Co-authored-by: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Co-authored-by: Soubhik Singha Mahapatra <160333583+Soubhik-10@users.noreply.github.com> Co-authored-by: stevencartavia <112043913+stevencartavia@users.noreply.github.com> Co-authored-by: Cypher Pepe <125112044+cypherpepe@users.noreply.github.com> Co-authored-by: Snezhkko <snezhkodaria38@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>




MDBX_dbiis an index into the MDBX environment to a table handle. We can safely share this index around unless we manually close and remove table handles from the MDBX environment (we don't).This PR takes the first step of sharing the DBIs across queries of the same DB transaction, which already yields lots of hits; each hit makes the query 6%-82% faster. For example, every single
getwas trying to create a new table handle (mdbx_dbi_open)...reth/crates/storage/db/src/implementation/mdbx/tx.rs
Line 293 in 0cdd548
A step further would be to pre-create and share the DBIs across all transactions.
No screenshot this one, as this path is literally everywhere 🫠.