perf(cat/grep/cli): per-file overhead cuts and faster cold start - #194
Closed
nwaughachukwuma wants to merge 1 commit into
Closed
perf(cat/grep/cli): per-file overhead cuts and faster cold start#194nwaughachukwuma wants to merge 1 commit into
nwaughachukwuma wants to merge 1 commit into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
nwaughachukwuma
commented
Aug 3, 2026
nwaughachukwuma
left a comment
Collaborator
Author
There was a problem hiding this comment.
@claude please followup
Comment on lines
416
to
428
| def _count_keyframes(self) -> int: | ||
| """Quick I-frame count via demux-level skip.""" | ||
| """I-frame count from packet flags only — demux, no decode.""" | ||
| import av | ||
|
|
||
| container = av.open(str(self._path)) | ||
| try: | ||
| stream = container.streams.video[0] | ||
| stream.codec_context.skip_frame = "NONKEY" | ||
| count = 0 | ||
| for packet in container.demux(stream): | ||
| for _ in packet.decode(): | ||
| if packet.is_keyframe and packet.pts is not None: | ||
| count += 1 | ||
| return count | ||
| finally: |
Collaborator
Author
There was a problem hiding this comment.
@claude, how does this compare against the old implementation, and what's the change in behavior?
Comment on lines
+21
to
+37
| - **RSI batch — grep/cat overhead + CLI cold start (260803)**: | ||
| - `mm grep`: Rust JSON fast path for the listing (no pyarrow import, | ||
| ~120 ms/invocation); matching is one C-speed `finditer` pass with | ||
| `re.MULTILINE` (zero-match files skip the per-line loop entirely); | ||
| documents route through the content-hash cache instead of | ||
| re-extracting every PDF each run; single-pass highlighting. | ||
| Fixture end-to-end: 345 ms → 238 ms wall. | ||
| - Magika no longer loads or runs for encoder auto-strategy — it only | ||
| ever read dimensional metadata (~0.3-0.5 s per binary-file `mm cat`; | ||
| model load off import). mm.toml parsed once per mtime (~10 | ||
| parses/file → 1); `Generate` type hints evaluated once; content hash | ||
| threaded through `run_fast`/`run_accurate`; ffmpeg probe and the | ||
| transcription OpenAI client process-cached; keyframe counting demuxes | ||
| packet flags instead of decoding every I-frame twice; image payloads | ||
| encode JPEG 4:2:0 unless alpha is present. | ||
| - CLI cold start: `importlib.metadata` deferred, pipeline/yaml imports | ||
| out of the `cat` registration path — `import mm.cli` 97 ms → 77 ms. |
Collaborator
Author
There was a problem hiding this comment.
remove the changes in changelog.md
| invoke_without_command=True, | ||
| help="Fast, multimodal context for agents.", | ||
| epilog=f"mm v{__version__}", | ||
| epilog="mm — fast, multimodal context for agents (mm --version)", |
Collaborator
Author
There was a problem hiding this comment.
revert to what it was before - we don't want cosmetic changes.
nwaughachukwuma
force-pushed
the
claude/core-perf-optimization-s230yb
branch
from
August 12, 2026 10:30
9ce1d7e to
0d2f4ca
Compare
nwaughachukwuma
force-pushed
the
claude/perf-catgrep-coldstart-s230yb
branch
from
August 12, 2026 10:32
a56fb33 to
f33c7c2
Compare
- mm grep: Rust JSON fast path for the listing (no pyarrow import), single finditer pass with MULTILINE, documents served from the content-hash cache, single-pass highlighting. mm wc routes documents through the same cache. - Magika no longer loads or runs for encoder auto-strategy — its output was never read there (~0.3-0.5s per binary-file mm cat; model load off import). - mm.toml parsed once per mtime (~10 parses/file → 1); Generate type hints evaluated once; content hash computed once per file; ffmpeg probe and the transcription OpenAI client process-cached; encoder discovery drops its O(modules x files) realpath sweep. - Keyframe counting demuxes packet flags instead of decoding every I-frame twice; image payloads encode JPEG 4:2:0 unless alpha is present. - CLI cold start: importlib.metadata deferred, pipeline/yaml imports out of the cat registration path (import mm.cli 97ms → 77ms). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012GnYsrLTmdJphKkm7yjWDV
nwaughachukwuma
force-pushed
the
claude/perf-catgrep-coldstart-s230yb
branch
from
August 12, 2026 10:40
f33c7c2 to
9c03a83
Compare
nwaughachukwuma
changed the base branch from
claude/core-perf-optimization-s230yb
to
add-report-flag-for-cat-command
August 12, 2026 10:40
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
mm grep: lists files via the Rust JSON fast path (no pyarrow import, ~120 ms/invocation); matches in one C-speedfinditerpass (re.MULTILINE; zero-match files skip the per-line loop entirely); serves documents from the content-hash cache instead of re-extracting every PDF on every run; single-pass highlighting.mm wcuses the same cache with a thread pool.Generatetype hints evaluated once; content hash computed once per file; ffmpeg probe + transcription OpenAI client process-cached; encoder discovery drops its O(modules × files) realpath sweep; keyframe counting demuxes packet flags instead of decoding every I-frame twice; JPEG 4:2:0 unless alpha.importlib.metadatadeferred behind module__getattr__; pipeline/yaml imports out of thecatregistration path.Speed gains
mm grep(340-file fixture, --count) wallmm catimport mm.cliValidation
1,208 Python tests pass; ruff clean. Includes the test updates for the new
content_hashkwarg and the cached transcription client.🤖 Generated with Claude Code
https://claude.ai/code/session_012GnYsrLTmdJphKkm7yjWDV