Skip to content

Trace events: add -time-trace to swiftc#2110

Open
MaxDesiatov wants to merge 5 commits intomainfrom
maxd/time-trace
Open

Trace events: add -time-trace to swiftc#2110
MaxDesiatov wants to merge 5 commits intomainfrom
maxd/time-trace

Conversation

@MaxDesiatov
Copy link
Copy Markdown
Contributor

@MaxDesiatov MaxDesiatov commented Apr 1, 2026

Depends on swiftlang/swift#88251.

This behaves in the same way as Clang's -ftime-trace:

Turn on time profiler. Generates JSON file based on output filename.

Generated JSON can be previewed with tools like https://ui.perfetto.dev.

@MaxDesiatov MaxDesiatov changed the title Trace events: add -ftime-trace to swiftc Trace events: add -time-trace to swiftc Apr 1, 2026
Copy link
Copy Markdown
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

Is there a chance other tools will benefit from a TimeTrace-like thing in the future and we would need to hoist it out of the driver?

Comment thread Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift Outdated
// Include the main module name in the trace file name to avoid collisions
// when multiple targets compile the same dependency module.
if enableTimeTrace {
commandLine.appendFlag("-time-trace")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not 100% sure how this option interacts with compiler caching, but additional flags/outputs will need to be taken into account. I think we should instead investigate having the dependency scanner specify these flags to module dependency command-line recipes.

Copy link
Copy Markdown
Contributor Author

@MaxDesiatov MaxDesiatov Apr 3, 2026

Choose a reason for hiding this comment

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

I removed it from supplementary outputs and removed suffixes. Do you still think dependency scanner investigation is needed if -time-trace-path is also cacheInvariant?

Comment thread Sources/SwiftDriver/Driver/Driver.swift Outdated
@MaxDesiatov MaxDesiatov marked this pull request as ready for review April 3, 2026 15:14
@MaxDesiatov MaxDesiatov requested a review from artemcm April 3, 2026 15:15
@MaxDesiatov
Copy link
Copy Markdown
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Copy Markdown
Contributor Author

@swift-ci test windows

@MaxDesiatov MaxDesiatov requested a review from a team as a code owner April 21, 2026 15:15
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