Skip to content

Commit 3cd589d

Browse files
committed
bench: why does sending payments take so long under CI?
To run, use: VALGRIND=0 TEST_BENCH=1 eatmydata pytest tests/test_connection.py::test_bench Example of running on my laptop (without --enable-debugbuild, over of 10 runs): FAILED tests/test_connection.py::test_bench - assert 47.403406-49.191765(48.343+/-0.48) == 0 With eatmydata: FAILED tests/test_connection.py::test_bench - assert 25.867860-27.549878(26.5762+/-0.5) == 0 You can also run perf on l1 once it's running: perf record --call-graph dwarf -q -p $(cat /tmp/ltests-*/test_bench_1/lightning-1/lightningd-regtest.pid) Then ^C after 10 seconds and run "perf report". Things which stood out: 1. Tracing in db_exec_prepared_v2 (fixed in another PR) 31.12% 0.04% lightningd lightningd [.] db_exec_prepared_v2 - 31.08% db_exec_prepared_v2 + 22.96% db_sqlite3_exec + 4.46% trace_span_end + 1.77% trace_span_start + 1.11% trace_span_tag + 0.72% tal_free 2. Logging: - 16.03% logv - 8.15% maybe_print - log_to_files + 4.51% __GI__IO_fflush (inlined) + 1.97% tal_fmt_ + 0.51% __GI___strftime_l (inlined) 3. Notification (when nothing is listening) in notify_log: - 6.84% maybe_notify_log - notify_log + 3.37% notify_send + 1.75% notify_start + 1.71% log_notification_serialize 0.56% new_log_entry Signed-off-by: Rusty Russell <[email protected]>
1 parent e27dee0 commit 3cd589d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/test_connection.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4846,6 +4846,41 @@ def test_no_delay(node_factory):
48464846
assert end < start + 100 * 0.5
48474847

48484848

4849+
@unittest.skipIf(os.getenv('TEST_BENCH', '0') == '0', "For profiling")
4850+
def test_bench(node_factory):
4851+
"""Is our Nagle disabling for critical messages working?"""
4852+
l1, l2 = node_factory.get_nodes(2, opts={'start': False,
4853+
'commit-time': 0})
4854+
4855+
# memleak detection plays havoc with profiles.
4856+
del l1.daemon.env["LIGHTNINGD_DEV_MEMLEAK"]
4857+
del l2.daemon.env["LIGHTNINGD_DEV_MEMLEAK"]
4858+
4859+
l1.start()
4860+
l2.start()
4861+
node_factory.join_nodes([l1, l2])
4862+
4863+
scid = only_one(l1.rpc.listpeerchannels()['channels'])['short_channel_id']
4864+
routestep = {
4865+
'amount_msat': 100,
4866+
'id': l2.info['id'],
4867+
'delay': 5,
4868+
'channel': scid
4869+
}
4870+
4871+
start = time.time()
4872+
# If we were stupid enough to leave Nagle enabled, this would add 200ms
4873+
# seconds delays each way!
4874+
for _ in range(1000):
4875+
phash = random.randbytes(32).hex()
4876+
l1.rpc.sendpay([routestep], phash)
4877+
with pytest.raises(RpcError, match="WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS"):
4878+
l1.rpc.waitsendpay(phash)
4879+
end = time.time()
4880+
duration = end - start
4881+
assert duration == 0
4882+
4883+
48494884
def test_listpeerchannels_by_scid(node_factory):
48504885
l1, l2, l3 = node_factory.line_graph(3, announce_channels=False)
48514886

0 commit comments

Comments
 (0)