-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
test: add benchmark for select querybuilder #8955
Merged
AlexMesser
merged 1 commit into
typeorm:master
from
draaglom:draaglom/benchmark-query-builder
May 20, 2022
Merged
test: add benchmark for select querybuilder #8955
AlexMesser
merged 1 commit into
typeorm:master
from
draaglom:draaglom/benchmark-query-builder
May 20, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Motivation: the query builder (and within it, replacePropertyNames and associated functions) is pretty CPU intensive. For our workload, it's one of the hottest functions in our entire stack. While improved in typeorm#4760, There are still outstanding issues relating to perf e.g. typeorm#3857 As we all know though, the first step in optimization is to measure systematically ;) https://wiki.c2.com/?ProfileBeforeOptimizing On my machine, this benchmark runs in ~3500ms or about 0.35ms/query. This tells us there's a way to go - on my stack, that's about 1/3 of a typical query's latency!
draaglom
force-pushed
the
draaglom/benchmark-query-builder
branch
from
May 1, 2022 18:05
db0894a
to
7f7af42
Compare
draaglom
added a commit
to draaglom/typeorm
that referenced
this pull request
May 1, 2022
Context: the query builder is pretty CPU intensive, and can be slow - e.g. typeorm#3857 One of the things which makes this slow is `escapeRegExp` in the query builder: we freshly construct the same RegExp once per `replacePropertyName` invocation (many times per overall query!) and since the RegExp itself is constant -- we can lift it out and construct it once. Over-all this saves about 8% on our query build times as measured by typeorm#8955.
7 tasks
draaglom
added a commit
to draaglom/typeorm
that referenced
this pull request
May 1, 2022
Context: the query builder is pretty CPU intensive, and can be slow - e.g. typeorm#3857 One of the things which makes this slow is `escapeRegExp` in the query builder: we freshly construct the same RegExp once per `replacePropertyName` invocation (many times per overall query!) and since the RegExp itself is constant -- we can lift it out and construct it once. Over-all this saves about 8% on our query build times as measured by typeorm#8955.
thank you for contribution! |
AlexMesser
pushed a commit
that referenced
this pull request
May 20, 2022
Context: the query builder is pretty CPU intensive, and can be slow - e.g. #3857 One of the things which makes this slow is `escapeRegExp` in the query builder: we freshly construct the same RegExp once per `replacePropertyName` invocation (many times per overall query!) and since the RegExp itself is constant -- we can lift it out and construct it once. Over-all this saves about 8% on our query build times as measured by #8955.
draaglom
added a commit
to draaglom/typeorm
that referenced
this pull request
May 23, 2022
Digging further into typeorm#3857. See also typeorm#8955, typeorm#8956. As [previously discussed](typeorm#3857 (comment)), the query builder currently suffers from poor performance in two ways: quadratic numbers of operations with respect to total table/column counts, and poor constant factor performance (regexps can be expensive to build/run!) The constant-factor performance is the more tractable problem: no longer quadratically looping would be a chunky rewrite of the query builder, but we can locally refactor to be a bunch cheaper in terms of regexp operations. This change cuts the benchmark time here in ~half (yay!). We achieve this by simplifying the overall replacement regexp (we don't need our column names in there, since we already have a plain object where they're the keys to match against) so compilation of that is much cheaper, plus skipping the need to `escapeRegExp` every column as a result.
7 tasks
pleerock
pushed a commit
that referenced
this pull request
May 31, 2022
Digging further into #3857. See also #8955, #8956. As [previously discussed](#3857 (comment)), the query builder currently suffers from poor performance in two ways: quadratic numbers of operations with respect to total table/column counts, and poor constant factor performance (regexps can be expensive to build/run!) The constant-factor performance is the more tractable problem: no longer quadratically looping would be a chunky rewrite of the query builder, but we can locally refactor to be a bunch cheaper in terms of regexp operations. This change cuts the benchmark time here in ~half (yay!). We achieve this by simplifying the overall replacement regexp (we don't need our column names in there, since we already have a plain object where they're the keys to match against) so compilation of that is much cheaper, plus skipping the need to `escapeRegExp` every column as a result.
draaglom
added a commit
to loyaltylion/typeorm
that referenced
this pull request
May 31, 2022
Context: the query builder is pretty CPU intensive, and can be slow - e.g. typeorm#3857 One of the things which makes this slow is `escapeRegExp` in the query builder: we freshly construct the same RegExp once per `replacePropertyName` invocation (many times per overall query!) and since the RegExp itself is constant -- we can lift it out and construct it once. Over-all this saves about 8% on our query build times as measured by typeorm#8955.
draaglom
added a commit
to loyaltylion/typeorm
that referenced
this pull request
May 31, 2022
Digging further into typeorm#3857. See also typeorm#8955, typeorm#8956. As [previously discussed](typeorm#3857 (comment)), the query builder currently suffers from poor performance in two ways: quadratic numbers of operations with respect to total table/column counts, and poor constant factor performance (regexps can be expensive to build/run!) The constant-factor performance is the more tractable problem: no longer quadratically looping would be a chunky rewrite of the query builder, but we can locally refactor to be a bunch cheaper in terms of regexp operations. This change cuts the benchmark time here in ~half (yay!). We achieve this by simplifying the overall replacement regexp (we don't need our column names in there, since we already have a plain object where they're the keys to match against) so compilation of that is much cheaper, plus skipping the need to `escapeRegExp` every column as a result.
frangz
pushed a commit
to loyaltylion/typeorm
that referenced
this pull request
Nov 14, 2022
Motivation: the query builder (and within it, replacePropertyNames and associated functions) is pretty CPU intensive. For our workload, it's one of the hottest functions in our entire stack. While improved in typeorm#4760, There are still outstanding issues relating to perf e.g. typeorm#3857 As we all know though, the first step in optimization is to measure systematically ;) https://wiki.c2.com/?ProfileBeforeOptimizing On my machine, this benchmark runs in ~3500ms or about 0.35ms/query. This tells us there's a way to go - on my stack, that's about 1/3 of a typical query's latency!
frangz
pushed a commit
to loyaltylion/typeorm
that referenced
this pull request
Nov 14, 2022
Context: the query builder is pretty CPU intensive, and can be slow - e.g. typeorm#3857 One of the things which makes this slow is `escapeRegExp` in the query builder: we freshly construct the same RegExp once per `replacePropertyName` invocation (many times per overall query!) and since the RegExp itself is constant -- we can lift it out and construct it once. Over-all this saves about 8% on our query build times as measured by typeorm#8955.
frangz
pushed a commit
to loyaltylion/typeorm
that referenced
this pull request
Nov 14, 2022
Digging further into typeorm#3857. See also typeorm#8955, typeorm#8956. As [previously discussed](typeorm#3857 (comment)), the query builder currently suffers from poor performance in two ways: quadratic numbers of operations with respect to total table/column counts, and poor constant factor performance (regexps can be expensive to build/run!) The constant-factor performance is the more tractable problem: no longer quadratically looping would be a chunky rewrite of the query builder, but we can locally refactor to be a bunch cheaper in terms of regexp operations. This change cuts the benchmark time here in ~half (yay!). We achieve this by simplifying the overall replacement regexp (we don't need our column names in there, since we already have a plain object where they're the keys to match against) so compilation of that is much cheaper, plus skipping the need to `escapeRegExp` every column as a result.
7 tasks
frangz
pushed a commit
to loyaltylion/typeorm
that referenced
this pull request
Nov 14, 2022
Motivation: the query builder (and within it, replacePropertyNames and associated functions) is pretty CPU intensive. For our workload, it's one of the hottest functions in our entire stack. While improved in typeorm#4760, There are still outstanding issues relating to perf e.g. typeorm#3857 As we all know though, the first step in optimization is to measure systematically ;) https://wiki.c2.com/?ProfileBeforeOptimizing On my machine, this benchmark runs in ~3500ms or about 0.35ms/query. This tells us there's a way to go - on my stack, that's about 1/3 of a typical query's latency!
frangz
pushed a commit
to loyaltylion/typeorm
that referenced
this pull request
Nov 14, 2022
Context: the query builder is pretty CPU intensive, and can be slow - e.g. typeorm#3857 One of the things which makes this slow is `escapeRegExp` in the query builder: we freshly construct the same RegExp once per `replacePropertyName` invocation (many times per overall query!) and since the RegExp itself is constant -- we can lift it out and construct it once. Over-all this saves about 8% on our query build times as measured by typeorm#8955.
frangz
pushed a commit
to loyaltylion/typeorm
that referenced
this pull request
Nov 14, 2022
Digging further into typeorm#3857. See also typeorm#8955, typeorm#8956. As [previously discussed](typeorm#3857 (comment)), the query builder currently suffers from poor performance in two ways: quadratic numbers of operations with respect to total table/column counts, and poor constant factor performance (regexps can be expensive to build/run!) The constant-factor performance is the more tractable problem: no longer quadratically looping would be a chunky rewrite of the query builder, but we can locally refactor to be a bunch cheaper in terms of regexp operations. This change cuts the benchmark time here in ~half (yay!). We achieve this by simplifying the overall replacement regexp (we don't need our column names in there, since we already have a plain object where they're the keys to match against) so compilation of that is much cheaper, plus skipping the need to `escapeRegExp` every column as a result.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
Motivation: the query builder (and within it, replacePropertyNames and
associated functions) is pretty CPU intensive. For our workload, it's
one of the hottest functions in our entire stack.
While improved in #4760,
There are still outstanding issues relating to perf e.g. #3857
As we all know though, the first step in optimization is to measure
systematically ;)
https://wiki.c2.com/?ProfileBeforeOptimizing
On my machine, this benchmark runs in ~3550ms or about 0.35ms/query.
This tells us there's a way to go - on my stack, that's about 1/3 of a
typical query's latency!
Pull-Request Checklist
master
branchnpm run format
to apply prettier formattingnpm run test
passes with this changeFixes #0000