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

DNS with less AsyncResources #2494

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

DNS with less AsyncResources #2494

wants to merge 9 commits into from

Conversation

bengl
Copy link
Collaborator

@bengl bengl commented Nov 3, 2022

No description provided.

@pr-commenter
Copy link

pr-commenter bot commented Nov 3, 2022

Benchmarks

Found 15 performance improvements and 14 performance regressions! Performance is the same for 937 cases.

scenario:plugin-graphql-with-depth-off-14

  • 🟥 cpu_user_time [+0.408s; +0.879s] or [+4.117%; +8.873%]
  • 🟥 execution_time [+0.377s; +0.748s] or [+3.524%; +6.998%]

scenario:plugin-graphql-with-depth-on-max-14

  • 🟥 cpu_user_time [+0.315s; +0.956s] or [+3.276%; +9.958%]
  • 🟥 execution_time [+0.209s; +1.166s] or [+2.030%; +11.331%]

scenario:plugin-http-client-with-tracer-14

  • 🟥 max_rss_usage [+1.533KB; +1.986KB] or [+2.719%; +3.523%]

scenario:spans-finish-later-14

  • 🟩 instructions [-129987732; -67427021] or [-6.143%; -3.186%]

scenario:plugin-dns-with-tracer-14

  • 🟩 cpu_usage_percentage [-1.777%; -1.388%]
  • 🟩 cpu_user_time [-40.777ms; -25.272ms] or [-9.413%; -5.834%]
  • 🟩 execution_time [-0.048s; -0.025s] or [-2.946%; -1.542%]
  • 🟩 instructions [-60702601; -57467613] or [-6.382%; -6.042%]

scenario:plugin-http-server-querystring-obfuscation-14

  • 🟥 cpu_usage_percentage [+0.801%; +0.923%]
  • 🟩 execution_time [-20.782ms; -17.595ms] or [-2.365%; -2.002%]

scenario:net-with-tracer-14

  • 🟩 max_rss_usage [-1.773KB; -1.667KB] or [-3.831%; -3.602%]

scenario:plugin-graphql-with-depth-off-16

  • 🟥 instructions [+417684928; +732744256] or [+1.932%; +3.389%]

scenario:plugin-graphql-with-depth-on-max-16

  • 🟥 execution_time [+0.197s; +0.476s] or [+1.812%; +4.387%]
  • 🟩 max_rss_usage [-149.549KB; -109.963KB] or [-15.739%; -11.573%]

scenario:plugin-graphql-with-depth-and-collapse-on-16

  • 🟥 instructions [+418318672; +494072812] or [+2.013%; +2.377%]

scenario:plugin-dns-with-tracer-16

  • 🟩 cpu_usage_percentage [-1.364%; -1.089%]
  • 🟩 cpu_user_time [-41.552ms; -25.698ms] or [-10.082%; -6.235%]
  • 🟩 instructions [-45330723; -42981979] or [-5.437%; -5.155%]
  • 🟥 max_rss_usage [+1.521KB; +1.796KB] or [+2.966%; +3.502%]

scenario:net-with-tracer-16

  • 🟥 cpu_user_time [+8.224ms; +12.123ms] or [+3.628%; +5.348%]
  • 🟥 execution_time [+8.183ms; +10.161ms] or [+2.295%; +2.850%]

scenario:scope-manager-base-18

  • 🟥 cpu_user_time [+1.459ms; +11.285ms] or [+1.857%; +14.367%]

scenario:plugin-dns-with-tracer-18

  • 🟩 cpu_usage_percentage [-2.253%; -1.830%]
  • 🟩 cpu_user_time [-55.160ms; -38.703ms] or [-12.846%; -9.013%]
  • 🟩 execution_time [-0.055s; -0.025s] or [-3.345%; -1.525%]
  • 🟩 instructions [-68548155; -58171438] or [-7.568%; -6.423%]

scenario:plugin-graphql-with-depth-and-collapse-on-18

  • 🟥 instructions [+434378264; +610041265] or [+1.911%; +2.684%]

@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Merging #2494 (f835187) into master (6a38f5a) will decrease coverage by 0.13%.
Report is 534 commits behind head on master.
The diff coverage is 54.05%.

@@            Coverage Diff             @@
##           master    #2494      +/-   ##
==========================================
- Coverage   93.04%   92.91%   -0.13%     
==========================================
  Files         286      286              
  Lines        9695     9715      +20     
==========================================
+ Hits         9021     9027       +6     
- Misses        674      688      +14     
Files Changed Coverage Δ
packages/datadog-plugin-dns/src/lookup.js 100.00% <ø> (ø)
packages/datadog-plugin-dns/src/lookup_service.js 100.00% <ø> (ø)
packages/datadog-plugin-dns/src/resolve.js 100.00% <ø> (ø)
packages/datadog-plugin-dns/src/reverse.js 100.00% <ø> (ø)
packages/dd-trace/src/plugins/outgoing.js 18.18% <0.00%> (-4.05%) ⬇️
packages/dd-trace/src/plugins/plugin.js 77.14% <25.00%> (-6.73%) ⬇️
packages/dd-trace/src/plugins/tracing.js 51.28% <27.27%> (-10.79%) ⬇️
packages/datadog-instrumentations/src/dns.js 89.58% <80.00%> (-1.33%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@bengl bengl marked this pull request as ready for review November 3, 2022 22:52
@bengl bengl requested a review from a team as a code owner November 3, 2022 22:52
@@ -12,6 +12,10 @@ class TracingPlugin extends Plugin {
this.operation = this.constructor.operation

this.addTraceSub('start', message => {
// TODO hasAsyncEnd is temporary until all plugins are converted to have asyncEnd
Copy link
Member

Choose a reason for hiding this comment

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

Can a WeakMap be used instead? If that's possible then it would be possible to just always store the parent store and the additional property wouldn't be needed.

@@ -46,7 +58,19 @@ class TracingPlugin extends Plugin {
this.activeSpan.finish()
}

asyncEnd (...args) {
this.finish(...args)
this.exit(...args)
Copy link
Member

Choose a reason for hiding this comment

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

This should only happen for OutgoingPlugin and InternalPlugin. Even though it doesn't really affect this PR since it only updates an internal plugin, it should still be moved to the right place to avoid issues with other plugins as they are updated to use the new event.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rochdev There's nothing currently called InternalPlugin, AFAIK.

packages/dd-trace/src/plugins/tracing.js Show resolved Hide resolved
Qard
Qard previously approved these changes Nov 18, 2022
Qard
Qard previously approved these changes Nov 18, 2022
Qard
Qard previously approved these changes Nov 18, 2022
@tlhunter
Copy link
Member

Note that I just force-pushed a rebase on master to run the benchmarks again. @bengl feel free to force push if you get errors when pushing later changes.

}
context.result = result
asyncEndCh.publish(context)
cb.apply(this, arguments)
Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline, let's make sure this is wrapped between 2 events so that the subscriber can restore the right context only in the callback, similar to promises and to what is described in nodejs/node#44943 (comment).

@tlhunter tlhunter requested a review from a team as a code owner August 15, 2023 22:07
@tlhunter tlhunter requested review from jbertran and removed request for a team August 15, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants