Skip to content

fix: avoid repeated seeks when skipping small GGUF metadata values - #2223

Merged
leejet merged 1 commit into
masterfrom
fix/gguf-metadata-skip-performance
Oct 26, 2026
Merged

leejet merged 1 commit into
masterfrom
fix/gguf-metadata-skip-performance

Conversation

@leejet

@leejet leejet commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Use buffered ignore() for GGUF metadata skips up to 64 KiB to avoid repeated seeks when parsing tokenizer string arrays.
  • Keep seekg() for larger skips and preserve existing bounds checks.

Related Issue / Discussion

Fixes #2218.

Additional Information

N/A

Checklist

Summary by CodeRabbit

  • Improvements
    • File reading now uses a different method for skipping smaller sections, while larger skips continue to use seeking. Existing stream checks and byte tracking are unchanged.
    • This is an internal processing change; no user-facing features or behavior are reported as changing.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff251226-cfa9-4e7b-9edd-52b786cd5ac1
Commits

Reviewing files that changed from the base of the PR and between e41fbcf and 0401de4.

Files selected for processing: 1
  • src/model_io/gguf_reader_ext.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

GGUFReader::safe_skip now uses ifstream::ignore for skips up to 64 KiB. Larger skips continue to use seekg. The existing stream-state check and byte accounting remain unchanged.

Changes: GGUF metadata skipping

Layer / File(s) Summary
Choose buffered reads or seeking
src/model_io/gguf_reader_ext.h
safe_skip uses ignore for skips up to 64 KiB and seekg for larger skips. The stream-state check and remaining-byte update are unchanged.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: losewayy

Merge Risk: Minimal · up to 0401d

The change safely improves small GGUF metadata skips without introducing an actionable merge risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: avoiding repeated seeks when skipping small GGUF metadata values.
Description check Passed The description includes the required Summary, Related Issue / Discussion, Additional Information, and Checklist sections. It explains the change, motivation, scope, linked issue, and verification con…
Linked Issues check Passed Issue #2218 requires buffered skipping for small GGUF metadata values and seeking for large values. The PR changes GGUFReader::safe_skip to use fin.ignore() for sizes up to 64 KiB and seekg() ab…
Out of Scope Changes check Passed The diff changes only src/model_io/gguf_reader_ext.h and only the skip operation in GGUFReader::safe_skip. The change directly supports issue #2218. No unrelated behavior or files are present in t…
Full details: Description check

Explanation

The description includes the required Summary, Related Issue / Discussion, Additional Information, and Checklist sections. It explains the change, motivation, scope, linked issue, and verification context sufficiently.

Full details: Linked Issues check

Explanation

Issue #2218 requires buffered skipping for small GGUF metadata values and seeking for large values. The PR changes GGUFReader::safe_skip to use fin.ignore() for sizes up to 64 KiB and seekg() above 64 KiB. The existing bounds check and stream-state check remain in both paths. skip_metadata_values() uses safe_skip() for metadata strings and arrays. No unmet coding requirement is shown.

Full details: Out of Scope Changes check

Explanation

The diff changes only src/model_io/gguf_reader_ext.h and only the skip operation in GGUFReader::safe_skip. The change directly supports issue #2218. No unrelated behavior or files are present in the reviewed diff.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@leejet
leejet merged commit bb6b128 into master Oct 26, 2026
11 checks passed
@leejet
leejet deleted the fix/gguf-metadata-skip-performance branch October 26, 2026 16:48
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.

[Bug] GGUF reader seeks once per skipped metadata string: ~1 s per start, 36 s on uncached storage

1 participant