-
Notifications
You must be signed in to change notification settings - Fork 937
Fix nagle, other minor optimizations #8222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rustyrussell
wants to merge
8
commits into
ElementsProject:master
Choose a base branch
from
rustyrussell:guilt/fix-tcp-cork
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix nagle, other minor optimizations #8222
rustyrussell
wants to merge
8
commits into
ElementsProject:master
from
rustyrussell:guilt/fix-tcp-cork
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Rusty Russell <[email protected]>
Our CORK logic was wrong, and it's better to use Nagle anyway: we disable Nagle just before sending timing-critical messages. Time for 100 (failed) payments: Before: 148.8573575 After: 10.7356977 Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: Protocol: Removed 200ms latency from sending commit/revoke messages.
To run, use: VALGRIND=0 TEST_BENCH=1 pytest tests/test_connection.py::test_bench Example of running on my laptop (without --enable-debugbuild): FAILED tests/test_connection.py::test_bench - assert 53.11918330192566 == 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 stand out: 1. Tracing in db_exec_prepared_v2: 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]>
…hecking. Before: 92.26076173782349 91.9576666355133 90.92732524871826 After: 90.5989830493927 88.10309219360352 90.07689118385315
Signed-off-by: Rusty Russell <[email protected]>
If nobody is subscribed, have notify_start return NULL and the caller can skip serialization. This is particularly useful for the "log" notification which can get called a lot. Signed-off-by: Rusty Russell <[email protected]>
This means we don't have to iterate through all plugins, making our "do we even have to construct this notification" optimization much more efficient. Signed-off-by: Rusty Russell <[email protected]>
This speeds logging slightly, but most of the time is actually spent in fflush() (which we need). Result: FAILED tests/test_connection.py::test_bench - assert 51.54966354370117 == 0 Signed-off-by: Rusty Russell <[email protected]>
63a2a8b
to
545970f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed we were not going as fast as we should, in a 100-payments test. Turns out our Nagle-suppressing code was wrong!
Then I continued with minor optimization until our profiling basically only contained sqlite operations.