Repository navigation
Commit 8d88f1c
authored
[perf](load) introduce sequential prefetch for FileScannerV2 CSV reads (#69716)
### What problem does this PR solve?
Issue Number: None
Related PR: #69333
Problem Summary:
After CSV ingestion switched to FileScannerV2, `DelimitedTextReader`
opened remote files directly through `FileFactory`, bypassing the
sequential prefetch used by the original CSV reader. S3 reads therefore
block the scanner instead of overlapping remote I/O with CSV parsing.
Restore `DelegateReader::create_file_reader(SEQUENTIAL)` in the shared
CSV/Text reader, passing the shared IOContext and adjusted split range.
Unknown-size first splits use an end sentinel bounded by the physical
file size. Tracing remains outside the prefetch layer, and shared
stream-load pipes retain their existing ownership and cancellation
behavior.
To safely integrate asynchronous reads with V2 scanner statistics:
- Each prefetch buffer owns its cache statistics and an IOContext
snapshot. The consumer merges completed statistics exactly once before
consuming, reusing or closing the buffer. Workers never update the
scanner's cache-statistics object.
- Close drains active reads even after a foreground timeout, keeping
borrowed scanner state alive until I/O completes. Queued tasks observe
CLOSED and skip reading. Cleanup can consequently take longer than
`buffered_reader_read_timeout_ms` while an underlying request is
outstanding.
- The ring modulus uses allocated capacity: a 6 MiB setting allocates
one 4 MiB buffer and wraps at 4 MiB. Settings below 4 MiB use one
buffer; the 16 MiB default is unchanged.
- CSV/Text filesystem readers close before collecting prefetch profile
counters. Repeated close does not publish counters twice.
### Performance
For the TPC-H dataset load benchmark, elapsed time decreased from
**2617.33 s** to **1696.06 s**, saving **921.27 s**. This is a **35.2%
reduction in load time**, or approximately **1.54x speedup**, for the
measured workload.
| Dataset | Before | After | Load time reduction | Speedup |
| --- | ---: | ---: | ---: | ---: |
| TPC-H | 2617.33 s | 1696.06 s | 35.2% | 1.54x |
### Release note
Restore asynchronous S3 prefetch for FileScannerV2 CSV and text reads,
with safe cache-statistics aggregation and cleanup, consistent ring
capacity and populated prefetch profiles.
### Check List (For Author)
- Test:
- Added S3 mock coverage for whole-file, mid-row split and unknown-size
reads; checks row values, outer tracing, background S3 reads, prefetch
profile publication and repeated close.
- Added buffered-reader tests for four concurrent workers with isolated
cache statistics, partial consumption, slot reuse, unconsumed-buffer
collection, successful reads finishing after foreground timeout,
explicit close/destruction, and exact bytes across 0/1/6/10/16 MiB ring
settings from zero/nonzero offsets. Added a shared stream-pipe ownership
test.
- Passed Clang 16 syntax checking of the complete
`buffered_reader_test.cpp` translation unit against repository and
installed third-party headers with `-Werror -Wunused-member-function`.
- Passed repository clang-format 16 formatting/check scripts,
`build-support/check-build-hygiene.sh`, and `git diff --check`.
- Full BE build and runtime tests are **not verified locally**:
`./run-be-ut.sh --run --filter='BufferedReaderTest.*:CsvV2ReaderTest.*'
-j 8` stops at JDK initialization (`Failed setting boot class path`).
Separate production/CSV syntax attempts encounter installed C++ library
and stale generated-header incompatibilities. No compilation database is
available for clang-tidy. Runtime and sanitizer validation remain
pending CI.
- The S3 mock test disables file cache; the concurrent statistics test
exercises the actual prefetch implementation with a mock reader updating
`FileCacheStatistics`. No cached-S3 end-to-end runtime result is
claimed.
- TPC-H load benchmark: elapsed time decreased from 2617.33 s to 1696.06
s (35.2% less load time; approximately 1.54x speedup).
- Behavior changed:
- [x] Yes. Eligible S3 CSV/Text readers use sequential prefetch. Shared
prefetch readers isolate cache counters, drain outstanding reads during
cleanup and normalize ring capacity. CSV/Text publishes prefetch
profiles on close.
- Does this need documentation?
- [x] No.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label1 parent 76011df commit 8d88f1c
5 files changed
Lines changed: 373 additions & 41 deletions
File tree
- be
- src
- format_v2/delimited_text
- io/fs
- test
- format_v2/delimited_text
- io/fs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
486 | 487 | | |
487 | 488 | | |
488 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
489 | 497 | | |
490 | 498 | | |
491 | 499 | | |
| |||
605 | 613 | | |
606 | 614 | | |
607 | 615 | | |
608 | | - | |
609 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
610 | 624 | | |
611 | 625 | | |
612 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
416 | 423 | | |
417 | 424 | | |
418 | 425 | | |
| |||
470 | 477 | | |
471 | 478 | | |
472 | 479 | | |
473 | | - | |
| 480 | + | |
474 | 481 | | |
475 | 482 | | |
476 | 483 | | |
| |||
497 | 504 | | |
498 | 505 | | |
499 | 506 | | |
| 507 | + | |
500 | 508 | | |
501 | 509 | | |
502 | 510 | | |
| |||
582 | 590 | | |
583 | 591 | | |
584 | 592 | | |
| 593 | + | |
585 | 594 | | |
586 | 595 | | |
587 | 596 | | |
| |||
612 | 621 | | |
613 | 622 | | |
614 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
615 | 634 | | |
616 | 635 | | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
624 | 641 | | |
625 | 642 | | |
626 | 643 | | |
| |||
647 | 664 | | |
648 | 665 | | |
649 | 666 | | |
650 | | - | |
| 667 | + | |
651 | 668 | | |
652 | 669 | | |
653 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
654 | 674 | | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | 675 | | |
659 | 676 | | |
660 | 677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
472 | 477 | | |
473 | 478 | | |
474 | 479 | | |
| |||
515 | 520 | | |
516 | 521 | | |
517 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
518 | 526 | | |
519 | 527 | | |
520 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| 50 | + | |
47 | 51 | | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| 60 | + | |
| 61 | + | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
58 | 139 | | |
59 | 140 | | |
60 | 141 | | |
| |||
512 | 593 | | |
513 | 594 | | |
514 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
515 | 668 | | |
516 | 669 | | |
517 | 670 | | |
| |||
927 | 1080 | | |
928 | 1081 | | |
929 | 1082 | | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
930 | 1094 | | |
931 | 1095 | | |
932 | 1096 | | |
| |||
0 commit comments