Skip to content

Commit

Permalink
Avoid logging information by-default and never discarding such logs
Browse files Browse the repository at this point in the history
The analyzer wraps various functionality in logging calls like

    await logger.runAsync('Prepare linked bundles', () async {
      ...
    });

Doing so will cause time being measured and begin/end messages to be
written to a log. Those strings accumulate in a `StringBuffer` that
is never accessed.

For example running analyzer on a big app like flutter can cause
thousands of "--- Prepare linked bundles in 0 ms.  " strings to be
generated and hanged on to.

This CL makes us no longer generate such strings - only if the
creator of a context supplies a [PerformanceLog] explicitly (in which case
it is responsible for draining the messages written to it).

This reduces memory consumption when analyzing flutter by around 3 MB.

TEST=ci

Change-Id: I4979a964f13c63bd2a3cccef97fb702431731139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254925
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
mkustermann authored and Commit Bot committed Aug 12, 2022
1 parent 74be55a commit b785f7d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/context_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ContextBuilderImpl implements ContextBuilder {
}

byteStore ??= MemoryByteStore();
performanceLog ??= PerformanceLog(StringBuffer());
performanceLog ??= PerformanceLog(null);

if (scheduler == null) {
scheduler = AnalysisDriverScheduler(performanceLog);
Expand Down

0 comments on commit b785f7d

Please sign in to comment.