Skip to content

Batch Git note edits and add a Cargo benchmark example - #3004

Draft
Sebastian Thiel (Byron) wants to merge 2 commits into
mainfrom
gix-notes-example
Draft

Sebastian Thiel (Byron) wants to merge 2 commits into
mainfrom
gix-notes-example

Conversation

@Byron

Copy link
Copy Markdown
Member

Tasks

  • refackiew

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Summary

Bulk note creation previously serialized all materialized mappings after every edit. Add gix_note::State::edit() to stage changes and State::write() to flush a batch once. Lookups see staged changes, existing replace()/remove() calls still flush immediately, and failed writes recover the last successfully written tree.

Add gix-notes-bench as a normal Cargo example that creates one note per commit-graph entry, packs the final objects, and verifies every payload through a fresh object database before publishing an unused notes ref.

Context

  • Keep the gix-note API and regression coverage in one commit, followed by the benchmark integration in a second commit.
  • Gate the example on notes. Enable gix-pack's generate and streaming-input features through a dev-dependency with the existing version and path, keeping those additions out of normal library builds.
  • Existing Windows example checks and local Clippy checks with --all-targets cover the new example. No extra CI job is needed.
  • The old standalone package, profiling data, binaries, build output, and generated fixture archives are excluded from the PR.

Validation

All passed, reusing the cached build output and setting GIX_TEST_IGNORE_ARCHIVES=1:

  • cargo check -p gix --examples --locked --offline
  • cargo clippy -p gix --no-default-features --features sha1,notes --example gix-notes-bench --locked --offline -- -D warnings
  • cargo test -p gix-note --all-features --locked --offline — 17 tests
  • cargo test -p gix --no-default-features --features sha1,notes --test gix --locked --offline repository::note:: — six tests
  • cargo run -p gix --no-default-features --features sha1,notes --example gix-notes-bench -- --help
  • cargo fmt --all -- --check

Both test commands also passed with only the library commit applied. The final combined tree matches the validated tree. The normal dependency graph for gix with sha1,notes enables only object-cache-dynamic,sha1 on gix-pack. Existing removed-Clippy-lint and unused-test-helper warnings remain.

Earlier validation reported in the handoff covered a 12,000-note comparison with Git and two complete 1,367,969-note round trips. Those larger workloads were not rerun for this Cargo integration.

User Prompts

Finish integrating the notes benchmark as a normal Cargo example

Exclude generated files, binaries, and profiling artifacts.

Enable the required gix-pack features for examples/tests, preferably
through a dev-dependency using the existing dependency's version/path.
Avoid enabling these features for all normal gix library consumers.

Put the changes to gix-note into a separate commit.

$pr-from-session

Creating many notes with repeated `State::replace()` calls serializes all
materialized mappings after every edit. Add `State::edit()` to update
retained state and `State::write()` to serialize once. Lookups observe
pending edits, while immediate replacement and removal continue to flush.
Failed writes recover the last saved root.

Regression coverage checks zero writes during staging, cached reads,
persisted replacements and removals, non-note preservation, no-op flushes,
and recovery after failed writes.

Validation with `GIX_TEST_IGNORE_ARCHIVES=1`:

- `cargo test -p gix-note --all-features --locked --offline` (17 tests)
- `cargo test -p gix --no-default-features --features sha1,notes --test gix --locked --offline repository::note::` (6 tests)
Register `gix-notes-bench` as a normal `gix` example gated by `notes` so
Cargo example builds and Clippy cover it. It uses the staged notes API
to create one note per commit-graph entry, packs the final objects,
verifies them through a fresh object database, and only then creates
an unused notes ref.

Enable `gix-pack`'s `generate` and `streaming-input` features in a
dev-dependency using the existing version and path. This supplies the
features the standalone package previously got from `gix-pack` defaults
without enabling them for normal library consumers.

Validation:

- `cargo check -p gix --examples --locked --offline`
- `cargo clippy -p gix --no-default-features --features sha1,notes --example gix-notes-bench --locked --offline -- -D warnings`
- `cargo run -p gix --no-default-features --features sha1,notes --example gix-notes-bench -- --help`
- `cargo fmt --all -- --check`

The normal library dependency graph with `sha1,notes` enables only
`object-cache-dynamic,sha1` on `gix-pack`. The removed-Clippy-lint warning
comes from existing workspace configuration.
report("pack_and_index", pack_time, count);
report("write_total", create_time + pack_time, count);
println!("pack: {}", pack_path.display());
println!("notes_commit: {notes_commit_id}");
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.

3 participants