8000 Performance/Asynchronous database backend by carljohnsen · Pull Request #6360 · duplicati/duplicati · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Performance/Asynchronous database backend #6360

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
wants to merge 355 commits into
base: master
Choose a base branch
from

Conversation

carljohnsen
Copy link
Contributor
@carljohnsen carljohnsen commented Jun 19, 2025 8000

This pull request migrates the database backend to Microsoft.Data.Sqlite, unlocking improved performance and enabling full support for asynchronous operations.

While it's not a proper benchmark, on my machine, running the test suite went from ~1600 seconds on the current master branch to ~1300 seconds on this branch, demonstrating a ~1.23x performance improvement purely from the new database backend.

Major changes

  • Full Async Refactor: Migrated all database operations to async to improve scalability and responsiveness, especially under high load or I/O-bound scenarios.
  • Deferred Transactions: Switched to deferred transactions to allow greater concurrency and reduce locking contention, improving reliability.
  • Removed IDb Usage: Eliminated the IDb interface to simplify the codebase and leverage features specific to Microsoft.Data.Sqlite.
  • Factory Instantiation Pattern: Adopted factory methods for object creation to support async initialization, making setup explicit and avoiding heavy work in constructors.
  • Property Refactor: Refactored properties to be lightweight and synchronous, moving any heavy or async logic to methods for clarity and maintainability.
  • .Cast() Fixes: Corrected improper .Cast<object>() usage to prevent runtime errors and ensure type safety.
  • Constructor Chain Parity: Ensured new factory methods replicate the logic of previous constructor chains to maintain consistent behavior.
  • Transaction Disposal: Verified that disposing transactions still triggers rollbacks as before, preserving data integrity.
  • Livelock Fix: Added locking in FileProcessor to resolve a livelock during restore, improving reliability.
  • ConfigureAwait(false): Applied ConfigureAwait(false) to async database calls to avoid deadlocks and improve context management.
  • Explicit Transaction Handling: Internalized transaction management for safety, while still allowing external commits as needed, simplifying usage.
  • Docstrings: Enhanced or added docstrings for better documentation and developer understanding.
  • SQL Query Formatting: Standardized SQL queries to use double quotes for identifiers, ensuring consistency and compatibility.
  • Async Propagation: Updated calling functions to propagate async changes, including use of await foreach for collections, to fully leverage async benefits.
  • Async Disposal: Adopted await using for async disposables to ensure proper resource cleanup.
  • Chained Command Execution: Chained multiple database commands for improved clarity and correctness.
  • CancellationToken Propagation: Propagated CancellationToken parameters to support cooperative cancellation and responsive shutdowns.
  • Database Pragmas: Updated default pragmas for better performance and reliability based on best practices.
  • SQLite Page Cache: Removed page cache setting, delegating configuration to environment variables for flexibility.

…vironment variable, or some other way of providing a custom database configurotion
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.

1 participant
0