Skip to content
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

LNS: Commit to db more conservatively instead of every block #1152

Merged
merged 3 commits into from
May 15, 2020

Conversation

Doy-lee
Copy link
Collaborator

@Doy-lee Doy-lee commented May 14, 2020

Instead of committing every block, commit everytime we know the DB has
changed and on shutdown. Upon profiling, every block added was taking an
additional ~9ms from HF15 because of save_settings(...) writing the
block hash and height to the DB.

If the daemon crashes during operation, then LNS only needs to scan
empty blocks up until that point which shouldn't be too slow and the
exception, not the norm.

Instead of committing every block, commit everytime we know the DB has
changed and on shutdown. Upon profiling, every block added was taking an
additional ~9ms from HF15 because of `save_settings(...)` writing the
block hash and height to the DB.

If the daemon crashes during operation, then LNS only needs to scan
empty blocks up until that point which shouldn't be too slow and the
exception, not the norm.
@jagerman
Copy link
Member

jagerman commented May 14, 2020

9ms seems like an eternity, and sounds more like disk IO time than CPU time. It might be caused by the sqlite synchronization settings: it might be worth seeing if WAL mode + synchronous = NORMAL helps here (it would probably help with all write queries, not just this one).

@Doy-lee
Copy link
Collaborator Author

Doy-lee commented May 15, 2020

It is disk IO, problem is completely gone if you write to an in memory DB. With WAL + synchronous, standalone it also similarly brings performance inline with the current PR.

Combined together shaves off another 100ms or so for processing 1k blocks (as of so far, rescanning the LNS db on the Mainnet).

@Doy-lee Doy-lee merged commit 8782f57 into oxen-io:master May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants