Skip to content
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

Find a pattern to avoid the cost of reformatting identical Dart code #3786

Open
natebosch opened this issue Dec 18, 2024 · 2 comments
Open
Labels
P3 A lower priority bug or feature request type-performance

Comments

@natebosch
Copy link
Member

Most codegen uses the formatter to create a consistent and readable output. The formatting always happens in the same builder as the code generation. This means that even when a builder produces identical output it pays the cost to reformat.

If it was more common to have a build_to: cache intermediate asset with the unformatted Dart code and formatted it in a separate build step then we would often short circuit the formatting steps.

Or maybe we could look at something like a way to record a hash of the "meaningful" input from read assets or a fingerprint of preformatted generated code. This would be a bit like baking in the pattern we've used in some code generators where we first read information into a JSON asset which can short circuit any builders that use it as input, then a separate build step reads the JSON asset to produce formatted code.

@natebosch natebosch added P3 A lower priority bug or feature request type-performance labels Dec 18, 2024
@jakemac53
Copy link
Contributor

Formatting as a separate step could definitely be interesting....

@jakemac53
Copy link
Contributor

One problem (or feature) with formatting separately is that depending how it is done it can affect the visibility of the files to other builders.

We could have a global builder that just formats files, after all codegen is done, which would mean no builder that opts into that can see the outputs of any other builder.

Or we could go the other way and say each builder should set up its own formatting builder, which only formats its own output. That could run immediately after it runs, so its output is available to other builders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request type-performance
Projects
None yet
Development

No branches or pull requests

2 participants