Improve chanmon_consistency fuzz target performance#4509
Draft
joostjager wants to merge 3 commits intolightningdevkit:mainfrom
Draft
Improve chanmon_consistency fuzz target performance#4509joostjager wants to merge 3 commits intolightningdevkit:mainfrom
joostjager wants to merge 3 commits intolightningdevkit:mainfrom
Conversation
The searched-for log message ("Outbound update_fee HTLC buffer
overflow") no longer exists in the lightning crate, so the
from_utf8 + contains check on every log line was pure waste.
AI tools were used in preparing this commit.
Even though DevNull discards the bytes, the formatting work (SubstringFormatter, fmt::write, from_utf8) was still being done on every log call. Short-circuit in TestLogger::log via a TypeId check, which monomorphization resolves at compile time. AI tools were used in preparing this commit.
Previously, TestChainMonitor::update_channel would deserialize the monitor from stored bytes, apply the update, and serialize it back. This duplicated the work already done by the inner ChainMonitor, which applies the update to its in-memory monitor and calls the persister. Instead, have TestPersister capture the monitor directly when the real ChainMonitor calls persist. Serialization is deferred until reload_node actually needs the bytes, which happens rarely (only on specific fuzz input bytes that trigger a node restart). This eliminates redundant deserialization and serialization on every monitor update, replacing the expensive serialize-on-every-persist with a cheaper clone. AI tools were used in preparing this commit.
|
👋 Hi! I see this is a draft PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4509 +/- ##
==========================================
- Coverage 86.19% 86.18% -0.02%
==========================================
Files 160 160
Lines 107537 107537
Branches 107537 107537
==========================================
- Hits 92693 92679 -14
- Misses 12220 12230 +10
- Partials 2624 2628 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
I can now see that on CI the speed up is a bit less than on my local machine. Factor 2.5x in CI. |
This file contains hidden or 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
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.
Reduce per-iteration overhead in the chanmon_consistency fuzz target. Together these achieve a 3-4x speedup. This target has proven crucial for finding bugs, so maximizing its iteration rate is relevant.