-
Notifications
You must be signed in to change notification settings - Fork 412
feat: Make MonitorUpdatingPersister change persist type based on size #3834
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
base: main
Are you sure you want to change the base?
feat: Make MonitorUpdatingPersister change persist type based on size #3834
Conversation
👋 Thanks for assigning @tnull as a reviewer! |
/// For small channel monitors (below `minimum_monitor_size_for_updates` bytes when serialized), | ||
/// this persister will always write the full monitor instead of individual updates. This avoids | ||
/// the overhead of managing update files and later compaction for tiny monitors that don't benefit | ||
/// from differential updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still not clear to me how much the gain is of this in practice. Also worried that disabling the incremental path initially allow certain bugs to linger for longer, just because the path isn't hit as much, or rarely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, but can we add some test coverage for the new behavior?
Additionally, benchmarks would indeed very helpful to evaluate what a reasonable threshold value would be.
ac6966e
to
c6ad41b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrite your commit history so that it's clear what are feature and fixup commits. Each commit message should have a clear headline followed by some paragraph(s) describing the change, where it happened, and why it was necessary. For guidance, please take a look at https://cbea.ms/git-commit/
Introduces an optimization to the MonitorUpdatingPersister to avoid writing differential updates for small channel monitors. When a channel monitor is smaller than a configurable threshold , the persister will now write the full monitor instead of an update. This avoids the I/O overhead of creating and managing many small update files for monitors that don't benefit significantly from differential updates.
Adds unit test for introduced size based optimisation. Also updates the old unit test to use a threshold value and use constructors to increase test coverage
357ce4b
to
b313e39
Compare
I have created a minimal benchmarking setup here for this. from this I get that adding update based persistence is reducing the performance completely opposite to what is claimed in the issue . [There are a lot of assumptions in the benchmarking regarding the update size and monitor sizes ] |
I'm not sure we can conclude all that much from a local-filesystem benchmark, sadly. We have several users (and hopefully more soon with |
Thanks for taking a first look at these benchmarks. How did you arrive at some of these assumptions? E.g., how did you decide on the 8KB threshold being 'large' monitors. I believe in reality monitors could end up being much larger. Maybe @TheBlueMatt can provide some realistic monitor sizes here? I'm asking because I suspect the results may stem from a latency vs. throughput trade-off, and under certain circumstances one might dominate over the other. The filesystem store for example likely (especially assuming that most file systems by now have 4kb block size) does not incur that much more latency when reading/writing 'larger' monitors (as 8kb is still tiny and the syscall / IO latency likely the dominant factor), while persistence to a remote server would see much slower write speeds and hence higher latency when (re-)persisting full monitors. |
Yea, so 8KiB is a reasonable "channel that got opened and has only done a handful of HTLC operations in its history" threshold (tho is maybe even a bit too small for a more active mobile wallet). On my routing node the largest monitor is ~73MiB, I imagine c= has some that get into the hundreds of MiB. |
My assumptions here were to test the crossover point to select what was the optimal value of the threshold . Since the talks in the issue for threshold were in kBs , I assumed them to be in the same range and didn't go as far as to check the monitors in MB range and the results I was getting was becoming worse as I was moving towards bigger sizes which also made me not go higher. So the comments to monitor sizes in benchmark are not of much significance as they were relative to 4kB monitor size. |
changes the threshold value to 8192 bytes as suggested in the PR comments
41c5253
to
9b4508b
Compare
Left some thoughts on the issue, since my thoughts aren't about this implementation but more the feature itself. But posting here since this is where the recent action is. 🙇 |
Concept ACK |
fixes #3770
minimum_monitor_size_for_updates
to specify the minimum size for full persistence to be activatednew_with_default_threshold
function to setupMonitorUpdatingPersister
with a defaultminimum_monitor_size_for_updates
value