Skip to main content

Best Practices for Profile Aggregates

Here are a set of practices that will make profiling less noisy and more actionable.

1. Pick a sufficient sampling rate

Without a sampling rate that works for your app, you won't be able to collect enough samples. Low sample counts lead to Profile Aggregates that may not be accurate.

For apps with more than 1 million daily active users, we recommend a sampling rate of 1%. For other apps, we recommend sampling at 100%.

2. Create user-centric custom metrics

Custom metrics can be user-centric if they measure perceived user experience.

Here are few examples of user-centric custom metrics:

  • dashboard_render_time: time to render the dashboard
  • time_to_initial_dashboard: time until dashboard is visually complete

3. Tag correlated values

The performance of large apps is often correlated with specific values. By tagging these values, you can gain a better understanding of the contextual factors contributing to a slow user experience.

Imagine you're building a text-editor app like Google Docs. Most users may have a good experience, performance-wise. But heavy users, with documents larger than 10,000 characters, likely have a much slower experience than average.

Tagging the document size will allow you to filter Profile Aggregates from heavy users.

Here are a few examples of tags by app type:

  • Text editors: number of characters in document
  • Dashboard: number of widgets
  • Spreadsheet: number of rows

Because tags only support strings as values, you'll need to convert your value to a string.

tag("documentSize", "1639");

Bucketing

Instead of tagging the raw value, we recommend bucketing it to make filtering and comparing easier. For example, instead of tagging the document size as 1639, tag it as 1000-2000.

Your bucket ranges should be large enough to have enough samples, but small enough to be actionable. As a starting point, you should start with 3 buckets and adjust from there.

Example of tagging document size:

const bucket = (value, bucketRange = 1_000) => {
const rounded = Math.round(value / bucketRange) * bucketRange;
return `${rounded}-${rounded + bucketRange}`;
};

// Bucket sizes:
// 0-5000, 5000-10000, etc...
tag("documentSize", bucket(1_639, 5_000));

Afterwards, in your Palette dashboard you can:

  1. Filter metrics by document size in Metrics to understand performance of documents of different sizes.
  2. Compare buckets in Profile Aggregates and see how function execution compares between documents of size 0-1000 and 10000-150000.

Here are the compare filters for Profile Aggregates that compare profiles from documents of different sizes 0-1000 and 10000-150000:

Left Aggregate:

FieldValue
Versionv1
EventKeydown to Paint
Path/
TagsdocumentSize: 0-1000

Right Aggregate:

FieldValue
Versionv1
EventKeydown to Paint
Path/
TagsdocumentSize: 10000-150000
© 2024 Redraw, Inc.