Optimize glob walkdir - #3013
Merged
Merged
Conversation
qin-ctx
requested changes
Jul 6, 2026
qin-ctx
left a comment
Collaborator
There was a problem hiding this comment.
这次 review 结论是 REQUEST_CHANGES。后端 glob 下推和分页方向整体合理,但 HTTP glob 默认改为 256 后,Python SDK / 高层 client 没有同步暴露 node_limit,既有 SDK 调用会被静默截断;另外英文 filesystem 文档误把 grep 的 node_limit 默认写成 256。
qin-ctx
approved these changes
Jul 6, 2026
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.
Description
This PR moves
globfrom Python-sidetree() + PurePath.match()filtering into RAGFS as a first-class paged backend operation.Before this change,
VikingFS.glob()fetched a large tree from Python and then appliedPurePath.match()as the final matcher. That made glob expensive for large backends and also exposed PythonPurePath.match()suffix/basename semantics, which are not aligned with standard glob behavior.After this change,
glob_directory()is implemented in RAGFS and exposed through the Python binding / AGFS async client. Matching is performed in Rust withglobsetagainst query-root-relative paths. This intentionally changes glob semantics from PythonPurePath.match()to standard globset semantics.This PR also optimizes backend-specific glob implementations:
ignore::WalkBuilderinstead of custom DFS walker/cursor code.ListObjectsV2pages, avoiding full tree materialization.Related Issue
Type of Change
Changes Made
FileSystem::glob_directory()to RAGFS withGlobPage,GlobEntry, opaque continuation tokens, page size validation, and sharedglobsethelpers.ragfs-python,openviking/pyagfs, andVikingFS.glob(), replacing Python-sidetree() + PurePath.match()filtering.PurePath.match()suffix matching to standardglobsetfull query-root-relative path matching.*.md->**/*.md,*->**/*,*.jsonl->**/*.jsonl.ignore::WalkBuilder, while keeping DFS traversal and adding static max-depth pruning for patterns without**, such as200*.ListObjectsV2page scanning,S3GlobToken, buffered page entries, S3 continuation tokens, and cross-page DFS ancestor de-duplication.MultiWriteWrappedFS::glob_directory()so glob can delegate to optimized backend implementations instead of falling back to default full-tree traversal.Testing
Checklist
Screenshots (if applicable)
Additional Notes
Glob semantics change
This PR intentionally replaces Python
PurePath.match()semantics with Rustglobsetstandard glob semantics.Important examples:
Old
PurePath.match()behavior:PurePath("a/b.md").match("*.md") == TruePurePath("a.md").match("**/*.md") == FalseNew
globsetbehavior:*.mdmatches only root-level*.mdunder the query root.**/*.mdmatches Markdown files at any depth, including root-level files.Migration rule:
**/*.md,**/*.py,**/*.jsonl, or**/*when recursive matching is intended.200*only when matching root-level entries under the query path is intended.LocalFS glob behavior
LocalFS now uses
ignore::WalkBuilder. This does not turn traversal into BFS; traversal remains DFS.Performance improvements come from:
globsetmatching,PurePath.match()filtering,For example,
200*has no/and no**, so LocalFS limits traversal to depth 1.S3FS glob behavior
S3FS now performs glob directly over S3 listing pages instead of materializing a full tree first.
The S3 glob token tracks:
This allows S3 glob pagination to continue scanning from the previous S3 page without rebuilding the whole tree for every request.