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

Further optimize filter expressions #7311

Merged
merged 4 commits into from
Aug 2, 2024
Merged

Conversation

nikolai-mb
Copy link
Contributor

This PR is a continuation of the improvements from PR #7005

By introducing a struct and extracting the parameter manually, it's possible to avoid a closure and lambda expression allocation for each filter operator value.

Note:
The added struct has a single property "p". The name is important as this is the same name that EF Core uses for the SQL Server provider by default when parameterizing values from anonymous closures. Changing the name causes SQL Server snapshot tests to fail, since "@__p_0" in the produced SQL would turn into "@__ChangedName_p"

Commit e9b8238 is not related to the perf improvements below, but should speed up the static class initialization a tiny bit

Benchmarks (commit 9b5b9e1)

The HC14 benchmarks represent the changes made in #7005 and what's currently in the main branch

Method Mean Error StdDev Ratio Gen0 Allocated Alloc Ratio
ContainsHC13 642.49 ns 4.118 ns 3.852 ns 1.00 0.0134 744 B 1.00
ContainsHC14 354.24 ns 2.918 ns 2.729 ns 0.55 0.0095 512 B 0.69
ContainsPR 264.37 ns 1.564 ns 1.386 ns 0.41 0.0072 376 B 0.51
EqualsHC13 382.57 ns 1.079 ns 1.010 ns 1.00 0.0095 488 B 1.00
EqualsHC14 159.52 ns 0.414 ns 0.323 ns 0.42 0.0050 256 B 0.52
EqualsPR 76.30 ns 0.359 ns 0.318 ns 0.20 0.0024 120 B 0.25
GreaterThanHC13 378.11 ns 3.283 ns 3.071 ns 1.00 0.0095 488 B 1.00
GreaterThanHC14 153.46 ns 0.617 ns 0.577 ns 0.41 0.0050 256 B 0.52
GreaterThanPR 75.43 ns 0.243 ns 0.227 ns 0.20 0.0024 120 B 0.25
InHC13 3,836.08 ns 33.165 ns 31.023 ns 1.00 0.1068 5840 B 1.00
InHC14 224.84 ns 0.502 ns 0.445 ns 0.06 0.0057 288 B 0.05
InPR 134.35 ns 0.667 ns 0.623 ns 0.04 0.0029 152 B 0.03
LowerThanHC13 389.97 ns 1.322 ns 1.236 ns 1.00 0.0095 488 B 1.00
LowerThanHC14 154.34 ns 0.502 ns 0.469 ns 0.40 0.0050 256 B 0.52
LowerThanPR 75.47 ns 0.247 ns 0.231 ns 0.19 0.0024 120 B 0.25
NotContainsHC13 648.94 ns 3.856 ns 3.607 ns 1.00 0.0153 792 B 1.00
NotContainsHC14 378.81 ns 1.312 ns 1.228 ns 0.58 0.0110 560 B 0.71
NotContainsPR 281.94 ns 1.398 ns 1.168 ns 0.43 0.0081 424 B 0.54
NotEqualsHC13 381.56 ns 0.809 ns 0.757 ns 1.00 0.0095 488 B 1.00
NotEqualsHC14 152.36 ns 0.502 ns 0.392 ns 0.40 0.0050 256 B 0.52
NotEqualsPR 74.08 ns 0.179 ns 0.158 ns 0.19 0.0024 120 B 0.25
StartsWithHC13 646.54 ns 4.196 ns 3.720 ns 1.00 0.0134 744 B 1.00
StartsWithHC14 348.92 ns 1.124 ns 0.996 ns 0.54 0.0100 512 B 0.69
StartsWithPR 257.99 ns 1.333 ns 1.247 ns 0.40 0.0072 376 B 0.51

@nikolai-mb
Copy link
Contributor Author

I see there's some raven snapshot tests failing, although not entirely sure why since the EF sql conversions work flawlessly. Will have a look. I'm still having issues with tons of snapshot tests failing due to snapshot containing \n while my machine produces \r\n - is there a known issue / fix for this by any chance?

@nikolai-mb
Copy link
Contributor Author

On second glance i see that the tests are failing for other PR's as well and not related to this change specifically

@PascalSenn
Copy link
Member

@nikolai-mb there are a few flaky tests
@glen-84 do you see anything out of the ordinary here?

@glen-84
Copy link
Collaborator

glen-84 commented Jul 31, 2024

There are currently 4 projects with failing tests:

I'm still having issues with tons of snapshot tests failing due to snapshot containing \n while my machine produces \r\n - is there a known issue / fix for this by any chance?

Yes. I have this on my after-hours to-do list. Since the snapshot data can come from various places, it's not always possible to configure the EOL sequence. For this reason, I'm considering proposing an update to Snapshooter that forces a specific sequence to be used while writing the snapshot.

@glen-84 do you see anything out of the ordinary here?

I don't see any new test failures, if that's what you're asking. 🙂

@michaelstaib michaelstaib merged commit fdb0274 into ChilliCream:main Aug 2, 2024
5 checks passed
@michaelstaib
Copy link
Member

Thank you for your contribution.

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.

4 participants