Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Write buffer for Dispute Coordinator #3437

Closed
rphmeier opened this issue Jul 8, 2021 · 6 comments
Closed

Write buffer for Dispute Coordinator #3437

rphmeier opened this issue Jul 8, 2021 · 6 comments
Assignees
Labels
I10-optimisation An enhancement to provide better overall performance in terms of time-to-completion for a task. T5-parachains_protocol This PR/Issue is related to Parachains features and protocol changes.

Comments

@rphmeier
Copy link
Contributor

rphmeier commented Jul 8, 2021

Every ImportStatements call to the Dispute Coordinator currently results in a database write. It would make more sense to buffer writes over the course of several seconds and flush to disk based on size & time. We shouldn't go more than say, 30 seconds, without writing to disk, because data could be lost if the node shuts down. But there should be little to no downside to building up at least a few hundred kilobytes of statements in memory before writing to disk, over a short period of time.

We should also immediately flush anything which is the subject of an active dispute, because there may be DoS vectors that cause nodes to be taken down and statements on disputed candidates should be preserved at all costs.

@rphmeier rphmeier added the I10-optimisation An enhancement to provide better overall performance in terms of time-to-completion for a task. label Jul 8, 2021
@ordian
Copy link
Member

ordian commented Jul 8, 2021

We should be extra careful not to introduce a very big db transaction that could cause issues like #3242.

@rphmeier
Copy link
Contributor Author

rphmeier commented Jul 8, 2021

Do we have any idea of size limits to prevent that? I think even a conservative value of say 50-100K would be a huge improvement as most statements are just a few hundred bytes.

@Lldenaurois
Copy link
Contributor

Should we pick this up? It would probably be good to complete this work before we finalize disputes testing.

@rphmeier
Copy link
Contributor Author

It's an optimization issue, so the next obvious action item is to collect I/O and latency data from a network involving hundreds of validators and tens of parachains. That'll come as we scale up in the end phases of disputes testing. The data will tell us how necessary this is.

@eskimor
Copy link
Member

eskimor commented Nov 29, 2021

It seems to impact dispute import, see #4404

@eskimor
Copy link
Member

eskimor commented Aug 5, 2022

Ok we figured that the actual slowdown is coming from the quadratic complexity on import, which is going to be resolved via batching which in turn also results in less frequent db writes. Therefore we should be able to close this one.

@eskimor eskimor closed this as completed Aug 5, 2022
@ordian ordian moved this to Implemented in Parachains-core Aug 16, 2022
@ordian ordian added the T5-parachains_protocol This PR/Issue is related to Parachains features and protocol changes. label Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I10-optimisation An enhancement to provide better overall performance in terms of time-to-completion for a task. T5-parachains_protocol This PR/Issue is related to Parachains features and protocol changes.
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants