Skip to content

cache session schema names#2

Open
Goldziher wants to merge 1 commit into
chore/upgrade-ort-rc12from
chore/optimize-hot-path
Open

cache session schema names#2
Goldziher wants to merge 1 commit into
chore/upgrade-ort-rc12from
chore/optimize-hot-path

Conversation

@Goldziher

Copy link
Copy Markdown
Member

Summary

Cache the actual session input/output names (HashSet<String>) once at Model::new / new_from_bytes instead of rebuilding them on every inference call. Schema validation also moves out from under inference_lock since it only reads cached state.

Published as kreuzberg-orp 0.1.1.

Stacks on #1 (chore/upgrade-ort-rc12). Companion: kreuzberg-gliner-rs PR.

Test plan

  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo build --all-targets --all-features
  • Benchmark against an unoptimised baseline once we have a criterion harness in gline-rs.

`Model::check_schema` was rebuilding a `HashSet<&str>` from
`session.inputs()/outputs()` on every inference call. Cache the actual
input/output names as `HashSet<String>` once at `Model::new` /
`new_from_bytes` (extracted via a new `wrap` helper) and have
`check_schema` walk the pipeline's expected iterator against the cached
sets — no per-call session-side allocation. The error path still
materialises a `HashSet<&str>` for the diagnostic.

Also moves schema validation out from under the `inference_lock`: it
only reads cached state, so blocking other inferences while we check it
is unnecessary.
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