fix(hns): cache root bucket properly in _get_dirs_and_update_cache - #990
fix(hns): cache root bucket properly in _get_dirs_and_update_cache#990yuxin00j wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request simplifies a directory cache update condition in gcsfs/core.py and adds a new integration test to verify that find() populates the directory cache for the root bucket. However, the new test method was accidentally inserted in the middle of an existing test, which truncates the original test and incorrectly indents its remaining assertions under the new test. A code suggestion has been provided to properly separate the tests and clean up an unused variable.
8eea016 to
1184271
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #990 +/- ##
==========================================
- Coverage 89.68% 89.66% -0.03%
==========================================
Files 16 16
Lines 3579 3581 +2
==========================================
+ Hits 3210 3211 +1
- Misses 369 370 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/gcbrun |
1 similar comment
|
/gcbrun |
1184271 to
db5d3f1
Compare
|
/gcbrun |
Summary
Fixes a performance bottleneck where
_get_dirs_and_update_cacheskipped updatingfsspec.dircachewhen listing the root bucket (dir_key == "") in Hierarchical Namespace (HNS) enabled buckets. This caused repeated metadata cache misses and redundant GCP network requests when loading multi-file datasets (e.g., Hugging Facedatasets/ Parquet).Root Cause & Technical Fix
gcsfs/core.py(_get_dirs_and_update_cache), the parent directory traversal loop terminated early when encountering the root bucket (not dir_key). Because the root bucket listing was never written toself.dircache, subsequentfs.info("bucket/file")calls triggered cache misses and made synchronous HTTP network requests to GCS for every file._get_dirs_and_update_cacheso thatcache_entriesis populated for root buckets ("bucket"), ensuring the directory contents are cached inself.dircache["bucket"].dirs[parent]assignment withif dir_key:so that root buckets are not incorrectly synthesized as subdirectories inside themselves (which previously caused409 Conflict: The bucket you tried to delete is not emptyduring test teardown).