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

Span Creation Optimizations #1108

Merged
merged 2 commits into from
Oct 7, 2020
Merged

Conversation

bengl
Copy link
Collaborator

@bengl bengl commented Oct 6, 2020

What does this PR do?

  • combine 2 loops into one in span creation
  • add a fast path for childOf without references in startSpan

See commit message of first commit for performance difference

Motivation

Better Performance

Previously, a `filter` loop was run over the `references` array _prior_
to iterating through and finding the parent. This has now been combined
into a single loop, also avoiding closure creation.

On my machine, this creates a measurable performance benefit on `yarn
bench:e2e`.

Before:

```
$ yarn bench:e2e -- --duration=300 # 5 min each, w/ tracer & control
avg latency overhead % 47.97297297297296
avg requests overhead % 43.17721241906214
avg throughput overhead % 43.15483642890816
```

After:

```
$ yarn bench:e2e -- --duration=300 # 5 min each, w/ tracer & control
avg latency overhead % 41.163793103448285
avg requests overhead % 37.218656879389656
avg throughput overhead % 37.20555614151182
```
@bengl bengl requested a review from a team as a code owner October 6, 2020 22:00
@bengl bengl force-pushed the bengl/span-creation-optimizations branch from 2f56951 to 354ac45 Compare October 7, 2020 14:28
packages/dd-trace/src/opentracing/tracer.js Outdated Show resolved Hide resolved
packages/dd-trace/src/opentracing/tracer.js Outdated Show resolved Hide resolved
packages/dd-trace/src/opentracing/tracer.js Outdated Show resolved Hide resolved
@bengl bengl force-pushed the bengl/span-creation-optimizations branch from 354ac45 to 1527e92 Compare October 7, 2020 16:58
This avoids all the logic in `getParent` iterating through a list of
references to find the parent, specifically in the case where there are
no references (i.e. the user is not specifically using opentracing).

This change did not create any noticeable difference in benchmarks,
likely due to the previous change having already cut out the majority of
the overhead in this code path.
@bengl bengl force-pushed the bengl/span-creation-optimizations branch from 1527e92 to fa4c023 Compare October 7, 2020 17:41
@bengl bengl merged commit 56d9e65 into master Oct 7, 2020
@tlhunter tlhunter deleted the bengl/span-creation-optimizations branch January 19, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants