refactor: move hash database from wow-mpq to warcraft-rs CLI#51
Merged
Conversation
The hash database maps filenames to MPQ hash values for file resolution when archives lack listfiles. This is an application-level concern, not a format parsing responsibility. Move the database module from wow-mpq to warcraft-rs and replace rusqlite with turso (async SQLite). This removes rusqlite (with bundled SQLite C compilation), directories, chrono, and glob from wow-mpq. Changes: - Promote calculate_mpq_hashes/calculate_het_hashes to wow_mpq::crypto - Create warcraft-rs/src/database/ with turso async API - Make CLI async with #[tokio::main] - Make mpq command dispatch, list_archive, execute_db_command async - Add standalone list_with_db and record_listfile_to_db helpers - Remove wow-mpq/src/database/ and related archive methods - Remove rusqlite, directories, chrono, glob from wow-mpq deps - Add tokio, turso, directories to warcraft-rs deps Closes #50
Profiling with perf/flamegraph revealed per-row fsync as the dominant bottleneck in store_filenames. Three optimizations applied: - Wrap all inserts in a single BEGIN/COMMIT transaction - Enable WAL journal mode and synchronous=NORMAL - Use prepare_cached to reuse compiled SQL across rows - Remove redundant SELECT existence check before each INSERT Benchmarks on art.MPQ (185k filenames): from ~6 min down to ~15s. Full import of all 5 WoW clients (714k filenames): ~18 min total.
Add flamegraph and inferno for performance profiling. Add node, cargo-binstall, wasm-pack, mdbook-mermaid. Reorganize into sections.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
The database module depends on turso and wow_mpq, which are only available when the mpq feature is enabled. Gate the module declaration and make turso/directories optional deps activated by the mpq feature. Fixes no-default-features build failure 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.
Summary
Closes #50.
wow-mpq(format library) towarcraft-rs(CLI application)rusqlitewithturso(async SQLite), making the CLI async via#[tokio::main]calculate_mpq_hashesandcalculate_het_hashestowow_mpq::cryptoand re-export from crate rootrusqlite(bundled SQLite C compilation),directories,chrono,globPerformance
Profiling with perf/flamegraph identified per-row fsync as the bottleneck. Three optimizations applied:
Tested against
All 5 WoW client versions with original MPQ archives:
wow-update-*patches)wow-update-*patches)714,916 unique filenames recorded. All
dbsubcommands verified:status,lookup,list --use-db,--record-to-db.Test plan
cargo clippy --workspacecleancargo test --workspacepassesmpq db statusshows database location and countmpq list <archive> --record-to-dbrecords filenamesmpq db lookup <filename>finds hash entriesmpq list <archive> --use-dbresolves unnamed files