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

Refactor groupBy and sortBy #562

Merged
merged 6 commits into from
Feb 15, 2024
Merged

Refactor groupBy and sortBy #562

merged 6 commits into from
Feb 15, 2024

Conversation

antonmedv
Copy link
Member

No description provided.

@antonmedv antonmedv changed the title Rearrange opcodes Refactor groupBy and sortBy Feb 13, 2024
@antonmedv
Copy link
Member Author

antonmedv commented Feb 13, 2024

Low level implementation of acc[key] = append(acc[key], item)

OpDup
OpGetAcc
OpRot
OpFetch
OpPointer
OpAppend
OpGetAcc
OpSetMapIndex

is 3x slower:

_groupBy-4                    17.86µ ± 0%    57.41µ ± 2%  +221.54% (p=0.000 n=10)

@antonmedv
Copy link
Member Author

Follow up #563

@antonmedv
Copy link
Member Author

goos: darwin
goarch: arm64
pkg: github.com/expr-lang/expr
                           │   old.txt   │               new.txt                │
                           │   sec/op    │    sec/op     vs base                │
_expr-8                      65.56n ± 1%    64.27n ± 0%   -1.97% (p=0.000 n=30)
_expr_reuseVm-8              44.95n ± 2%    44.37n ± 1%   -1.29% (p=0.000 n=30)
_len-8                       35.44n ± 1%    35.47n ± 0%        ~ (p=0.482 n=30)
_filter-8                    44.63µ ± 1%    43.67µ ± 0%   -2.16% (p=0.004 n=30)
_filterLen-8                 40.91µ ± 1%    40.14µ ± 0%   -1.89% (p=0.000 n=30)
_filterFirst-8               415.5n ± 1%    403.4n ± 0%   -2.94% (p=0.000 n=30)
_filterLast-8                712.0n ± 1%    698.5n ± 1%   -1.90% (p=0.000 n=30)
_filterMap-8                 4.822µ ± 1%    4.805µ ± 0%        ~ (p=0.636 n=30)
_arrayIndex-8                61.50n ± 2%    60.71n ± 1%   -1.29% (p=0.001 n=30)
_envStruct-8                 45.06n ± 1%    44.49n ± 0%        ~ (p=0.371 n=30)
_envMap-8                    48.50n ± 1%    48.05n ± 3%   -0.93% (p=0.031 n=30)
_callFunc-8                  355.8n ± 1%    354.1n ± 0%        ~ (p=0.626 n=30)
_callMethod-8                367.6n ± 1%    366.0n ± 1%        ~ (p=0.403 n=30)
_callField-8                 58.43n ± 2%    60.81n ± 5%   +4.07% (p=0.000 n=30)
_callFast-8                  60.69n ± 1%    60.59n ± 0%        ~ (p=1.000 n=30)
_callConstExpr-8             48.38n ± 1%    47.66n ± 0%   -1.47% (p=0.000 n=30)
_largeStructAccess-8         124.6n ± 1%    122.7n ± 0%   -1.56% (p=0.001 n=30)
_largeNestedStructAccess-8   133.5n ± 1%    132.1n ± 0%   -1.05% (p=0.000 n=30)
_largeNestedArrayAccess-8    416.1µ ± 1%    398.2µ ± 1%   -4.31% (p=0.000 n=30)
_sort-8                      4.579µ ± 1%    4.232µ ± 2%   -7.57% (p=0.000 n=30)
_sortBy-8                    8.631µ ± 1%    9.601µ ± 3%  +11.25% (p=0.000 n=30)
_groupBy-8                   9.053µ ± 1%   10.117µ ± 2%  +11.75% (p=0.000 n=30)
_reduce-8                    4.674µ ± 1%    4.698µ ± 1%        ~ (p=0.186 n=30)
geomean                      604.8n         602.9n        -0.31%

@antonmedv antonmedv merged commit 36f9adb into master Feb 15, 2024
12 checks passed
@antonmedv antonmedv deleted the sort-by branch February 15, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant