feat(storage): optimize tree func#2372
Open
baojun-zhang wants to merge 1 commit into
Open
Conversation
Collaborator
Author
性能测试(LS)前置导入 1000 个资源,用于准备 ls 测试数据: python3 ./OpenViking/load_test_add_resource_1000.py测试命令python3 perf/s3/ls/load_test_ls_100.py \
--account-id tenant_d9f3c5b17f \
--user-id user_b27e46a1cb \
--api-key 'dGVuY...ZA' \
--uri viking://resources \
--iterations 100结果汇总(100 次)
结论在相同结果规模( 原始输出优化前优化后 |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
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
Push the
treerecursive traversal capability down from the Python layer intoragfs(Rust). A default implementation equivalent to Python's_tree_originalis provided incore/filesystem.rs, ands3fsgets a high-performance override based on flat listing. The PythonVikingFSlayer now only handles view shaping, ACL, and agent enrichment, eliminating the duplicated DFS between_tree_original/_tree_agent. Zero semantic regression, with a major performance gain for wide S3 directories.Related Issue
Type of Change
Changes Made
TreeEntry(core/types.rs); addtree_directory()/tree_directory_internal()default recursive implementation to theFileSystemtrait (core/filesystem.rs), preservingnode_limit/level_limit/show_hidden/rel_path/DFS-order semantics identical to the original Python logic.tree_directory()routing and rewrite plugin-internal paths back to global AGFS absolute paths (core/mountable.rs).tree_directory()proxy andFsOperation::TreeDir(core/stats_wrapper.rs,core/stats.rs), fixing the wrapper not delegating, which previously made the S3FS optimization ineffective.tree_directory()and addbuild_tree_entries_from_flat_listing(), replacing per-directory recursiveread_dirwith a single/few paginated flat listings;client.rsaddslist_tree_objects()that retains directory markers (plugins/s3fs/mod.rs,plugins/s3fs/client.rs).tree_directory()andTreeEntry → PyDictserialization (ragfs-python/src/lib.rs).async_client.pyadds an asynctree_directory();viking_fs.pyrefactors_tree_original/_tree_agentinto adapters/enrichment built on a shared_iter_visible_tree_entries(), adds_is_tree_entry_visible()/_ancestor_is_filtered(), and keeps the "applynode_limitafter ACL filtering" semantics.Testing
Added/passing test coverage: Rust Core
tree_directorydefault implementation (RUST-TREE-001018), S3FS override (RUST-S3-001012), MountableFS routing (RUST-MNT-001~004); Python_is_tree_entry_visible/_iter_visible_tree_entries/_tree_original/_tree_agent(PY-FLT/ITER/ORIG/AGENT, 31 cases,tests/storage/test_viking_fs_tree.py). 65 unit tests pass in total. Performance regression: at the same result scale (1000 nodes), tree dropped from ~31615ms/call to ~10726ms/call (~2.95x), p99 from 56835ms to 13035ms (~4.36x), and stability improved from 99/100 to 100/100.Checklist
Screenshots (if applicable)
Additional Notes
perf/s3/tree/tree-optimization-design.md; Chapter 16 documents the implementation retrospective (including the fix for the missing StatsWrappedFS proxy).node_limitmust be applied after ACL filtering (not pushed down to Rust);level_limitcan be safely pushed down.audit-design.md,sqlite/DESIGN.md, andsetup.pyare not part of this PR.