MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BenchTxGraphTrim

Function BenchTxGraphTrim

src/bench/txgraph.cpp:27–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void BenchTxGraphTrim(benchmark::Bench& bench)
28{
29 // The from-block transactions consist of 1000 fully linear clusters, each with 64
30 // transactions. The mempool contains 11 transactions that together merge all of these into
31 // a single cluster.
32 //
33 // (1000 chains of 64 transactions, 64000 T's total)
34 //
35 // T T T T T T T T
36 // | | | | | | | |
37 // T T T T T T T T
38 // | | | | | | | |
39 // T T T T T T T T
40 // | | | | | | | |
41 // T T T T T T T T
42 // (64 long) (64 long) (64 long) (64 long) (64 long) (64 long) (64 long) (64 long)
43 // | | | | | | | |
44 // | | / \ | / \ | | /
45 // \----------+--------/ \--------+--------/ \--------+-----+----+--------/
46 // | | |
47 // B B B
48 //
49 // (11 B's, each attaching to up to 100 chains of 64 T's)
50 //
51 /** The maximum cluster count used in this test. */
52 static constexpr int MAX_CLUSTER_COUNT = 64;
53 /** The number of "top" (from-block) chains of transactions. */
54 static constexpr int NUM_TOP_CHAINS = 1000;
55 /** The number of transactions per top chain. */
56 static constexpr int NUM_TX_PER_TOP_CHAIN = MAX_CLUSTER_COUNT;
57 /** The (maximum) number of dependencies per bottom transaction. */
58 static constexpr int NUM_DEPS_PER_BOTTOM_TX = 100;
59 /** Set a very large cluster size limit so that only the count limit is triggered. */
60 static constexpr int32_t MAX_CLUSTER_SIZE = 100'000 * 100;
61 /** Set a very high number for acceptable cost, so that we certainly benchmark optimal
62 * linearization. */
63 static constexpr uint64_t HIGH_ACCEPTABLE_COST = 100'000'000;
64
65 /** Refs to all top transactions. */
66 std::vector<TxGraph::Ref> top_refs;
67 /** Refs to all bottom transactions. */
68 std::vector<TxGraph::Ref> bottom_refs;
69 /** Indexes into top_refs for some transaction of each component, in arbitrary order.
70 * Initially these are the last transactions in each chains, but as bottom transactions are
71 * added, entries will be removed when they get merged, and randomized. */
72 std::vector<size_t> top_components;
73
74 InsecureRandomContext rng(11);
75 auto graph = MakeTxGraph(MAX_CLUSTER_COUNT, MAX_CLUSTER_SIZE, HIGH_ACCEPTABLE_COST, PointerComparator);
76
77 // Construct the top chains.
78 for (int chain = 0; chain < NUM_TOP_CHAINS; ++chain) {
79 for (int chaintx = 0; chaintx < NUM_TX_PER_TOP_CHAIN; ++chaintx) {
80 int64_t fee = rng.randbits<27>() + 100;
81 FeePerWeight feerate{fee, 1};
82 graph->AddTransaction(top_refs.emplace_back(), feerate);
83 // Add internal dependencies linking the chain transactions together.
84 if (chaintx > 0) {

Callers 1

TxGraphTrimFunction · 0.85

Calls 15

MakeTxGraphFunction · 0.85
rbeginMethod · 0.80
GetBlockBuilderMethod · 0.80
randrangeMethod · 0.80
epochsMethod · 0.80
epochIterationsMethod · 0.80
TrimMethod · 0.80
AddTransactionMethod · 0.45
emplace_backMethod · 0.45
AddDependencyMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected