Skip to content

Conversation

@stloyd
Copy link
Member

@stloyd stloyd commented Jul 20, 2024

Change Log

Added

Fixed

Changed

  • Rework `References` to do fewer loops

Removed

Deprecated

Security


Description

While looking on this class I noticed quite extensive amount of loops and array operations, unfortunately I don't have Blackfire (or alternative) installed right now to provide numbers.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2024

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   | 3.916mb +0.01%  | 508.279ms -0.35% | ±0.02% -98.08% |
| JsonExtractorBench    | bench_extract_10k | 1    | 3   | 3.949mb +0.01%  | 1.081s +0.90%    | ±0.78% +56.86% |
| ParquetExtractorBench | bench_extract_10k | 1    | 3   | 28.509mb +0.00% | 437.551ms +3.10% | ±0.34% -44.73% |
| TextExtractorBench    | bench_extract_10k | 1    | 3   | 3.676mb +0.01%  | 33.451ms -2.74%  | ±0.79% -41.46% |
| XmlExtractorBench     | bench_extract_10k | 1    | 3   | 3.622mb +0.01%  | 431.671ms +0.55% | ±0.36% -29.54% |
+-----------------------+-------------------+------+-----+-----------------+------------------+----------------+
Transformers
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| benchmark                   | subject                  | revs | its | mem_peak         | mode            | rstdev         |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1    | 3   | 115.968mb +0.00% | 60.627ms +1.09% | ±1.09% +64.49% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
Loaders
+--------------------+----------------+------+-----+------------------+-----------------+------------------+
| benchmark          | subject        | revs | its | mem_peak         | mode            | rstdev           |
+--------------------+----------------+------+-----+------------------+-----------------+------------------+
| CSVLoaderBench     | bench_load_10k | 1    | 3   | 54.071mb +0.00%  | 85.615ms +2.91% | ±0.39% -81.50%   |
| JsonLoaderBench    | bench_load_10k | 1    | 3   | 106.503mb +0.00% | 51.763ms -0.09% | ±1.64% +1191.47% |
| ParquetLoaderBench | bench_load_10k | 1    | 3   | 123.785mb +0.00% | 1.236s +1.12%   | ±0.78% +172.74%  |
| TextLoaderBench    | bench_load_10k | 1    | 3   | 16.865mb +0.00%  | 44.582ms +2.73% | ±0.24% +72.77%   |
+--------------------+----------------+------+-----+------------------+-----------------+------------------+
Building Blocks
+-------------------------+----------------------------+------+-----+------------------+------------------+------------------------------+
| benchmark               | subject                    | revs | its | mem_peak         | mode             | rstdev                       |
+-------------------------+----------------------------+------+-----+------------------+------------------+------------------------------+
| TypeDetectorBench       | bench_type_detector        | 1    | 3   | 59.697mb +0.00%  | 431.042ms -0.69% | ±0.55% -7.82%                |
| TypeDetectorBench       | bench_type_detector        | 1    | 3   | 14.236mb +0.00%  | 85.679ms +0.91%  | ±0.41% -34.38%               |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 116.518mb +0.00% | 488.588ms -1.10% | ±1.81% +31.28%               |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 59.997mb +0.00%  | 250.755ms +2.38% | ±1.49% +211.87%              |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 14.930mb +0.00%  | 53.676ms -1.87%  | ±0.16% -90.42%               |
| RowsBench               | bench_chunk_10_on_10k      | 2    | 3   | 86.788mb +0.00%  | 3.704ms +14.86%  | ±2.18% -2.44%                |
| RowsBench               | bench_diff_left_1k_on_10k  | 2    | 3   | 102.386mb +0.00% | 189.434ms +1.12% | ±0.27% -82.44%               |
| RowsBench               | bench_diff_right_1k_on_10k | 2    | 3   | 85.106mb +0.00%  | 18.808ms -1.87%  | ±0.79% -54.89%               |
| RowsBench               | bench_drop_1k_on_10k       | 2    | 3   | 88.028mb +0.00%  | 1.964ms +17.83%  | ±3.10% +303.66%              |
| RowsBench               | bench_drop_right_1k_on_10k | 2    | 3   | 88.028mb +0.00%  | 2.008ms +19.28%  | ±1.47% +119.03%              |
| RowsBench               | bench_entries_on_10k       | 2    | 3   | 85.140mb +0.00%  | 2.764ms +8.77%   | ±1.30% +106.37%              |
| RowsBench               | bench_filter_on_10k        | 2    | 3   | 85.669mb +0.00%  | 18.903ms +19.79% | ±2.08% +365.45%              |
| RowsBench               | bench_find_on_10k          | 2    | 3   | 85.669mb +0.00%  | 17.895ms +11.99% | ±1.70% +144.78%              |
| RowsBench               | bench_find_one_on_10k      | 10   | 3   | 83.573mb +0.00%  | 1.894μs +11.41%  | ±2.53% +0.00%                |
| RowsBench               | bench_first_on_10k         | 10   | 3   | 83.573mb +0.00%  | 0.300μs 0.00%    | ±0.00% 0.00%                 |
| RowsBench               | bench_flat_map_on_1k       | 2    | 3   | 92.923mb +0.00%  | 12.301ms +2.10%  | ±0.43% -66.14%               |
| RowsBench               | bench_map_on_10k           | 2    | 3   | 122.294mb +0.00% | 60.562ms +0.52%  | ±0.47% -68.78%               |
| RowsBench               | bench_merge_1k_on_10k      | 2    | 3   | 86.189mb +0.00%  | 1.668ms +37.18%  | ±2.54% +2908.81%             |
| RowsBench               | bench_partition_by_on_10k  | 2    | 3   | 89.536mb -0.00%  | 58.445ms +1.85%  | ±0.10% -85.78%               |
| RowsBench               | bench_remove_on_10k        | 2    | 3   | 88.290mb +0.00%  | 4.343ms +11.38%  | ±0.52% -31.96%               |
| RowsBench               | bench_sort_asc_on_1k       | 2    | 3   | 83.717mb +0.00%  | 39.199ms +0.54%  | ±1.32% +589.00%              |
| RowsBench               | bench_sort_by_on_1k        | 2    | 3   | 83.718mb +0.00%  | 39.925ms +0.80%  | ±1.02% -61.53%               |
| RowsBench               | bench_sort_desc_on_1k      | 2    | 3   | 83.717mb +0.00%  | 39.560ms +1.75%  | ±0.77% -40.28%               |
| RowsBench               | bench_sort_entries_on_1k   | 2    | 3   | 86.015mb +0.00%  | 7.390ms +1.28%   | ±0.52% -68.68%               |
| RowsBench               | bench_sort_on_1k           | 2    | 3   | 83.573mb +0.00%  | 29.260ms +3.32%  | ±1.14% +93.02%               |
| RowsBench               | bench_take_1k_on_10k       | 10   | 3   | 83.573mb +0.00%  | 14.000μs +5.26%  | ±0.58% +4366643765918200.00% |
| RowsBench               | bench_take_right_1k_on_10k | 10   | 3   | 83.573mb +0.00%  | 15.906μs +1.83%  | ±0.30% -63.07%               |
| RowsBench               | bench_unique_on_1k         | 2    | 3   | 102.387mb +0.00% | 193.378ms +0.72% | ±1.18% +89.73%               |
+-------------------------+----------------------------+------+-----+------------------+------------------+------------------------------+

@github-actions github-actions bot added size: S and removed size: XS labels Jul 20, 2024
@norberttech
Copy link
Member

You might want to try to profile it with https://github.com/NoiseByNorthwest/php-spx but it looks good even without profiling, thanks!

@norberttech norberttech merged commit 8c613ee into flow-php:1.x Jul 20, 2024
@stloyd stloyd deleted the chore/refs-impr branch July 20, 2024 12:00
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