-
Notifications
You must be signed in to change notification settings - Fork 435
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
contrib/go-redis/redis.v8: optimize BeforeProcess and BeforeProcessPipeline #920
Merged
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
johejo
force-pushed
the
optimize_contrib_go_redis_v8
branch
from
May 7, 2021 23:42
700248c
to
6e87961
Compare
gbbr
reviewed
May 10, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice, thanks! Just one nit, otherwise all good by me.
johejo
force-pushed
the
optimize_contrib_go_redis_v8
branch
from
May 10, 2021 11:29
6e87961
to
8f73a07
Compare
gbbr
reviewed
May 10, 2021
…peline This change includes the following three optimizations. 1. The previous implementation split the command with strings.Split, but only the 0th element is actually needed as a tag for span. Therefore, use strings.IndexByte to find the first space and slice the raw command string. 2. Replace the length derivation of args with the counting of the number of spaces. 3. The number of ddtrace.StartSpanOptions is often pre-determined, so make it in advance to reduce allocation.
johejo
force-pushed
the
optimize_contrib_go_redis_v8
branch
from
May 10, 2021 17:48
8f73a07
to
5966af7
Compare
gbbr
approved these changes
May 11, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real nice! Thanks for posting the benchmarks.
stlimtat
pushed a commit
to stlimtat/dd-trace-go
that referenced
this pull request
May 17, 2021
* 'v1' of https://github.com/DataDog/dd-trace-go: Implement DD_PROFILING_OUTPUT_DIR for dev/debug (DataDog#924) contrib/go-pg/pg.v10: add INTEGRATION flag check for tests (DataDog#921) contrib/go-redis/redis.v8: optimize BeforeProcess and BeforeProcessPipeline (DataDog#920) CI: check go.sum is up-to-date (DataDog#918) README: Fix go get instructions (DataDog#913) internal/log: Improve API for testing (DataDog#916) ddtrace/tracer: add support for agent discovery endpoint, feature flags, stats & drops (DataDog#859) internal/version: bump to v1.31.0 (DataDog#910) CONTRIBUTING.md: add link to contrib/README.md (DataDog#802) profiler: Disable agentless mode for WithAPIKey (DataDog#906) contrib/Shopify/sarama: fix possible deadlock in WrapAsyncProducer (DataDog#907) contrib/database/sql.tracedConn implement driver.SessionResetter (DataDog#908) ddtrace/opentracer: consider FollowsFrom references as children (DataDog#905) ddtrace/opentracer: add support for opentracing.TracerContextWithSpanExtension (DataDog#855) ddtrace/tracer: follow noDebugStack setting when using SetTag with an error (DataDog#900) contrib/net/http: add a getter to retrieve original round tripper (DataDog#903) ddtrace/tracer: ensure Flush call is synchronous (DataDog#901)
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.
This change includes the following three optimizations.
The previous implementation split the command with strings.Split, but only
the 0th element is actually needed as a tag for span.
Therefore, use strings.IndexByte to find the first space and slice the raw
command string.
Replace the length derivation of args with the counting of the number of
spaces.
The number of ddtrace.StartSpanOptions is often pre-determined,
so make it in advance to reduce allocation.
Benchmark
Result