Page MenuHomePhabricator

[Chronik] Optimize SpentByWriter using merge ops
ClosedPublic

Authored by tobias_ruck on Aug 29 2023, 22:41.

Details

Reviewers
Fabien
bytesofman
Group Reviewers
Restricted Project
Commits
rABCbb6a7ba5dda1: [Chronik] Optimize SpentByWriter using merge ops
Summary

Speed up SpendByWriter significantly using merge ops: When chronikreindexing blocks 22000 to 221000, SpendByWriter::insert goes from 4.38s to 0.19s. When chronikreindexing the first 300000 blocks, it seems to shave off roughly 1700s, from 10059s to 8315.98s.

Depends on D14505.

Test Plan

ninja check-crates && ninja check-functional

Diff Detail

Repository
rABC Bitcoin ABC
Branch
chronik-optimize-spent-by
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24905
Build 49398: Build Diffbuild-chronik
Build 49397: arc lint + arc unit

Event Timeline

Add tests to test_catch_merge

Fix comment in apply_merge_spent_by

improvement looks great. code appears tested and effective.

tbh I really don't know what's going on here. Could you expand a bit on the diff summary?

using merge ops

What does this mean / what was being done before?

chronik/chronik-db/src/io/group_history.rs
169

what does ser mean here

chronik/chronik-db/src/io/spent_by.rs
558–572

what is this doing?

Fabien requested changes to this revision.Aug 31 2023, 08:03

Please split the fix out of the speedup, they can be landed separately

improvement looks great. code appears tested and effective.

tbh I really don't know what's going on here. Could you expand a bit on the diff summary?

using merge ops

What does this mean / what was being done before?

See D14393 for some history

chronik/chronik-db/src/io/group_history.rs
169

I think it's half of serdes

chronik/chronik-db/src/io/spent_by.rs
558–572

My understanding is that it's checking that the block disconnects doesn't impact the utxos that were not spent in that block. Previously the test was only checking for the state from the block txs, and not checking the side effects on other utxos.

This revision now requires changes to proceed.Aug 31 2023, 08:03
chronik/chronik-db/src/io/group_history.rs
169

It's short for "serialize"

chronik/chronik-db/src/io/spent_by.rs
558–572

👍

Fabien added inline comments.
chronik/chronik-db/src/io/spent_by.rs
139 ↗(On Diff #42278)

Not blocking: what's the rule here ? If the symbol is used once don't bother pulling it with a use statement ?

This revision is now accepted and ready to land.Sep 20 2023, 09:14

Use imported db_(de)serialize, add comment to clarify no-side-effect test