Files
sdk/pkg/analysis_server/tool/performance
Paul Berry afcfbbeba8 Migrate developer experience packages to new constructor decl syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288)

This change migrates the packages owned by the developer experience
team to use the new constructor declaration syntax, described in
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

This change was performed in an automated fashion, by (a) bumping the
packages' SDK constraints to `3.13.0-0`, (b) enabling the lints
`unnecessary_type_name_in_constructor` and
`unnecessary_const_in_enum_constructor`, (c) fixing the resulting lint
failures using `dart fix`, and then (d) reformatting the affected
files.

To ease code review, I've reverted unrelated formatting changes.

Since this change requires bumping SDK constaints to `3.13.0-0`, it
was only performed on packages that are *not* published on
pub. (Packages that *are* published on pub should remain on lower
language versions until at least after the stable version of 3.13 is
released, so that we don't block users on the stable channel from
receiving updates to those packages.)

Change-Id: Ibb4daebafd239da58251e838ea6a3f336a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505046
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-27 14:52:58 -07:00
..

This directory contains tools for recording and replaying a real world analysis server session, in order to reproduce issues and validate fixes.

This involves 3 steps:

  1. Recording a session to a log file.
  2. Normalizing the log file so it is portable across machines.
  3. Adding the scenario, which includes project setup and a pointer to the normalized log file.

Recording a session from VsCode

In order to record a session, seach for "Open analyzer Diagnostics/Insights" in the VsCode command pallet (ctrl+shift+p, or cmd+shift+p). This should open up the web app for analysis server diagnostics.

From here, select "Session communications log" from the left hand menu.

When you are ready to record your session, click "Start capturing entries", and when you are done click "Stop capturing entries".

Copy the contents of the captured log to a file on your machine somewhere.

Normalizing the log file

In order to normalize the log file, you will use the script at pkg/analysis_server/tool/log_player/normalize.dart. This script requires the following arguments:

  • -i <path> The original log
  • -o <path> The output path for the normalized log
  • -p <path> The path to the package config file for the project that you recorded from. This file will typically be at .dart_tool/package_config.json relative to the root of the project.

The normalized log files should be written to tools/performance/scenarios/logs/<scenario-name>.log.

For example, if you are running from the SDK root, and your original log file is at log.json, you could run the following:

dart pkg/analysis_server/tool/log_player/normalize.dart \
  -i log.json
  -o pkg/analysis_server/tool/performance/scenarios/logs/my_awesome_scenario.log
  -p .dart_tool/package_config.json

Setting up the scenario

Scenarios require a project, a log file, and name.

Projects are either set up by cloning a git repo (typical for external repo scenarios), or by creating a git worktree for a local project (recommended for SDK scenarios).

Scenarios are set up in pkg/analysis_server/tool/performance/scenarios/run_saved_scenarios.dart, find the top level scenarios variable in that file, and add a scenario following the pattern established there by the existing ones, or see the following examples:

Example git clone project (non-SDK git repo)

Scenario(
  name: 'my_scenario',
  logFile: fileSystem.getFile(
    logsRoot.resolve('my_scenario.json').toFilePath(),
  ),
  project: GitCloneProjectGenerator(
    'https://github.com/my-org/my-repo',
    // The commit, branch, tag etc that the scenario was recorded at.
    'commit-ish',
  ),
)

Example git worktree project (Dart SDK)

Scenario(
  name: 'my_sdk_scenario',
  logFile: fileSystem.getFile(
    logsRoot.resolve('my_sdk_scenario.json').toFilePath(),
  ),
  project: GitWorktreeProjectGenerator(
    Directory.fromUri(sdkRoot),
    'commit-ish',
    isSdkRepo: true,
    // Restricts analysis to only these dirs, must match the directories you had
    // open when recording the session.
    openSubdirs: ['pkg/analysis_server'],
  ),
)

Running scenarios

To run scenarios, use the pkg/analysis_server/tool/performance/scenarios/run_saved_scenarios.dart script.

By default this will run all scenarios, but you can pass -s <scenario-name> to run just a specific scenario.

Suggestion: pass --help to see the available scenarios.