Skip to content

Sort submissions by metadata count - #164

Merged
OpsBotPrime merged 10 commits into
masterfrom
jerbaroo-faster-prefer-distinct
Aug 19, 2026
Merged

Sort submissions by metadata count#164
OpsBotPrime merged 10 commits into
masterfrom
jerbaroo-faster-prefer-distinct

Conversation

@jerbaroo

@jerbaroo jerbaroo commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR makes changes to how the chunk selection query of the PreferDistinct strategy. In the Files changed tab, you can see the impact on the benchmark SVG .

Key changes:

  • Includes a test of fairness in the Python test suite.
  • We no longer do index walks over all chunks, instead we sort submissions by metadata.
  • Already-reserved check is from SQLite via FFI, commit from @ReinierMaas
  • Metadata counts are not passed to SQLite via the generated query, but rather checked from SQLite via FFI, commit from @ReinierMaas

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves PreferDistinct selection from chunk scans to metadata-ranked submission selection with indexed chunk lookup.

Changes:

  • Ranks submissions using reservation metadata exposed through SQLite FFI.
  • Adds submission random-order indexing and simplifies metastate tracking.
  • Adds fairness and reservation-filtering tests.

Reviewed changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
workspace-hack/Cargo.toml Updates generated dependency features.
opsqueue/src/consumer/strategy.rs Reworks strategy query generation.
opsqueue/src/consumer/dispatcher/reserver.rs Exposes reservation lookup.
opsqueue/src/consumer/dispatcher/mod.rs Registers SQLite FFI callbacks.
opsqueue/src/consumer/dispatcher/metastate.rs Simplifies counts and adds JSON export.
opsqueue/src/common/submission.rs Reuses one SQL parameter.
opsqueue/src/common/chunk.rs Adds signed chunk-index conversion.
opsqueue/migrations/20260803133844_add_random_order_index_to_submissions.up.sql Adds submission random ordering.
opsqueue/migrations/20260803133844_add_random_order_index_to_submissions.down.sql Reverts submission random ordering.
opsqueue/Cargo.toml Adds SQLite FFI dependency.
libs/opsqueue_python/tests/test_roundtrip.py Tests PreferDistinct fairness.
Cargo.toml Defines the workspace SQLite dependency.
Cargo.lock Updates resolved dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread opsqueue/src/consumer/strategy.rs
Comment thread opsqueue/src/consumer/dispatcher/mod.rs
Comment thread opsqueue/migrations/20260803133844_add_random_order_index_to_submissions.up.sql Outdated
@jerbaroo
jerbaroo force-pushed the jerbaroo-faster-prefer-distinct branch 2 times, most recently from 525fbdf to 4887d3d Compare August 10, 2026 15:04
@jerbaroo
jerbaroo marked this pull request as ready for review August 10, 2026 15:14
@jerbaroo
jerbaroo requested a review from ReinierMaas August 10, 2026 15:20
@ReinierMaas

Copy link
Copy Markdown
Member

There are some CI failures but the changes in the last fixup don't explain the errors on CI... Are they introduced with the rebase?

@jerbaroo jerbaroo self-assigned this Aug 11, 2026
@jerbaroo

Copy link
Copy Markdown
Contributor Author

There are some CI failures but the changes in the last fixup don't explain the errors on CI... Are they introduced with the rebase?

Somehow I had incorrectly generated the DB migrations. Re-generated opsqueue/opsqueue_example_database_schema.db in d644aa5

@ReinierMaas ReinierMaas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to review: opsqueue/src/consumer/strategy.rs

Comment thread libs/opsqueue_python/tests/test_roundtrip.py
Comment thread opsqueue/src/consumer/dispatcher/mod.rs Outdated
Comment thread opsqueue/src/consumer/dispatcher/metastate.rs
Comment thread opsqueue/src/consumer/dispatcher/mod.rs Outdated
@ReinierMaas
ReinierMaas self-requested a review August 11, 2026 15:01

@ReinierMaas ReinierMaas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I left some more changes but I think that covers all.

Comment thread opsqueue/src/consumer/strategy.rs Outdated
Comment thread opsqueue/src/consumer/strategy.rs Outdated
Comment thread opsqueue/src/consumer/strategy.rs Outdated
Comment thread opsqueue/src/consumer/strategy.rs Outdated
Comment thread opsqueue/src/consumer/strategy.rs
Comment thread opsqueue/src/consumer/strategy.rs Outdated
Comment thread opsqueue/src/consumer/dispatcher/mod.rs Outdated
Comment thread opsqueue/src/consumer/dispatcher/mod.rs Outdated
Comment thread opsqueue/src/consumer/strategy.rs Outdated
Comment thread opsqueue/src/consumer/strategy.rs Outdated
@jerbaroo

jerbaroo commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

LGTM! I left some more changes but I think that covers all.

Thanks for the comprehensive review! Educational :)

Comments are addressed and merge conflicts resolved. Will deploy first thing in the morning.

@jerbaroo

Copy link
Copy Markdown
Contributor Author

@OpsBotPrime merge and tag

@OpsBotPrime

Copy link
Copy Markdown
Contributor

Failed to rebase, please rebase manually using

git fetch && git rebase --interactive --autosquash --no-keep-empty origin/master jerbaroo-faster-prefer-distinct

@jerbaroo
jerbaroo force-pushed the jerbaroo-faster-prefer-distinct branch from fe09d4d to adea587 Compare August 19, 2026 08:13
@jerbaroo

Copy link
Copy Markdown
Contributor Author

@OpsBotPrime merge and tag

Approved-by: jerbaroo
Priority: Normal
Auto-deploy: false
@OpsBotPrime

Copy link
Copy Markdown
Contributor

Rebased as 1aaa74d, waiting for CI …

@OpsBotPrime

Copy link
Copy Markdown
Contributor

CI job 🟡 started.

@OpsBotPrime

Copy link
Copy Markdown
Contributor

@jerbaroo I tagged your PR with v60. Please wait for the build of 1aaa74d to pass and don't forget to deploy it!

@OpsBotPrime
OpsBotPrime merged commit 1aaa74d into master Aug 19, 2026
5 of 7 checks passed
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.

4 participants