Skip to content

perf(memory): defer to_lowercase in extract_facts until triggers fire#608

Merged
matedev01 merged 2 commits into
GeniePod:mainfrom
jony376:perf/memory-defer-extract-lowercase
Jul 6, 2026
Merged

perf(memory): defer to_lowercase in extract_facts until triggers fire#608
matedev01 merged 2 commits into
GeniePod:mainfrom
jony376:perf/memory-defer-extract-lowercase

Conversation

@jony376

@jony376 jony376 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Defers the allocating to_lowercase() in extract_facts until an identity, preference, or relationship trigger is present. Common no-match utterances (weather, questions, chit-chat) now skip the lowercase allocation entirely while preserving byte-identical extraction output.

Fixes #607

Changes

  • needs_extract_facts_lower + ASCII case-insensitive trigger gates over the existing marker sets; to_lowercase() is built only when a gate fires.
  • Remember-only fast path: Remember … with no other triggers still works without allocating a lowercase buffer.
  • Extended the regression corpus with mixed-case no-match cases; updated extract_bench commentary.

Real Behavior Proof

  • I have built and run the affected code locally (or noted why I could not).
  • I have verified the change end-to-end on Jetson hardware.
  • I have NOT verified on Jetson hardware, and I explain the equivalent verification path or validation gap below.

Tested profile / hardware (check all that apply):

  • jetson
  • raspberry_pi
  • portable_sbc
  • laptop
  • mac
  • CI-only / docs-only
  • Not run locally

What I ran

No local Rust toolchain on this Windows dev machine (cargo not on PATH). Pushed branch and relied on upstream CI (cargo fmt, cargo clippy -D warnings, cargo test) for correctness proof. The extract_facts_corpus_regression integration test guards byte-identical output across identity, preference, relationship, remember, and no-match inputs including mixed case.

What I observed

Awaiting CI on push. Prior PRs (#562, #575) on the same repo validated the CI-only path; this change is confined to extract_facts with the existing differential corpus extended.

Test plan

  • cargo test -p genie-core extract_facts_corpus_regression
  • cargo test -p genie-core extract_
  • Optional Jetson: cargo test -p genie-core --release --ignored --nocapture bench_extract_facts and compare no-match per-call latency before/after

Notes for reviewers

The trigger gates mirror the existing lowercase substring checks from #495; only the order changes (gate before alloc, not after). Relationship still uses the "my " marker gate already present in extract_relationships.

@github-actions github-actions Bot added the performance performance improvement, but not verify on jetson label Jul 3, 2026
Skip the allocating Unicode lowercase view on common no-match utterances
(weather, questions, chit-chat) by gating on ASCII case-insensitive marker
scans before building the lowercased buffer. Remember-only inputs still
take a zero-alloc fast path.

Extended the extract_facts regression corpus with mixed-case no-match cases.

Co-authored-by: Cursor <cursoragent@cursor.com>

@matedev01 matedev01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — behavior-preserving (ascii-CI gating = old lowercasing for all-ASCII triggers), extended corpus regression covers no-match case. 826 lib, BFCL 96%.

@matedev01 matedev01 merged commit f4a314d into GeniePod:main Jul 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance performance improvement, but not verify on jetson

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(memory): defer extract_facts to_lowercase until triggers fire

2 participants