Skip to content

Conversation

@norberttech
Copy link
Member

@norberttech norberttech commented Sep 29, 2024

Change Log

Added

Fixed

Changed

  • CachingPipeline will relay only on previously set batch size without modifying it

Removed

  • Default global CachingPipeline batch size

Deprecated

Security


Description

Previously using cache was changing the batch size which for long and complicated pipelines could end up in significant performance drop.

Before

df()
  ->read(...)
  ->batchSize(10_000)
  ->withEntry(...) // batch size here is 10k
  ->cache("test") // cache batch size is not provided so default batch size is used and changed to 100
  ->withEntry(...) // batch size here is 100 
  ->run()

df()
  ->read(...)
  ->batchSize(10_000)
  ->withEntry(...) // batch size here is 10k
  ->cache("test", cacheBatchSize: 10) // cache batch size is set to 10
  ->withEntry(...) // batch size here is 10
  ->run()

After

df()
  ->read(...)
  ->batchSize(10_000)
  ->withEntry(...) // batch size here is 10k
  ->cache("test") // batch size here is still 10k 
  ->withEntry(...) // batch size here is still 10k
  ->run()

df()
  ->read(...)
  ->batchSize(10_000)
  ->withEntry(...) // batch size here is 10k
  ->cache("test", cacheBatchSize: 5000) // batch size here is still 5k
  ->withEntry(...) // batch size here is now 5k
  ->run()

@github-actions
Copy link
Contributor

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          |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
| CSVExtractorBench     | bench_extract_10k | 1    | 3   | 4.631mb -0.13%  | 523.131ms +4.21% | ±0.86% -39.48%  |
| JsonExtractorBench    | bench_extract_10k | 1    | 3   | 4.719mb -0.13%  | 1.119s +3.55%    | ±2.32% +348.66% |
| ParquetExtractorBench | bench_extract_10k | 1    | 3   | 29.175mb -0.02% | 459.197ms +7.86% | ±0.56% +110.90% |
| TextExtractorBench    | bench_extract_10k | 1    | 3   | 4.360mb -0.14%  | 33.619ms +2.12%  | ±1.98% -6.99%   |
| XmlExtractorBench     | bench_extract_10k | 1    | 3   | 4.341mb -0.14%  | 657.414ms +3.80% | ±0.23% -26.21%  |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
Transformers
+-----------------------------+--------------------------+------+-----+------------------+-----------------+---------------+
| benchmark                   | subject                  | revs | its | mem_peak         | mode            | rstdev        |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+---------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1    | 3   | 116.701mb -0.06% | 62.846ms +4.83% | ±1.29% -1.02% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+---------------+
Loaders
+--------------------+----------------+------+-----+------------------+------------------+----------------+
| benchmark          | subject        | revs | its | mem_peak         | mode             | rstdev         |
+--------------------+----------------+------+-----+------------------+------------------+----------------+
| CSVLoaderBench     | bench_load_10k | 1    | 3   | 54.829mb -0.01%  | 123.920ms +7.67% | ±0.78% -58.16% |
| JsonLoaderBench    | bench_load_10k | 1    | 3   | 90.412mb -0.01%  | 103.357ms +6.50% | ±0.55% -68.65% |
| ParquetLoaderBench | bench_load_10k | 1    | 3   | 124.532mb -0.00% | 1.249s +2.89%    | ±0.48% -66.07% |
| TextLoaderBench    | bench_load_10k | 1    | 3   | 17.551mb -0.04%  | 29.605ms +12.00% | ±1.01% -63.99% |
+--------------------+----------------+------+-----+------------------+------------------+----------------+
Building Blocks
+-------------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| benchmark               | subject                    | revs | its | mem_peak         | mode             | rstdev          |
+-------------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| TypeDetectorBench       | bench_type_detector        | 1    | 3   | 53.271mb +0.00%  | 401.419ms +4.56% | ±0.76% -20.83%  |
| TypeDetectorBench       | bench_type_detector        | 1    | 3   | 13.537mb +0.00%  | 80.742ms +0.63%  | ±0.18% -94.87%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 107.468mb +0.00% | 490.784ms +6.38% | ±0.42% -72.38%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 55.826mb +0.00%  | 245.336ms +2.29% | ±0.70% -14.17%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 14.664mb +0.00%  | 54.374ms +9.58%  | ±1.34% -51.75%  |
| RowsBench               | bench_chunk_10_on_10k      | 2    | 3   | 87.445mb +0.00%  | 3.543ms +6.06%   | ±1.22% -55.84%  |
| RowsBench               | bench_diff_left_1k_on_10k  | 2    | 3   | 102.983mb +0.00% | 191.229ms +1.82% | ±0.64% -60.27%  |
| RowsBench               | bench_diff_right_1k_on_10k | 2    | 3   | 85.703mb +0.00%  | 19.242ms +1.18%  | ±0.71% -66.15%  |
| RowsBench               | bench_drop_1k_on_10k       | 2    | 3   | 88.685mb +0.00%  | 2.239ms +34.92%  | ±1.38% -43.84%  |
| RowsBench               | bench_drop_right_1k_on_10k | 2    | 3   | 88.685mb +0.00%  | 2.328ms +38.03%  | ±0.88% -42.32%  |
| RowsBench               | bench_entries_on_10k       | 2    | 3   | 85.797mb +0.00%  | 3.046ms +15.38%  | ±2.36% +14.23%  |
| RowsBench               | bench_filter_on_10k        | 2    | 3   | 86.326mb +0.00%  | 18.749ms +22.13% | ±0.93% +39.69%  |
| RowsBench               | bench_find_on_10k          | 2    | 3   | 86.326mb +0.00%  | 19.121ms +19.92% | ±0.89% -29.64%  |
| RowsBench               | bench_find_one_on_10k      | 10   | 3   | 84.230mb +0.00%  | 1.706μs +13.74%  | ±2.72% +0.00%   |
| RowsBench               | bench_first_on_10k         | 10   | 3   | 84.230mb +0.00%  | 0.400μs +33.33%  | ±0.00% +0.00%   |
| RowsBench               | bench_flat_map_on_1k       | 2    | 3   | 93.580mb +0.00%  | 12.683ms +0.14%  | ±0.42% -82.81%  |
| RowsBench               | bench_map_on_10k           | 2    | 3   | 122.951mb +0.00% | 61.294ms +3.34%  | ±1.41% -45.18%  |
| RowsBench               | bench_merge_1k_on_10k      | 2    | 3   | 86.846mb +0.00%  | 1.698ms +36.17%  | ±3.44% +51.75%  |
| RowsBench               | bench_partition_by_on_10k  | 2    | 3   | 90.136mb +0.00%  | 59.170ms +4.63%  | ±0.41% -43.89%  |
| RowsBench               | bench_remove_on_10k        | 2    | 3   | 88.947mb +0.00%  | 4.213ms +6.25%   | ±1.23% -46.20%  |
| RowsBench               | bench_sort_asc_on_1k       | 2    | 3   | 84.314mb +0.00%  | 41.837ms +8.66%  | ±2.75% +1.31%   |
| RowsBench               | bench_sort_by_on_1k        | 2    | 3   | 84.314mb +0.00%  | 40.774ms +7.07%  | ±0.35% -69.23%  |
| RowsBench               | bench_sort_desc_on_1k      | 2    | 3   | 84.314mb +0.00%  | 41.704ms +7.42%  | ±1.26% +0.48%   |
| RowsBench               | bench_sort_entries_on_1k   | 2    | 3   | 86.671mb +0.00%  | 7.542ms +8.40%   | ±0.83% +126.83% |
| RowsBench               | bench_sort_on_1k           | 2    | 3   | 84.230mb +0.00%  | 29.240ms +6.67%  | ±0.70% -56.67%  |
| RowsBench               | bench_take_1k_on_10k       | 10   | 3   | 84.230mb +0.00%  | 13.780μs +13.30% | ±1.23% -60.72%  |
| RowsBench               | bench_take_right_1k_on_10k | 10   | 3   | 84.230mb +0.00%  | 15.882μs +1.77%  | ±0.90% +196.84% |
| RowsBench               | bench_unique_on_1k         | 2    | 3   | 102.988mb +0.00% | 195.424ms +1.72% | ±0.91% -2.37%   |
+-------------------------+----------------------------+------+-----+------------------+------------------+-----------------+

@norberttech norberttech merged commit aa124c4 into flow-php:1.x Sep 29, 2024
@norberttech norberttech deleted the feature/batch-size-improvements branch December 5, 2024 20:18
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.

1 participant