Skip to content

[hooks_runner] Add TimelineEvents #2327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
Merged

[hooks_runner] Add TimelineEvents #2327

merged 2 commits into from
May 23, 2025

Conversation

dcharkes
Copy link
Collaborator

@dcharkes dcharkes commented May 22, 2025

This PR adds timeline events to the hooks_runner package:

  • All FileSystem calls. (With a TracingFileSystem.)
  • All Process runs.
  • The main methods.

This enables looking at the performance:

image

(First build compiles the hook and runs the hook. Second build doesn't compile the hook and doesn't run the hook. Side note: Compiling Dart takes longer than running the hook (compiling C)!)

Some quirks:

The one improvement made in this PR is that we stop hashing the kernel file contents. Saving a hook invocation if the kernel file didn't change (~300ms) if the hook sources only had a whitespace change seems less valuable than saving the hashing of the hook kernel file on every invocation (~50ms). After this change, cached hook invocations take ~30ms per hook on the local test cases.

Closes: #2236

Copy link

github-actions bot commented May 22, 2025

Package publishing

Package Version Status Publish tag (post-merge)
package:code_assets 0.19.3 already published at pub.dev
package:data_assets 0.19.1 (error) pubspec version (0.19.1) and changelog (0.19.2) don't agree
package:ffi 2.1.4 already published at pub.dev
package:ffigen 19.0.0 already published at pub.dev
package:hooks 0.19.3 already published at pub.dev
package:hooks_runner 0.20.2 ready to publish hooks_runner-v0.20.2
package:jni 0.14.2 already published at pub.dev
package:jnigen 0.14.2 already published at pub.dev
package:native_doc_dartifier 0.0.1-pre already published at pub.dev
package:native_toolchain_c 0.16.2 already published at pub.dev
package:objective_c 8.0.0 already published at pub.dev
package:swift2objc 0.0.1-wip WIP (no publish necessary)
package:swiftgen 0.0.1-wip WIP (no publish necessary)

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

Copy link

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/native_doc_dartifier/example/native_doc_dartifier_example.dart
pkgs/native_doc_dartifier/lib/native_doc_dartifier.dart
pkgs/native_doc_dartifier/lib/src/native_doc_dartifier_base.dart
pkgs/native_doc_dartifier/test/native_doc_dartifier_test.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

@dcharkes dcharkes requested a review from goderbauer May 22, 2025 15:39
@dcharkes dcharkes marked this pull request as ready for review May 22, 2025 15:41
@coveralls
Copy link

coveralls commented May 22, 2025

Coverage Status

coverage: 85.305% (+0.02%) from 85.285%
when pulling 261a66a on developer-timeline
into ad157d1 on main.

}) async {
final packageGraphJsonFile = fileSystem.file(
packageConfigUri.resolve('package_graph.json'),
);
assert(packageGraphJsonFile.existsSync());
assert(await packageGraphJsonFile.exists());
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually work? I was under the impression that code in asserts has to be synchronous? A quick experiment in dartpad with assert(await Future.value(false)); also seems to indicate that it wouldn't fire as expected...

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, never mind. This works. Dartpad doesn't have asserts enabled it seems.

/// it up in multiple tasks.
final _task = TimelineTask();

/// Traced by [_task], cannot be used for concurrent actions.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Include a note that this used _fileSystemUntraced under the hood.

Copy link
Contributor

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@auto-submit auto-submit bot merged commit 09a756c into main May 23, 2025
37 checks passed
@auto-submit auto-submit bot deleted the developer-timeline branch May 23, 2025 12:07
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.

[native_assets_builder] Benchmark hook overheads
3 participants