Skip to content

[Caching][Macro] Make macro plugin options cacheable #80474

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 1 commit into from
Apr 10, 2025

Conversation

cachemeifyoucan
Copy link
Contributor

Currently, the macro plugin options are included as cache key and the absolute path of the plugin executable and library will affect cache hit, even the plugin itself is identical.

Using the new option -resolved-plugin-validation flag, the macro plugin paths are remapped just like the other paths during dependency scanning. swift-frontend will unmap to its original path during the compilation, make sure the content hasn't changed, and load the plugin. It also hands few other corner cases for macro plugins:

  • Make sure the plugin options in the swift module is prefix mapped.
  • Make sure the remarks of the macro loading is not cached, as the mesasge includes the absolute path of the plugin, and is not cacheable.

rdar://148465899

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

This is part 1. Also need swift-driver and lldb part.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

Have you looked at the performance implications of comparing the plugin binaries?

@cachemeifyoucan
Copy link
Contributor Author

cachemeifyoucan commented Apr 3, 2025

Have you looked at the performance implications of comparing the plugin binaries?

The macro dylibs are not too big right now (biggest fat macro we ship is around 1M), even we are comparing the entire fat binary sometimes. Future improvements are definitely on the table but the good thing is the comparing method is just between frontend and scanner, thus it is easy to make improvements.

Few other possibilities without completely redo the logics right now:

  • Just diff the size
  • Insert the version on disk into CAS and compare the hash. Benefit is we don't need to read the one from CAS (which is not too expensive) and comparison is faster, but we potentially insert a different version into CAS and pay the hashing cost.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

ping

Currently, the macro plugin options are included as cache key and the
absolute path of the plugin executable and library will affect cache
hit, even the plugin itself is identical.

Using the new option `-resolved-plugin-validation` flag, the macro
plugin paths are remapped just like the other paths during dependency
scanning. `swift-frontend` will unmap to its original path during the
compilation, make sure the content hasn't changed, and load the plugin.
It also hands few other corner cases for macro plugins:

* Make sure the plugin options in the swift module is prefix mapped.
* Make sure the remarks of the macro loading is not cached, as the
  mesasge includes the absolute path of the plugin, and is not
  cacheable.

rdar://148465899
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan merged commit 2dd49f5 into swiftlang:main Apr 10, 2025
3 checks passed
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