Skip to content

Add parallelism information to profiles#4765

Merged
szegedi merged 2 commits into
masterfrom
szegedi/parallelism
Jan 15, 2025
Merged

Add parallelism information to profiles#4765
szegedi merged 2 commits into
masterfrom
szegedi/parallelism

Conversation

@szegedi

@szegedi szegedi commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds information about available parallelism and size of libuv thread pool to profiles.

Motivation

Combined with timeline events activity, this can allow us to determine in the backend if the libuv thread pool is undersized and offer an analysis/insight for it.

Additional Notes

Jira link: PROF-10686

@github-actions

github-actions Bot commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.23 MB
Deduped: 94.81 MB
No deduping: 95.37 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | @datadog/libdatadog | 0.2.2 | 29.27 MB | 29.27 MB | | @datadog/native-appsec | 8.3.0 | 19.37 MB | 19.38 MB | | @datadog/native-iast-taint-tracking | 3.2.0 | 13.9 MB | 13.91 MB | | @datadog/pprof | 5.4.1 | 9.76 MB | 10.13 MB | | protobufjs | 7.2.5 | 2.77 MB | 5.16 MB | | @datadog/native-iast-rewriter | 2.6.0 | 2.58 MB | 2.72 MB | | @opentelemetry/core | 1.14.0 | 872.87 kB | 1.47 MB | | @datadog/native-metrics | 3.0.1 | 1.06 MB | 1.46 MB | | @opentelemetry/api | 1.8.0 | 1.21 MB | 1.21 MB | | import-in-the-middle | 1.11.2 | 112.74 kB | 826.22 kB | | msgpack-lite | 0.1.26 | 201.16 kB | 281.59 kB | | source-map | 0.7.4 | 226 kB | 226 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | lru-cache | 7.18.3 | 133.92 kB | 133.92 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | @datadog/sketches-js | 2.1.0 | 109.9 kB | 109.9 kB | | semver | 7.6.3 | 95.82 kB | 95.82 kB | | lodash.sortby | 4.7.0 | 75.76 kB | 75.76 kB | | ignore | 5.3.1 | 51.46 kB | 51.46 kB | | int64-buffer | 0.1.10 | 49.18 kB | 49.18 kB | | shell-quote | 1.8.1 | 44.96 kB | 44.96 kB | | istanbul-lib-coverage | 3.2.0 | 29.34 kB | 29.34 kB | | rfdc | 1.3.1 | 25.21 kB | 25.21 kB | | @isaacs/ttlcache | 1.4.1 | 25.2 kB | 25.2 kB | | tlhunter-sorted-set | 0.1.0 | 24.94 kB | 24.94 kB | | limiter | 1.1.5 | 23.17 kB | 23.17 kB | | dc-polyfill | 0.1.4 | 23.1 kB | 23.1 kB | | retry | 0.13.1 | 18.85 kB | 18.85 kB | | jest-docblock | 29.7.0 | 8.99 kB | 12.76 kB | | crypto-randomuuid | 1.0.0 | 11.18 kB | 11.18 kB | | path-to-regexp | 0.1.12 | 6.6 kB | 6.6 kB | | koalas | 1.0.2 | 6.47 kB | 6.47 kB | | module-details-from-path | 1.0.3 | 4.47 kB | 4.47 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@pr-commenter

pr-commenter Bot commented Oct 8, 2024

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2024-12-11 11:21:29

Comparing candidate commit aa1b8a6 in PR branch szegedi/parallelism with baseline commit 50bb0dd in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 262 metrics, 4 unstable metrics.

@szegedi
szegedi force-pushed the szegedi/parallelism branch from 6e205e4 to 9d66475 Compare October 9, 2024 14:07
@codecov

codecov Bot commented Oct 9, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.90%. Comparing base (7f93d36) to head (9d66475).
Report is 28 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4765       +/-   ##
===========================================
+ Coverage   69.19%   93.90%   +24.70%     
===========================================
  Files           1      106      +105     
  Lines         198     3312     +3114     
  Branches       33        0       -33     
===========================================
+ Hits          137     3110     +2973     
- Misses         61      202      +141     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@szegedi szegedi changed the title add parallelism information to profiles Add parallelism information to profiles Oct 22, 2024
@szegedi
szegedi force-pushed the szegedi/parallelism branch 2 times, most recently from be7f2b1 to 6f50f69 Compare December 3, 2024 09:06
@szegedi
szegedi marked this pull request as ready for review December 3, 2024 10:04
@szegedi
szegedi requested a review from a team as a code owner December 3, 2024 10:04
@szegedi
szegedi requested a review from nsavoire December 3, 2024 10:04

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

UV_THREADPOOL_SIZE might not be defined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, that's fine – the property will be missing here then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not send the default threadpool size when it is not overridden by UV_THREADPOOL_SIZE ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, a hardcoded 4? The comment above that line says it: "we'll let the backend figure out the effective numeric value." I think this is just me instinctively preferring having logic in the backend, 'cause we can more easily fix/modify that than libraries (and have users upgrade to new libraries.) E.g. if libuv in a future Node version changes either the default or the max thread pool size.

I might go for converting early to number though, as JavaScript's parseInt is almost compatible with C atoi that libuv uses to parse it so I wouldn't have to implement an atoi equivalent in Java in the backend.

@nsavoire nsavoire Dec 3, 2024

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note that if container has a cpu limit enforced through cpu CFS shares, the value will be wrong (eg. with a CPU limit of 0.5CPU on a 96 core system, value will be 96).
Datadog agent metrics (eg. kubernetes.cpu.requests/limits) could be useful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh I see. This would still be useful, 'cause it could give an upper limit for a suggestion for UV_THREADPOOL_SIZE. The main use I have for this is that I could provide a profiler analysis: if there's more concurrent DNS and filesystem operations (and in future, cryptography and compression) than we have workers in the libuv worker thread pool, we can suggest the customer increase the size of the pool as long as there's space for some extra parallelism in the CPU cores. K8s won't limit parallelism as looking from outside the box, you don't see the threads, it just limits the overall utilization of the CPU, right? Theory being that DNS and filesystem operations cause the libuv threads to be blocked on IO, so they're idle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But I could also definitely have use for kubernetes.cpu.requests and kubernetes.cpu.limits too. I don't suppose I can grab those values easily from within the Node app?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't believe there is a way to get kubernetes.cpu.requests and kubernetes.cpu.limits from node app.
My point is that this value will be hard to interpret.
If threads are mostly blocked on network / IO operations, it might be beneficial to increase thread pool size even if available parallelism is low.

@szegedi
szegedi force-pushed the szegedi/parallelism branch 2 times, most recently from c641a92 to 54bfb86 Compare December 6, 2024 14:28
@szegedi
szegedi requested a review from nsavoire December 9, 2024 08:07
nsavoire
nsavoire previously approved these changes Dec 10, 2024
Comment on lines 98 to 105

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wow, great attention to detail here !

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry for the noise, I did not understand that you were delegating to the backend the computation of the default value.
My first take was that the library was in a better position to determine the default value, but since the node version is part of profile metadata, it might be better to let the backend handle this, since updating code in the backend is far more easier.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't believe there is a way to get kubernetes.cpu.requests and kubernetes.cpu.limits from node app.
My point is that this value will be hard to interpret.
If threads are mostly blocked on network / IO operations, it might be beneficial to increase thread pool size even if available parallelism is low.

@szegedi

szegedi commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

Had to rebase it because it conflicted with #4980

@szegedi
szegedi requested a review from nsavoire January 14, 2025 12:07
@szegedi
szegedi merged commit b070889 into master Jan 15, 2025
@szegedi
szegedi deleted the szegedi/parallelism branch January 15, 2025 09:34
watson pushed a commit that referenced this pull request Jan 22, 2025
@watson watson mentioned this pull request Jan 22, 2025
watson pushed a commit that referenced this pull request Jan 22, 2025
@watson watson mentioned this pull request Jan 22, 2025
watson pushed a commit that referenced this pull request Jan 23, 2025
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.

2 participants