Skip to content

Conversation

@norberttech
Copy link
Member

@norberttech norberttech commented Aug 9, 2024

Change Log

Added

Fixed

Changed

  • All scalar functions will now expect parameters to be a scalar function or literal value

Removed

  • ToMoney scalar function and money optional dependency

Deprecated

Security


Description

Looking at all scalar functions I noticed a very inconsistent approach to evaluating and validating parameters.
In order to simplify it and make it more predictable I introduced Parameter object that can take any value and if it's a scalar function it will evaluate it. On top of that we can also tell Parameter to return us value in given type or null.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 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   | 4.131mb -4.39%  | 511.938ms +0.41% | ±0.34% +47.44%  |
| JsonExtractorBench    | bench_extract_10k | 1    | 3   | 4.263mb -4.26%  | 1.077s -0.57%    | ±1.11% +16.57%  |
| ParquetExtractorBench | bench_extract_10k | 1    | 3   | 28.726mb -0.63% | 445.725ms +4.48% | ±2.04% +793.11% |
| TextExtractorBench    | bench_extract_10k | 1    | 3   | 3.890mb -4.67%  | 33.792ms -0.04%  | ±1.73% +27.54%  |
| XmlExtractorBench     | bench_extract_10k | 1    | 3   | 3.880mb -4.68%  | 754.081ms +0.33% | ±1.42% +221.60% |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
Transformers
+-----------------------------+--------------------------+------+-----+------------------+-----------------+-----------------+
| benchmark                   | subject                  | revs | its | mem_peak         | mode            | rstdev          |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+-----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1    | 3   | 116.232mb -0.16% | 61.665ms +5.02% | ±2.32% +372.04% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+-----------------+
Loaders
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
| benchmark          | subject        | revs | its | mem_peak         | mode             | rstdev          |
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
| CSVLoaderBench     | bench_load_10k | 1    | 3   | 54.353mb -0.33%  | 85.169ms -0.16%  | ±0.54% -71.32%  |
| JsonLoaderBench    | bench_load_10k | 1    | 3   | 102.675mb -0.18% | 64.021ms +23.17% | ±3.41% +303.81% |
| ParquetLoaderBench | bench_load_10k | 1    | 3   | 124.005mb -0.15% | 1.322s +7.52%    | ±3.02% +569.32% |
| TextLoaderBench    | bench_load_10k | 1    | 3   | 17.147mb -1.06%  | 44.318ms +1.68%  | ±0.60% +85.87%  |
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
Building Blocks
+-------------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| benchmark               | subject                    | revs | its | mem_peak         | mode             | rstdev          |
+-------------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| TypeDetectorBench       | bench_type_detector        | 1    | 3   | 52.813mb -0.34%  | 396.984ms +1.29% | ±3.13% -7.69%   |
| TypeDetectorBench       | bench_type_detector        | 1    | 3   | 13.078mb -1.39%  | 78.987ms -5.34%  | ±1.07% -69.91%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 107.005mb -0.17% | 468.573ms -0.85% | ±2.37% +256.73% |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 55.364mb -0.33%  | 234.044ms -3.00% | ±1.37% +57.03%  |
| NativeEntryFactoryBench | bench_entry_factory        | 1    | 3   | 14.202mb -1.28%  | 54.711ms +6.40%  | ±2.35% +80.54%  |
| RowsBench               | bench_chunk_10_on_10k      | 2    | 3   | 86.988mb -0.21%  | 3.587ms +12.84%  | ±3.42% +99.52%  |
| RowsBench               | bench_diff_left_1k_on_10k  | 2    | 3   | 102.592mb -0.18% | 187.842ms +1.03% | ±2.59% +290.58% |
| RowsBench               | bench_diff_right_1k_on_10k | 2    | 3   | 85.312mb -0.21%  | 19.935ms +5.15%  | ±1.61% +359.37% |
| RowsBench               | bench_drop_1k_on_10k       | 2    | 3   | 88.228mb -0.21%  | 1.908ms +13.13%  | ±2.14% +184.14% |
| RowsBench               | bench_drop_right_1k_on_10k | 2    | 3   | 88.228mb -0.21%  | 1.925ms +19.07%  | ±3.25% +47.48%  |
| RowsBench               | bench_entries_on_10k       | 2    | 3   | 85.340mb -0.21%  | 2.757ms -2.38%   | ±2.00% +22.74%  |
| RowsBench               | bench_filter_on_10k        | 2    | 3   | 85.869mb -0.21%  | 16.989ms +4.65%  | ±1.99% -34.83%  |
| RowsBench               | bench_find_on_10k          | 2    | 3   | 85.869mb -0.21%  | 18.315ms +15.02% | ±2.90% +13.66%  |
| RowsBench               | bench_find_one_on_10k      | 10   | 3   | 83.773mb -0.22%  | 1.800μs +12.93%  | ±0.00% -100.00% |
| RowsBench               | bench_first_on_10k         | 10   | 3   | 83.773mb -0.22%  | 0.300μs 0.00%    | ±0.00% 0.00%    |
| RowsBench               | bench_flat_map_on_1k       | 2    | 3   | 93.123mb -0.19%  | 12.373ms -0.53%  | ±1.20% +4.80%   |
| RowsBench               | bench_map_on_10k           | 2    | 3   | 122.494mb -0.15% | 63.053ms +4.87%  | ±2.32% +174.83% |
| RowsBench               | bench_merge_1k_on_10k      | 2    | 3   | 86.389mb -0.21%  | 1.607ms +35.83%  | ±3.31% +516.95% |
| RowsBench               | bench_partition_by_on_10k  | 2    | 3   | 89.741mb -0.20%  | 64.520ms +13.47% | ±0.84% +89.02%  |
| RowsBench               | bench_remove_on_10k        | 2    | 3   | 88.490mb -0.21%  | 4.100ms +6.74%   | ±0.56% +480.01% |
| RowsBench               | bench_sort_asc_on_1k       | 2    | 3   | 83.923mb -0.22%  | 39.751ms +0.57%  | ±2.96% +255.73% |
| RowsBench               | bench_sort_by_on_1k        | 2    | 3   | 83.924mb -0.22%  | 39.193ms -0.86%  | ±0.69% +14.56%  |
| RowsBench               | bench_sort_desc_on_1k      | 2    | 3   | 83.923mb -0.22%  | 38.925ms -0.49%  | ±2.24% +30.33%  |
| RowsBench               | bench_sort_entries_on_1k   | 2    | 3   | 86.215mb -0.21%  | 7.392ms +1.28%   | ±0.12% -31.62%  |
| RowsBench               | bench_sort_on_1k           | 2    | 3   | 83.773mb -0.22%  | 28.308ms +0.35%  | ±0.36% -75.42%  |
| RowsBench               | bench_take_1k_on_10k       | 10   | 3   | 83.773mb -0.22%  | 13.518μs +1.65%  | ±1.04% -60.56%  |
| RowsBench               | bench_take_right_1k_on_10k | 10   | 3   | 83.773mb -0.22%  | 16.049μs -1.55%  | ±2.32% +4.88%   |
| RowsBench               | bench_unique_on_1k         | 2    | 3   | 102.593mb -0.18% | 193.529ms +0.67% | ±0.45% -61.74%  |
+-------------------------+----------------------------+------+-----+------------------+------------------+-----------------+

@norberttech norberttech merged commit 50a9aa0 into flow-php:1.x Aug 9, 2024
@norberttech norberttech deleted the refactoring/scalar-functions-unification 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