Navigation Menu

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

Slightly speed up scripts #68478

Merged
merged 1 commit into from Feb 4, 2021

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Feb 3, 2021

This saves a couple of nanoseconds on ever invocation of a painless
script that uses SearchLookup. Which is most of the scripts in the hot
path. This amounts to a 3.5% performance savings for things like script
scoring and runtime fields. We got this by speeding up a method that the
async profiler reported as taking 20% of the time running a script score
with painless. This drops it to 1%. You'd think that'd result in a 19%
speed up. But no such luck.

This saves a couple of nanoseconds on ever invocation of a painless
script that uses `SearchLookup`. Which is most of the scripts in the hot
path. This amounts to a 3.5% performance savings for things like script
scoring and runtime fields. We got this by speeding up a method that the
async profiler reported as taking 20% of the time running a script score
with painless. This drops it to 1%. You'd think that'd result in a 19%
speed up. But no such luck.
@nik9000 nik9000 added >enhancement :Search/Search Search-related issues that do not fall into other categories v8.0.0 v7.12.0 labels Feb 3, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Feb 3, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@nik9000
Copy link
Member Author

nik9000 commented Feb 3, 2021

The actual speedup from this is pretty disappointing. The async profiler has betrayed me! But its a very very easy change so I figure its worth it.

@nik9000
Copy link
Member Author

nik9000 commented Feb 3, 2021

Benchmarks just finished:

Before:

Benchmark                       (indexingBufferMb)       (script)  Mode  Cnt   Score   Error  Units
ScriptScoreBenchmark.benchmark                  16     expression  avgt   10  63.950 ± 1.444  ns/op
ScriptScoreBenchmark.benchmark                  16          metal  avgt   10  52.474 ± 0.572  ns/op
ScriptScoreBenchmark.benchmark                  16  painless_cast  avgt   10  71.872 ± 0.472  ns/op
ScriptScoreBenchmark.benchmark                  16   painless_def  avgt   10  72.232 ± 1.007  ns/op

After:

Benchmark                       (indexingBufferMb)       (script)  Mode  Cnt   Score   Error  Units
ScriptScoreBenchmark.benchmark                  16     expression  avgt   10  63.203 ± 0.063  ns/op
ScriptScoreBenchmark.benchmark                  16          metal  avgt   10  52.388 ± 0.312  ns/op
ScriptScoreBenchmark.benchmark                  16  painless_cast  avgt   10  70.971 ± 0.235  ns/op
ScriptScoreBenchmark.benchmark                  16   painless_def  avgt   10  70.097 ± 0.469  ns/op

Like I said - its a small improvement for painless scripts. But its a small change.

@nik9000
Copy link
Member Author

nik9000 commented Feb 3, 2021

The async profiler led me to believe it'd be a bigger improvement or else I wouldn't even have looked. But still.

Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nik9000 nik9000 merged commit 4b75c5a into elastic:master Feb 4, 2021
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Feb 4, 2021
This saves a couple of nanoseconds on ever invocation of a painless
script that uses `SearchLookup`. Which is most of the scripts in the hot
path. This amounts to a 3.5% performance savings for things like script
scoring and runtime fields. We got this by speeding up a method that the
async profiler reported as taking 20% of the time running a script score
with painless. This drops it to 1%. You'd think that'd result in a 19%
speed up. But no such luck.
nik9000 added a commit that referenced this pull request Feb 4, 2021
This saves a couple of nanoseconds on ever invocation of a painless
script that uses `SearchLookup`. Which is most of the scripts in the hot
path. This amounts to a 3.5% performance savings for things like script
scoring and runtime fields. We got this by speeding up a method that the
async profiler reported as taking 20% of the time running a script score
with painless. This drops it to 1%. You'd think that'd result in a 19%
speed up. But no such luck.
easyice pushed a commit to easyice/elasticsearch that referenced this pull request Mar 25, 2021
This saves a couple of nanoseconds on ever invocation of a painless
script that uses `SearchLookup`. Which is most of the scripts in the hot
path. This amounts to a 3.5% performance savings for things like script
scoring and runtime fields. We got this by speeding up a method that the
async profiler reported as taking 20% of the time running a script score
with painless. This drops it to 1%. You'd think that'd result in a 19%
speed up. But no such luck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v7.12.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants