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

Scalable builds #3811

Open
davidmorgan opened this issue Feb 1, 2025 · 5 comments
Open

Scalable builds #3811

davidmorgan opened this issue Feb 1, 2025 · 5 comments
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-enhancement A request for a change that isn't a bug type-performance

Comments

@davidmorgan
Copy link
Contributor

The benchmark I'm adding in #3802 shows the problem pretty clearly,

json_serializable      
libraries clean/ms no changes/ms incremental/ms
1 21573 2840 4278
100 23040 2974 6327
250 28098 3285 12578
500 42940 4288 35061
750 69483 6561 67670
1000 115941 9178 119308

notice the incremental build time for 500 libraries and 1000 libraries: it increases from 35s to 119s, an increase of x3.4. For double the number of libraries the time increase should be x2 :)

The benchmark also runs for built_value, freezed and mockito, numbers on the PR, the story is pretty similar, except:

  • built_value and json_serializable are about 2x as slow as freezed on the big build, it turns out this is purely because they use shared parts, filed Faster shared parts #3803 for that sub-problem
  • mockito is about 2x as fast as freezed, I believe that is because mockito adds a part file to the test where it does not become a dep of all the other generators; conversely built_value, json_serializable and freezed all add part files in the app code, doubling the number of deps of all the generators

Apart from these multipliers the numbers are very similar, I think it does not matter much what the generators are actually doing.

@davidmorgan davidmorgan added type-enhancement A request for a change that isn't a bug type-performance P1 A high priority bug; for example, a single project is unusable or has many test failures labels Feb 1, 2025
@amrgetment

This comment has been minimized.

@davidmorgan

This comment has been minimized.

@amrgetment

This comment has been minimized.

@rrousselGit
Copy link

  • mockito is about 2x as fast as freezed, I believe that is because mockito adds a part file to the test where it does not become a dep of all the other generators; conversely built_value, json_serializable and freezed all add part files in the app code, doubling the number of deps of all the generators

Going back to this:

This could be because freezed starts by asking for the AST of the generated file.
I need the AST, and build_runner doesn't give it to me. So I have to ask for it again. And I don't think it's cached, right?

If build_runner could expose us the AST, that'd be cool. Most of my generators use it.

@davidmorgan
Copy link
Contributor Author

  • mockito is about 2x as fast as freezed, I believe that is because mockito adds a part file to the test where it does not become a dep of all the other generators; conversely built_value, json_serializable and freezed all add part files in the app code, doubling the number of deps of all the generators

Going back to this:

This could be because freezed starts by asking for the AST of the generated file. I need the AST, and build_runner doesn't give it to me. So I have to ask for it again. And I don't think it's cached, right?

If build_runner could expose us the AST, that'd be cool. Most of my generators use it.

The performance issue I'm looking at is just due to the deps graph, it's nothing to do with what the generator does. When you look at the CPU flame charts of the large benchmarks, the generator barely shows up.

Once that's solved--yes, I think there's a possibility of handling ASTs better/faster, we'd have to compare :) thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-enhancement A request for a change that isn't a bug type-performance
Projects
None yet
Development

No branches or pull requests

3 participants