chitralverma opened a new pull request, #9080:
URL: https://github.com/apache/opendal/pull/9080

   # Which issue does this PR close?
   
   Follow-up to #8966.
   
   # Rationale for this change
   
   #8966 filters one recursive listing when the walk would list every directory 
below the leading literal directories of the pattern, as for `t/**/*.parquet`. 
With a trailing `**`, the directory before `**` can match itself, so it is not 
a leading literal directory. For `logs/**`, the walk starts at the root and 
sends one request per directory below `logs/`. For `logs/y=*/**`, it does the 
same below each matched directory. One recursive listing of the matched 
directory reads the same keys with fewer requests.
   
   # What changes are included in this PR?
   
   - When the walk finds a directory below which it would list every directory, 
and the service supports recursive listing, it filters one recursive listing of 
that directory instead of walking it. Examples: `logs/y=*/**` and 
`logs/y=*/**/f0.json` below each `logs/y=*/`.
   - The check uses the same rule as the existing top-level check 
(`walks_whole_subtree`), so the recursive listing costs no more requests than 
the walk.
   - The filter reuses `FilteredLister`, which also returns directories that 
exist only as key prefixes.
   - Services without `list_with_recursive`, services with native glob, and 
listings with `start_after`, versions, or delete markers keep their current 
behavior.
   
   Requests and time on a fake S3 server with 0.29 s per request and pages of 
1,000 keys. The tree has 49,200 keys (`t/part=0..199/` with 6 keys each, 
`logs/y=*/m=*/d=*/` with 200 keys each). `skew` has 200 directories in `s/`, 
and one of them holds 1,000,000 more keys. `dense` has 40 directories in `d/` 
with 2,000 keys each. Patterns that do not change are omitted.
   
   | pattern | entries | `main` | this PR |
   |---|---:|---:|---:|
   | `logs/**` | 48,267 | 268 (79.8 s) | 49 (14.7 s) |
   | `logs/**/` | 267 | 268 (79.8 s) | 49 (14.7 s) |
   | `logs/y=*/**/f0.json` | 240 | 267 (79.5 s) | 49 (14.7 s) |
   | `logs/y=2024/**` | 24,133 | 134 (39.9 s) | 25 (7.5 s) |
   | `logs/y=*/m=03/**` | 4,022 | 25 (7.4 s) | 7 (2.1 s) |
   | `t/**` | 1,401 | 202 (60.0 s) | 3 (0.9 s) |
   | `s/**` (skew) | 1,000,402 | 1,202 (360.6 s) | 1,002 (301.3 s) |
   | `d/**` (dense) | 80,041 | 82 (24.5 s) | 81 (24.4 s) |
   
   Over 34 patterns (30 on the model tree, 2 on skew, 2 on dense), requests go 
from 3,803 to 2,620 and time from 1,134 s to 783 s. No pattern needs more 
requests, and each pattern returns the same entries as `main`.
   
   # Are there any user-facing changes?
   
   - `glob()` sends fewer list requests for patterns that end with `**`, as 
`logs/**` or `logs/y=*/**`, and for patterns with `**` after a wildcard 
directory, as `logs/y=*/**/f0.json`. Returned entries do not change.
   - Entry order can change below a directory that the layer lists recursively.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: Jcode
   - Model: claude-opus-5-5
   - Effort: low
   - Role: Wrote the patch, tests and this description, and ran the checks 
listed below. The human author reviewed the change and the results.
   
   Verified: requests, time, and entries against `main` on a fake S3 server for 
34 patterns on 3 trees (49,200, 1,000,200, and 80,000 keys): 0 changed entries, 
0 patterns with more requests, 8 with fewer; memory gate for 36 patterns on 4 
trees, with native and simulated recursion (288 cases): same entries as `main`, 
0 cases with more requests, 40 with fewer; differential on fs and memory, with 
and without directory markers: same entries as `main`; `cargo test -p 
opendal-core --lib` (504); behavior tests with `OPENDAL_TEST=memory` (118) and 
`OPENDAL_TEST=fs` (138); `cargo clippy -p opendal-core --all-targets 
--all-features -- -D warnings`; `cargo fmt --all --check`.
   
   Not verified: real S3 and services other than memory and fs on real backends.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to