Skip to content

Commit 36a6584

Browse files
committed
tracing: correctly scope utxocache:flush tracepoint
Previously, the `utxocache:flush` tracepoint was in the wrong scope and reached every time `CChainState::FlushStateToDisk` was called, even when there was no flushing of the cache. The tracepoint is now properly scoped and will be reached during a full flush. Inside the scope, the `fDoFullFlush` value will always be `true`, so it doesn't need to be logged separately. Hence, it's dropped from the tracepoint arguments.
1 parent 5d91133 commit 36a6584

File tree

4 files changed

+16
-35
lines changed

4 files changed

+16
-35
lines changed

contrib/tracing/README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Histogram of block connection times in milliseconds (ms).
237237

238238
### log_utxocache_flush.py
239239

240-
A BCC Python script to log the cache and index flushes. Based on the
240+
A BCC Python script to log the UTXO cache flushes. Based on the
241241
`utxocache:flush` tracepoint.
242242

243243
```bash
@@ -246,23 +246,10 @@ $ python3 contrib/tracing/log_utxocache_flush.py ./src/bitcoind
246246

247247
```
248248
Logging utxocache flushes. Ctrl-C to end...
249-
Duration (µs) Mode Coins Count Memory Usage Prune Full Flush
250-
0 PERIODIC 28484 3929.87 kB False False
251-
1 PERIODIC 28485 3930.00 kB False False
252-
0 PERIODIC 28489 3930.51 kB False False
253-
1 PERIODIC 28490 3930.64 kB False False
254-
0 PERIODIC 28491 3930.77 kB False False
255-
0 PERIODIC 28491 3930.77 kB False False
256-
0 PERIODIC 28496 3931.41 kB False False
257-
1 PERIODIC 28496 3931.41 kB False False
258-
0 PERIODIC 28497 3931.54 kB False False
259-
1 PERIODIC 28497 3931.54 kB False False
260-
1 PERIODIC 28499 3931.79 kB False False
261-
.
262-
.
263-
.
264-
53788 ALWAYS 30076 4136.27 kB False False
265-
7463 ALWAYS 0 245.84 kB False False
249+
Duration (µs) Mode Coins Count Memory Usage Prune
250+
730451 IF_NEEDED 22990 3323.54 kB True
251+
637657 ALWAYS 122320 17124.80 kB False
252+
81349 ALWAYS 0 1383.49 kB False
266253
```
267254

268255
### log_utxos.bt

contrib/tracing/log_utxocache_flush.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
u64 coins_count;
2121
u64 coins_mem_usage;
2222
bool is_flush_prune;
23-
bool is_full_flush;
2423
};
2524
2625
// BPF perf buffer to push the data to user space.
@@ -33,7 +32,6 @@
3332
bpf_usdt_readarg(3, ctx, &data.coins_count);
3433
bpf_usdt_readarg(4, ctx, &data.coins_mem_usage);
3534
bpf_usdt_readarg(5, ctx, &data.is_flush_prune);
36-
bpf_usdt_readarg(5, ctx, &data.is_full_flush);
3735
flush.perf_submit(ctx, &data, sizeof(data));
3836
return 0;
3937
}
@@ -55,18 +53,16 @@ class Data(ctypes.Structure):
5553
("coins_count", ctypes.c_uint64),
5654
("coins_mem_usage", ctypes.c_uint64),
5755
("is_flush_prune", ctypes.c_bool),
58-
("is_full_flush", ctypes.c_bool)
5956
]
6057

6158

6259
def print_event(event):
63-
print("%-15d %-10s %-15d %-15s %-8s %-8s" % (
60+
print("%-15d %-10s %-15d %-15s %-8s" % (
6461
event.duration,
6562
FLUSH_MODES[event.mode],
6663
event.coins_count,
6764
"%.2f kB" % (event.coins_mem_usage/1000),
6865
event.is_flush_prune,
69-
event.is_full_flush
7066
))
7167

7268

@@ -87,9 +83,9 @@ def handle_flush(_, data, size):
8783

8884
b["flush"].open_perf_buffer(handle_flush)
8985
print("Logging utxocache flushes. Ctrl-C to end...")
90-
print("%-15s %-10s %-15s %-15s %-8s %-8s" % ("Duration (µs)", "Mode",
91-
"Coins Count", "Memory Usage",
92-
"Prune", "Full Flush"))
86+
print("%-15s %-10s %-15s %-15s %-8s" % ("Duration (µs)", "Mode",
87+
"Coins Count", "Memory Usage",
88+
"Prune"))
9389

9490
while True:
9591
try:

doc/tracing.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Arguments passed:
112112

113113
#### Tracepoint `utxocache:flush`
114114

115-
Is called *after* the caches and indexes are flushed depending on the mode
115+
Is called *after* the caches are flushed depending on the mode
116116
`CChainState::FlushStateToDisk` is called with.
117117

118118
Arguments passed:
@@ -122,7 +122,6 @@ Arguments passed:
122122
3. Number of coins flushed as `uint64`
123123
4. Memory usage in bytes as `uint64`
124124
5. If the flush was pruned as `bool`
125-
6. If it was full flush as `bool`
126125

127126
#### Tracepoint `utxocache:add`
128127

src/validation.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,14 +2324,13 @@ bool CChainState::FlushStateToDisk(
23242324
return AbortNode(state, "Failed to write to coin database");
23252325
nLastFlush = nNow;
23262326
full_flush_completed = true;
2327+
TRACE5(utxocache, flush,
2328+
(int64_t)(GetTimeMicros() - nNow.count()), // in microseconds (µs)
2329+
(u_int32_t)mode,
2330+
(u_int64_t)coins_count,
2331+
(u_int64_t)coins_mem_usage,
2332+
(bool)fFlushForPrune);
23272333
}
2328-
TRACE6(utxocache, flush,
2329-
(int64_t)(GetTimeMicros() - nNow.count()), // in microseconds (µs)
2330-
(u_int32_t)mode,
2331-
(u_int64_t)coins_count,
2332-
(u_int64_t)coins_mem_usage,
2333-
(bool)fFlushForPrune,
2334-
(bool)fDoFullFlush);
23352334
}
23362335
if (full_flush_completed) {
23372336
// Update best block in wallet (so we can detect restored wallets).

0 commit comments

Comments
 (0)