Skip to content

[Profiler] Remove sample-count threshold from profiler discard logic#4566

Open
thomasbertet wants to merge 1 commit intomainfrom
thomas.bertet/profiler-skip-on-duration-and-long-tasks
Open

[Profiler] Remove sample-count threshold from profiler discard logic#4566
thomasbertet wants to merge 1 commit intomainfrom
thomas.bertet/profiler-skip-on-duration-and-long-tasks

Conversation

@thomasbertet
Copy link
Copy Markdown
Collaborator

@thomasbertet thomasbertet commented May 6, 2026

Motivation

Short-lived non-SPA navigations (full-page loads with moderate scripting) were being silently discarded by the profiler because they accumulated fewer than 50 stack-trace samples (~500ms of scripting activity), even when the page was active long enough to meet the duration threshold. This caused an empty "No profiles" state in the Profiling UI for use cases like shopist.io where users click quickly across pages.

Additionally, filtering on sample count introduced a selection bias in aggregations: only CPU-heavy pages were retained, skewing flame graphs away from scripting-light but potentially slow navigations.

The trade-off here is collecting more profiles for a slightly better coverage of short-lived navigations.
Nonetheless, we keep discarding profiles <5s if they don't have Long Tasks in them.

Changes

  • Removed the minNumberOfSamples check from the profile discard logic in profiler.ts. Profiles are now kept or discarded based solely on duration (minProfileDurationMs) and long-task presence.
  • Removed the minNumberOfSamples field from RUMProfilerConfiguration and DEFAULT_RUM_PROFILER_CONFIGURATION.
  • Added unit tests covering the three discard cases: below duration threshold with no long tasks (discarded), below duration threshold with a long task (sent), and above duration threshold (sent).

Test instructions

  1. Load a non-SPA page with the RUM SDK and profiler enabled.
  2. Navigate away quickly (within a few seconds) before reaching the 5s duration threshold.
  3. Verify a profile is sent if a long task was captured, discarded otherwise.
  4. Run yarn test:unit --spec packages/rum/src/domain/profiling/profiler.spec.ts — 20 tests should pass.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@thomasbertet thomasbertet changed the title ♻️ Remove sample-count threshold from profiler discard logic [Profiler] Remove sample-count threshold from profiler discard logic May 6, 2026
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented May 6, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 179.65 KiB 179.65 KiB 0 B 0.00%
Rum Profiler 6.17 KiB 6.04 KiB -132 B -2.09%
Rum Recorder 27.03 KiB 27.03 KiB 0 B 0.00%
Logs 56.78 KiB 56.78 KiB 0 B 0.00%
Rum Slim 135.50 KiB 135.50 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0039 0.004 +2.56%
RUM - add action 0.0131 0.0137 +4.58%
RUM - add error 0.0117 0.0123 +5.13%
RUM - add timing 0.0025 0.003 +20.00%
RUM - start view 0.0119 0.0119 0.00%
RUM - start/stop session replay recording 0.0006 0.0007 +16.67%
Logs - log message 0.0138 0.0194 +40.58%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 31.78 KiB 32.57 KiB +810 B
RUM - add action 56.94 KiB 56.94 KiB -9 B
RUM - add timing 32.72 KiB 33.40 KiB +694 B
RUM - add error 60.80 KiB 61.40 KiB +618 B
RUM - start/stop session replay recording 32.10 KiB 31.94 KiB -168 B
RUM - start view 484.29 KiB 483.78 KiB -523 B
Logs - log message 95.66 KiB 103.74 KiB +8.08 KiB

🔗 RealWorld

@datadog-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 Bot commented May 6, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 77.01% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 24c88f2 | Docs | Datadog PR Page | Give us feedback!

@thomasbertet thomasbertet force-pushed the thomas.bertet/profiler-skip-on-duration-and-long-tasks branch 4 times, most recently from 6742b2f to b1f8a72 Compare May 7, 2026 06:58
Profiles were previously discarded when the number of stack-trace samples
was below 50 (~500ms of scripting activity), causing short-lived non-SPA
navigations with little scripting to be silently dropped. The sample-count
check and the minNumberOfSamples configuration field are removed entirely.
Profiles are now kept or discarded based solely on duration and long-task
presence.
@thomasbertet thomasbertet force-pushed the thomas.bertet/profiler-skip-on-duration-and-long-tasks branch from b1f8a72 to 24c88f2 Compare May 7, 2026 08:12
@thomasbertet thomasbertet marked this pull request as ready for review May 7, 2026 12:46
@thomasbertet thomasbertet requested a review from a team as a code owner May 7, 2026 12:46
Copy link
Copy Markdown
Collaborator

@thomas-lebeau thomas-lebeau left a comment

Choose a reason for hiding this comment

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

Can you edit the PR title to follow our convention. This help generate clean changelog and release notes.

other than that, LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants