Priya2996 commented on PR #54840:
URL: https://github.com/apache/arrow/pull/54840#issuecomment-7361702800

   @dmitry-chirkov-dremio Thanks for the suggestions. I ran a few tests based 
on the recommendations. Here are a few results, including cases that got slower 
or used more memory.
   
   Unless noted below, scans use pre_buffer=true, threading enabled, eight CPU 
workers, four I/O workers, 65,536-row batches, batch readahead 16, and fragment 
readahead 1. The numeric and mixed datasets each contain 3,145,728 rows. 
Numeric files use Snappy with dictionaries off. The mixed file has four integer 
fields, two floats, four strings, a list of integers, and a struct containing a 
float and a string, with null values included.
   
   Each arrow shows the result before the PR, then with the PR. Lower times and 
memory are better; a positive reading-speed change means faster. Memory values 
are peaks: scanner memory counts allocations through the scan pool, while RSS 
covers the broader process.
   
   
   | What was measured | Scan time (ms), before → PR | Reading speed change | 
Scanner memory (MiB), before → PR | Process memory / RSS (MiB), before → PR |
   |---|---:|---:|---:|---:|
   | Read all 12 integer columns from one file: 96 row groups of 32,768 rows 
each | 33.27 → 49.63 | -33.0% | 102.3 → 11.7 | 321.9 → 224.7 |
   | Same file as above, but read only the first 2 of the 12 columns | 6.86 → 
22.49 | -69.5% | 17.4 → 2.0 | 88.1 → 60.8 |
   | Read all 12 integer columns from the same data, stored in 3 row groups of 
1,048,576 rows each | 41.42 → 45.43 | -8.8% | 212.2 → 25.6 | 427.0 → 244.9 |
   | Read all 12 mixed/nested fields from one file: 3 row groups of 1,048,576 
rows each; Snappy compression; dictionary encoding enabled for string columns | 
65.11 → 66.11 | -1.5% | 332.5 → 36.4 | 637.8 → 254.7 |
   | Read all 12 integer columns across 4 files, each with 3 row groups of 
262,144 rows; fragment readahead 4 | 30.47 → 33.12 | -8.0% | 297.7 → 256.9 | 
527.8 → 491.9 |
   | Read all fields from the original file: 629 top-level fields / 650 leaf 
columns, 1,481,181 rows in one row group; ZSTD, dictionaries on 54 leaf columns 
| 284.54 → 210.39 | +35.2% | 5108.5 → 894.2 | 5387.2 → 1113.0 |
   | Read all 128 integer columns from one file: 262,144 rows in one row group; 
Snappy, dictionary off; batch size 131,072 | 26.96 → 29.45 | -8.5% | 265.2 → 
343.5 | 478.4 → 587.6 |
   
   The original wide file improves in both speed and memory. But files with 
small row groups can get slower, especially when reading only a few columns. 
   
   
   To compare small and large row groups against the batch size directly, here 
are the results for the same numeric and mixed/nested data stored with 
different row-group sizes. Each file contains 3,145,728 rows, and all columns 
are read. All use Snappy; numeric files have dictionaries off, while mixed 
files have dictionary encoding enabled for string columns. Threading is enabled 
with eight CPU workers, four I/O workers, batch readahead 16, fragment 
readahead 1, and `pre_buffer=true` in both versions.
   
   | File type | Rows per row group | Batch limit (rows) | Scan time (ms), 
before → PR | Reading speed change | Scanner peak memory (MiB), before → PR |
   |---|---:|---:|---:|---:|---:|
   | 12 integer columns | 32,768 | 65,536 | 33.27 → 49.63 | -33.0% | 102.3 → 
11.7 |
   | 12 integer columns | 1,048,576 | 65,536 | 41.42 → 45.43 | -8.8% | 212.2 → 
25.6 |
   | 12 integer columns | 1,048,576 | 131,072 | 33.75 → 41.57 | -18.8% | 309.7 
→ 48.4 |
   | 12 mixed/nested fields | 32,768 | 65,536 | 43.47 → 70.52 | -38.4% | 156.3 
→ 17.3 |
   | 12 mixed/nested fields | 1,048,576 | 65,536 | 65.11 → 66.11 | -1.5% | 
332.5 → 36.4 |
   | 12 mixed/nested fields | 1,048,576 | 131,072 | 49.76 → 62.15 | -19.9% | 
431.5 → 71.4 |
   
   
   I also tested stopping after the first batch. The table shows both the time 
to receive that batch and the time including cleanup of work that had already 
started. I did not request more batches after stopping. These use the same 
batch size and worker counts as above:
   
   | What was measured | Time to first batch (ms), before → PR | Time including 
cleanup (ms), before → PR | Scanner memory (MiB), before → PR | Process memory 
/ RSS (MiB), before → PR |
   |---|---:|---:|---:|---:|
   | Large-row-group numeric file above; all columns; stop after 65,536 rows; 
batch readahead 0, fragment readahead 1 | 16.86 → 6.91 | 16.96 → 9.39 | 114.7 → 
21.1 | 196.3 → 108.1 |
   | Original 650-column file above; all fields; stop after 65,536 rows; batch 
readahead 16, fragment readahead 1 | 223.40 → 33.66 | 291.88 → 264.97 | 5104.0 
→ 3797.1 | 5372.7 → 3994.4 |
   
   One goal of this change is to let users choose how much data to decode at 
once, even when they cannot change how the file was written. Today, a smaller 
`batch_size` on the pre-buffered Dataset path still allows a whole row group to 
be decoded upfront. With this change, it also controls the number of rows 
decoded per step. Users can adjust it along with readahead to balance speed and 
memory. This limits how effectively users can reduce decoded memory through the 
existing settings.
   
   The results show that this flexibility comes with costs for some workloads, 
and those regressions deserve attention. At the same time, the ability to tune 
decoding independently of the stored row-group size is a useful capability that 
the current pre-buffered path does not provide. I think that additional 
control, alongside the measured performance tradeoffs, is an important part of 
evaluating this change.


-- 
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