Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance for a few Rows methods #671

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

stloyd
Copy link
Member

@stloyd stloyd commented Oct 30, 2023

Change Log

Added

Fixed

Changed

  • Improve performance for a few `Rows` methods
  • Rework benchmark GH action to use artifact for baseline

Removed

Deprecated

Security


Description

Covered: find, findOne, first, partitionBy, take, takeRight.

Comparing local benchmarks:

composer run-script test:benchmark:building_blocks
> tools/phpbench/vendor/bin/phpbench run --report=flow-report --group=building_blocks --ref=1.x
PHPBench (1.2.14) running benchmarks... #standwithukraine
with configuration file: /Users/stloyd/Documents/flow/phpbench.json
with PHP version 8.1.25, xdebug ❌, opcache ❌
comparing [actual vs. 1.x]

.......................... 

Subjects: 26, Assertions: 0, Failures: 0, Errors: 0
+-------------------------+----------------------------+------+-----+-----------------+------------------+
| benchmark               | subject                    | revs | its | mem_peak        | mode             |
+-------------------------+----------------------------+------+-----+-----------------+------------------+
| RowsBench               | bench_chunk_10_on_10k      | 5    | 5   | 60.962mb -0.00% | 2.571ms -1.38%   |
| RowsBench               | bench_diff_left_1k_on_10k  | 5    | 5   | 80.754mb -0.00% | 234.289ms +2.53% |
| RowsBench               | bench_diff_right_1k_on_10k | 5    | 5   | 59.279mb -0.00% | 23.252ms +6.90%  |
| RowsBench               | bench_drop_1k_on_10k       | 5    | 5   | 60.101mb -0.00% | 2.374ms -9.14%   |
| RowsBench               | bench_drop_right_1k_on_10k | 5    | 5   | 62.203mb -0.00% | 2.452ms +1.86%   |
| RowsBench               | bench_entries_on_10k       | 5    | 5   | 59.315mb -0.00% | 3.931ms -2.71%   |
| RowsBench               | bench_filter_on_10k        | 5    | 5   | 59.843mb -0.00% | 21.557ms -8.90%  |
| RowsBench               | bench_find_on_10k          | 5    | 5   | 59.843mb -0.00% | 23.355ms +8.62%  |
| RowsBench               | bench_find_one_on_10k      | 5    | 5   | 58.267mb -0.61% | 5.000μs -99.98%  |
| RowsBench               | bench_first_on_10k         | 5    | 5   | 57.914mb -0.00% | 2.000μs 0.00%    |
| RowsBench               | bench_flat_map_on_1k       | 5    | 5   | 66.148mb -0.00% | 12.537ms +2.71%  |
| RowsBench               | bench_map_on_10k           | 5    | 5   | 91.668mb -0.00% | 58.519ms +3.87%  |
| RowsBench               | bench_merge_1k_on_10k      | 5    | 5   | 60.364mb -0.00% | 2.820ms -11.90%  |
| RowsBench               | bench_partition_by_on_10k  | 5    | 5   | 64.735mb -3.25% | 49.046ms -9.22%  |
| RowsBench               | bench_remove_on_10k        | 5    | 5   | 62.465mb -0.00% | 6.297ms +1.23%   |
| RowsBench               | bench_sort_asc_on_1k       | 5    | 5   | 57.914mb -0.00% | 62.019ms -4.12%  |
| RowsBench               | bench_sort_by_on_1k        | 5    | 5   | 57.914mb -0.00% | 60.592ms -1.10%  |
| RowsBench               | bench_sort_desc_on_1k      | 5    | 5   | 57.914mb -0.00% | 63.074ms +0.75%  |
| RowsBench               | bench_sort_entries_on_1k   | 5    | 5   | 60.189mb -0.00% | 9.063ms -3.89%   |
| RowsBench               | bench_sort_on_1k           | 5    | 5   | 57.914mb -0.00% | 44.019ms -1.26%  |
| RowsBench               | bench_take_1k_on_10k       | 5    | 5   | 59.389mb -2.48% | 17.290μs -99.98% |
| RowsBench               | bench_take_right_1k_on_10k | 5    | 5   | 59.389mb -2.48% | 28.598μs -96.75% |
| RowsBench               | bench_unique_on_1k         | 5    | 5   | 80.754mb -0.00% | 229.792ms -7.76% |
| NativeEntryFactoryBench | bench_10k_rows             | 5    | 5   | 84.172mb -0.01% | 132.170ms +1.31% |
| NativeEntryFactoryBench | bench_1k_rows              | 5    | 5   | 45.704mb +0.00% | 13.150ms -2.29%  |
| NativeEntryFactoryBench | bench_5k_rows              | 5    | 5   | 62.977mb -0.00% | 64.536ms -0.95%  |
+-------------------------+----------------------------+------+-----+-----------------+------------------+

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 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             |
+-----------------------+-------------------+------+-----+------------------+------------------+
| AvroExtractorBench    | bench_extract_10k | 5    | 3   | 44.122mb -0.00%  | 620.606ms +7.07% |
| CSVExtractorBench     | bench_extract_10k | 5    | 3   | 14.007mb -0.01%  | 520.512ms +2.68% |
| JsonExtractorBench    | bench_extract_10k | 5    | 3   | 18.669mb -0.01%  | 995.698ms +5.99% |
| ParquetExtractorBench | bench_extract_10k | 5    | 3   | 237.792mb -0.00% | 1.398s +4.85%    |
| TextExtractorBench    | bench_extract_10k | 5    | 3   | 7.276mb -0.02%   | 20.104ms +5.34%  |
| XmlExtractorBench     | bench_extract_10k | 5    | 3   | 7.624mb -0.02%   | 855.840ms +8.11% |
+-----------------------+-------------------+------+-----+------------------+------------------+
Transformers
+-----------------------------+--------------------------+------+-----+-----------------+-----------------+
| benchmark                   | subject                  | revs | its | mem_peak        | mode            |
+-----------------------------+--------------------------+------+-----+-----------------+-----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 5    | 5   | 87.062mb -0.00% | 83.589ms +5.91% |
+-----------------------------+--------------------------+------+-----+-----------------+-----------------+
Loaders
+--------------------+----------------+------+-----+------------------+------------------+
| benchmark          | subject        | revs | its | mem_peak         | mode             |
+--------------------+----------------+------+-----+------------------+------------------+
| AvroLoaderBench    | bench_load_10k | 5    | 3   | 219.956mb -0.00% | 996.975ms +5.86% |
| CSVLoaderBench     | bench_load_10k | 5    | 3   | 47.140mb -0.00%  | 107.636ms +9.87% |
| JsonLoaderBench    | bench_load_10k | 5    | 3   | 88.579mb -0.00%  | 101.423ms +4.61% |
| ParquetLoaderBench | bench_load_10k | 5    | 3   | 281.200mb -0.00% | 1.354s +7.19%    |
| TextLoaderBench    | bench_load_10k | 5    | 3   | 16.566mb -0.01%  | 48.298ms +2.13%  |
+--------------------+----------------+------+-----+------------------+------------------+
Building Blocks
+-------------------------+----------------------------+------+-----+-----------------+-------------------+
| benchmark               | subject                    | revs | its | mem_peak        | mode              |
+-------------------------+----------------------------+------+-----+-----------------+-------------------+
| RowsBench               | bench_chunk_10_on_10k      | 5    | 5   | 60.694mb -0.00% | 5.120ms +10.11%   |
| RowsBench               | bench_diff_left_1k_on_10k  | 5    | 5   | 80.485mb -0.00% | 233.410ms +10.28% |
| RowsBench               | bench_diff_right_1k_on_10k | 5    | 5   | 59.011mb -0.00% | 23.213ms +11.50%  |
| RowsBench               | bench_drop_1k_on_10k       | 5    | 5   | 59.833mb -0.00% | 3.897ms +12.89%   |
| RowsBench               | bench_drop_right_1k_on_10k | 5    | 5   | 61.935mb -0.00% | 4.064ms +15.65%   |
| RowsBench               | bench_entries_on_10k       | 5    | 5   | 59.046mb -0.00% | 4.890ms +9.76%    |
| RowsBench               | bench_filter_on_10k        | 5    | 5   | 59.575mb -0.00% | 26.377ms +3.82%   |
| RowsBench               | bench_find_on_10k          | 5    | 5   | 59.575mb -0.00% | 27.760ms +7.47%   |
| RowsBench               | bench_find_one_on_10k      | 5    | 5   | 57.998mb -0.61% | 4.993μs -99.98%   |
| RowsBench               | bench_first_on_10k         | 5    | 5   | 57.646mb -0.00% | 1.000μs +25.00%   |
| RowsBench               | bench_flat_map_on_1k       | 5    | 5   | 65.879mb -0.00% | 18.876ms +17.30%  |
| RowsBench               | bench_map_on_10k           | 5    | 5   | 91.400mb -0.00% | 84.495ms +13.78%  |
| RowsBench               | bench_merge_1k_on_10k      | 5    | 5   | 60.096mb -0.00% | 4.194ms +22.05%   |
| RowsBench               | bench_partition_by_on_10k  | 5    | 5   | 64.466mb -3.26% | 63.082ms +13.88%  |
| RowsBench               | bench_remove_on_10k        | 5    | 5   | 62.196mb -0.00% | 10.178ms +11.29%  |
| RowsBench               | bench_sort_asc_on_1k       | 5    | 5   | 57.646mb -0.00% | 70.050ms +7.37%   |
| RowsBench               | bench_sort_by_on_1k        | 5    | 5   | 57.646mb -0.00% | 67.372ms +3.60%   |
| RowsBench               | bench_sort_desc_on_1k      | 5    | 5   | 57.646mb -0.00% | 66.442ms +3.57%   |
| RowsBench               | bench_sort_entries_on_1k   | 5    | 5   | 59.921mb -0.00% | 12.811ms +6.07%   |
| RowsBench               | bench_sort_on_1k           | 5    | 5   | 57.646mb -0.00% | 49.597ms +4.01%   |
| RowsBench               | bench_take_1k_on_10k       | 5    | 5   | 59.120mb -2.50% | 34.528μs -99.98%  |
| RowsBench               | bench_take_right_1k_on_10k | 5    | 5   | 59.121mb -2.50% | 41.561μs -97.05%  |
| RowsBench               | bench_unique_on_1k         | 5    | 5   | 80.486mb -0.00% | 236.059ms +5.73%  |
| NativeEntryFactoryBench | bench_10k_rows             | 5    | 5   | 83.912mb -0.01% | 223.967ms +5.46%  |
| NativeEntryFactoryBench | bench_1k_rows              | 5    | 5   | 45.420mb +0.02% | 21.769ms +8.74%   |
| NativeEntryFactoryBench | bench_5k_rows              | 5    | 5   | 62.712mb +0.01% | 111.290ms +7.74%  |
+-------------------------+----------------------------+------+-----+-----------------+-------------------+

@github-actions github-actions bot added the ci/cd label Oct 30, 2023
@stloyd stloyd force-pushed the feature/rows-perf-part1 branch 5 times, most recently from 8a6ded5 to a5912e2 Compare October 30, 2023 16:03
Covered: `find`, `findOne`, `first`, `partitionBy`, `take`, `takeRight`
@stloyd stloyd force-pushed the feature/rows-perf-part1 branch from a5912e2 to b146944 Compare October 30, 2023 16:41
@norberttech
Copy link
Member

Finally, the benchmarks are working as they are supposed to 🎉 also, good job on the performance improvements!!

@norberttech norberttech merged commit 8af1c62 into flow-php:1.x Oct 30, 2023
14 checks passed
@stloyd stloyd deleted the feature/rows-perf-part1 branch October 30, 2023 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants