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

Object query & Scla 3 optimizations #2033

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Conversation

kyri-petrou
Copy link
Collaborator

In this PR we optimize the creation of the object query by utilizing indices instead of a Map when an object . This gives us roughly 7-8% improvement in queries that contain a lot of objects with both pure and effectful fields:

series/2.x:
[info] Benchmark                                          Mode  Cnt    Score    Error  Units
[info] NestedZQueryBenchmark.multifieldBatchedQuery1000  thrpt    5  780.252 ± 14.266  ops/s

PR:
[info] Benchmark                                          Mode  Cnt    Score    Error  Units
[info] NestedZQueryBenchmark.multifieldBatchedQuery1000  thrpt    5  832.235 ± 13.481  ops/s

Additionally, in Scala 3 we can annotate lazy vals with @threadUnsafe which compiles to a faster implementation which can be used in cases that the initialization is known to be performed by a single thread. It more or less compiles to the following:

private var fooVar = null
def foo = {
  if (fooVar == null) ???
  fooVar
}

This is OK for this usecase because we initialise the lazy val's during the call of the toType method, which is guaranteed to be performed on a single thread when we create the interpreter.

@kyri-petrou kyri-petrou merged commit 078c28d into series/2.x Dec 11, 2023
10 checks passed
@kyri-petrou kyri-petrou deleted the optimize-object-query branch December 11, 2023 07:21
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.

2 participants