Skip to content

Conversation

@norberttech
Copy link
Member

@norberttech norberttech commented Nov 3, 2023

Change Log

Added

  • batchSize argument to DataFrame::collect method

Fixed

Changed

  • Closure was moved to Loader namespace as it applies to Loaders, not Pipelines

Removed

  • Rows from Closure::closure method
  • BufferLoader

Deprecated

Security


Ref: #715

Description

BufferLoader was implemented at very early stage of ETL, it's goal was to reduce number of IO operations when writing data. From now the same behavior can be achieved by setting a batchSize on DataFrame::collect() method. Before collect was collecting everything into memory, and it still does that when batchSize is not specified.
When batchSize is defined, CollectingPipeline will keep merging rows until they reach batchSize and then it will yield them.

Why is this important?

Thanks to the collect method, users have control over how many Rows at once are passed to the Loader, which can help in achieving better performance or displaying more readable output.

We can also remove batchSize from the Loaders directly, as they should not be responsible for dividing received Rows into chunks, but it's a thing for the next PR.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2023

Flow PHP - Benchmarks

Results of the benchmarks from this PR are compared with the results from 1.x branch.

Extractors
+-----------------------+-------------------+------+-----+------------------+-------------------+-----------------+
| benchmark             | subject           | revs | its | mem_peak         | mode              | rstdev          |
+-----------------------+-------------------+------+-----+------------------+-------------------+-----------------+
| AvroExtractorBench    | bench_extract_10k | 1    | 3   | 44.093mb +0.00%  | 430.568ms +23.48% | ±0.40% +34.03%  |
| CSVExtractorBench     | bench_extract_10k | 1    | 3   | 13.977mb +0.00%  | 341.438ms +30.23% | ±0.12% -25.68%  |
| JsonExtractorBench    | bench_extract_10k | 1    | 3   | 18.639mb +0.00%  | 663.431ms +22.81% | ±0.25% -80.49%  |
| ParquetExtractorBench | bench_extract_10k | 1    | 3   | 242.975mb +0.00% | 965.361ms +30.79% | ±0.34% -4.70%   |
| TextExtractorBench    | bench_extract_10k | 1    | 3   | 7.247mb +0.01%   | 19.111ms +30.08%  | ±1.72% +390.29% |
| XmlExtractorBench     | bench_extract_10k | 1    | 3   | 7.594mb +0.01%   | 590.881ms +31.91% | ±0.99% +32.18%  |
+-----------------------+-------------------+------+-----+------------------+-------------------+-----------------+
Transformers
+-----------------------------+--------------------------+------+-----+-----------------+------------------+---------------+
| benchmark                   | subject                  | revs | its | mem_peak        | mode             | rstdev        |
+-----------------------------+--------------------------+------+-----+-----------------+------------------+---------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1    | 3   | 87.032mb +0.00% | 63.562ms +31.61% | ±0.55% +4.53% |
+-----------------------------+--------------------------+------+-----+-----------------+------------------+---------------+
Loaders
+--------------------+----------------+------+-----+------------------+-------------------+-----------------+
| benchmark          | subject        | revs | its | mem_peak         | mode              | rstdev          |
+--------------------+----------------+------+-----+------------------+-------------------+-----------------+
| AvroLoaderBench    | bench_load_10k | 1    | 3   | 93.197mb +0.00%  | 662.735ms +16.76% | ±1.75% +172.70% |
| CSVLoaderBench     | bench_load_10k | 1    | 3   | 47.111mb +0.00%  | 71.157ms +4.70%   | ±0.29% +58.01%  |
| JsonLoaderBench    | bench_load_10k | 1    | 3   | 88.545mb +0.00%  | 69.204ms +22.62%  | ±1.04% +228.91% |
| ParquetLoaderBench | bench_load_10k | 1    | 3   | 286.875mb +0.00% | 1.468s +24.98%    | ±0.02% -97.47%  |
| TextLoaderBench    | bench_load_10k | 1    | 3   | 16.532mb +0.00%  | 36.750ms -10.28%  | ±0.57% -10.86%  |
+--------------------+----------------+------+-----+------------------+-------------------+-----------------+
Building Blocks
+-------------------------+----------------------------+------+-----+-----------------+-------------------+-----------------+
| benchmark               | subject                    | revs | its | mem_peak        | mode              | rstdev          |
+-------------------------+----------------------------+------+-----+-----------------+-------------------+-----------------+
| RowsBench               | bench_chunk_10_on_10k      | 2    | 3   | 60.656mb +0.00% | 3.993ms +75.89%   | ±3.70% +807.37% |
| RowsBench               | bench_diff_left_1k_on_10k  | 2    | 3   | 80.448mb +0.00% | 176.582ms +14.97% | ±0.75% +140.37% |
| RowsBench               | bench_diff_right_1k_on_10k | 2    | 3   | 58.974mb +0.00% | 17.932ms +19.59%  | ±0.76% +532.84% |
| RowsBench               | bench_drop_1k_on_10k       | 2    | 3   | 59.795mb +0.00% | 3.271ms +86.73%   | ±1.64% -35.31%  |
| RowsBench               | bench_drop_right_1k_on_10k | 2    | 3   | 59.795mb +0.00% | 3.174ms +84.39%   | ±2.36% +765.41% |
| RowsBench               | bench_entries_on_10k       | 2    | 3   | 59.008mb +0.00% | 4.113ms +56.91%   | ±2.07% +114.17% |
| RowsBench               | bench_filter_on_10k        | 2    | 3   | 59.537mb +0.00% | 18.285ms +31.22%  | ±0.72% -10.07%  |
| RowsBench               | bench_find_on_10k          | 2    | 3   | 59.537mb +0.00% | 18.231ms +32.02%  | ±0.13% -93.62%  |
| RowsBench               | bench_find_one_on_10k      | 10   | 3   | 57.608mb +0.00% | 2.494μs +38.55%   | ±1.91% +0.00%   |
| RowsBench               | bench_first_on_10k         | 10   | 3   | 57.608mb +0.00% | 0.500μs +25.00%   | ±0.00% -100.00% |
| RowsBench               | bench_flat_map_on_1k       | 2    | 3   | 65.841mb +0.00% | 14.159ms +37.19%  | ±1.46% +149.90% |
| RowsBench               | bench_map_on_10k           | 2    | 3   | 91.361mb +0.00% | 58.775ms +28.18%  | ±1.20% +77.38%  |
| RowsBench               | bench_merge_1k_on_10k      | 2    | 3   | 60.058mb +0.00% | 3.466ms +80.97%   | ±1.37% -29.67%  |
| RowsBench               | bench_partition_by_on_10k  | 2    | 3   | 62.328mb +0.00% | 41.613ms +26.02%  | ±0.62% -49.73%  |
| RowsBench               | bench_remove_on_10k        | 2    | 3   | 62.158mb +0.00% | 7.553ms +59.88%   | ±1.10% +2.22%   |
| RowsBench               | bench_sort_asc_on_1k       | 2    | 3   | 57.608mb +0.00% | 46.508ms +23.98%  | ±0.35% -40.64%  |
| RowsBench               | bench_sort_by_on_1k        | 2    | 3   | 57.608mb +0.00% | 46.772ms +24.74%  | ±0.33% -29.26%  |
| RowsBench               | bench_sort_desc_on_1k      | 2    | 3   | 57.608mb +0.00% | 47.168ms +23.80%  | ±0.07% -94.28%  |
| RowsBench               | bench_sort_entries_on_1k   | 2    | 3   | 59.882mb +0.00% | 9.864ms +35.17%   | ±0.66% -53.05%  |
| RowsBench               | bench_sort_on_1k           | 2    | 3   | 57.607mb +0.00% | 36.719ms +29.71%  | ±0.34% -59.39%  |
| RowsBench               | bench_take_1k_on_10k       | 10   | 3   | 57.608mb +0.00% | 21.840μs +66.72%  | ±1.32% -29.55%  |
| RowsBench               | bench_take_right_1k_on_10k | 10   | 3   | 57.608mb +0.00% | 27.170μs +71.86%  | ±0.87% -73.94%  |
| RowsBench               | bench_unique_on_1k         | 2    | 3   | 80.449mb +0.00% | 178.800ms +12.65% | ±0.51% +23.87%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 91.721mb +0.02% | 144.456ms +24.04% | ±0.46% -26.46%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 47.593mb +0.01% | 73.202ms +26.88%  | ±0.31% -38.83%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 12.389mb -0.04% | 17.703ms +27.16%  | ±0.43% -71.80%  |
+-------------------------+----------------------------+------+-----+-----------------+-------------------+-----------------+

Copy link
Member

@stloyd stloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changes, just small notes that seem to be missing from the upgrade file

@norberttech
Copy link
Member Author

Two more things can be implemented after this is merged:

#717
#718

@norberttech norberttech merged commit 8951dd7 into flow-php:1.x Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants