Closed nerder closed 3 years ago
Did it give you more info under the waiting on:
line? It should list the longest running actions.
Hey @jakemac53 thank you for the fast reply:
This is the complete one
[INFO] Watch:Starting Build
[INFO] Build:Updating asset graph...
[INFO] Build:Updating asset graph completed, took 5ms
[INFO] Build:Running build...
[WARNING] freezed:freezed on test/blocs/user_bloc_test.dart:
Your current `analyzer` version may not fully support your current SDK version.
Please try upgrading to the latest `analyzer` by running `flutter packages upgrade`.
Analyzer language version: 2.10.0
SDK language version: 2.12.0
If you are getting this message and have the latest analyzer please file
an issue at https://github.com/dart-lang/sdk/issues/new with the title
"No published analyzer available for language version 2.12.0".
Please search the issue tracker first and thumbs up and/or subscribe to
existing issues if present to avoid duplicates.
[INFO] Heartbeat:1.7s elapsed, 0/16 actions completed.
[INFO] Heartbeat:2.9s elapsed, 0/16 actions completed.
[INFO] Heartbeat:4.0s elapsed, 0/16 actions completed.
[INFO] Heartbeat:6.2s elapsed, 0/16 actions completed.
[INFO] Heartbeat:7.3s elapsed, 0/16 actions completed.
[INFO] Heartbeat:8.4s elapsed, 0/16 actions completed.
[INFO] Heartbeat:10.0s elapsed, 0/16 actions completed.
[INFO] Heartbeat:11.0s elapsed, 0/16 actions completed.
[INFO] Heartbeat:12.9s elapsed, 0/16 actions completed.
[INFO] Heartbeat:13.9s elapsed, 0/16 actions completed.
[INFO] Heartbeat:15.0s elapsed, 0/16 actions completed.
[WARNING] Heartbeat:
No actions completed for 15.0s, waiting on:
- freezed:freezed on test/blocs/user_bloc_test.dart
- freezed:freezed on test/blocs/lessons_bloc_test.dart
- freezed:freezed on test/blocs/registry_bloc_test.dart
- freezed:freezed on test/blocs/auth_bloc_test.dart
- freezed:freezed on test/blocs/account_bloc_test.dart
.. and 11 more
[INFO] Heartbeat:16.4s elapsed, 0/16 actions completed.
[INFO] Heartbeat:17.9s elapsed, 0/16 actions completed.
[INFO] Heartbeat:19.0s elapsed, 0/16 actions completed.
[INFO] Heartbeat:20.0s elapsed, 0/16 actions completed.
[INFO] Heartbeat:21.0s elapsed, 0/16 actions completed.
[INFO] Heartbeat:25.2s elapsed, 0/16 actions completed.
[INFO] Heartbeat:26.2s elapsed, 0/16 actions completed.
[FINE] freezed:freezed on test/blocs/user_bloc_test.dart:Running FreezedGenerator
... other [FINE] ...
Ok, so this could be a problem with the freezed
generator itself, or if your app is very large it could just be taking a while to resolve these tests (especially if they have a ton of transitive imports).
What I would recommend trying is targetting the freezed
generator to the files you actually need it to run on, something like this, in a build.yaml
file at the root of your package:
targets:
$default:
builders:
freezed:freezed:
generate_for:
- lib/models/*.dart
- lib/other_models/*.dart
That will be a lot more efficient.
That's interesting, while after a complete clean
and build
i'm not seeing much of an improvement (maybe ~8s or so)
Now i got this issue:
[SEVERE] freezed:freezed on test/freezed/test_gym.dart:
Cycle loading state error
#0 LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:177:32)
#1 SetMixin.forEach (dart:collection/set.dart:142:30)
#2 LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:117:32)
#3 SetMixin.forEach (dart:collection/set.dart:142:30)
#4 LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:117:32)
#5 SetMixin.forEach (dart:collection/set.dart:142:30)
#6 LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:117:32)
#7 SetMixin.forEach (dart:collection/set.dart:142:30)
#8 LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:117:32)
#9 LibraryContext.load2.<anonymous closure> (package:analyzer/src/dart/analysis/library_context.dart:250:17)
#10 PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#11 LibraryContext.load2 (package:analyzer/src/dart/analysis/library_context.dart:248:12)
#12 AnalysisDriver._createLibraryContext.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1504:25)
#13 _rootRun (dart:async/zone.dart:1190:13)
#14 _CustomZone.run (dart:async/zone.dart:1093:19)
#15 _runZoned (dart:async/zone.dart:1630:10)
#16 runZoned (dart:async/zone.dart:1550:10)
#17 NullSafetyUnderstandingFlag.enableNullSafetyTypes (package:analyzer/dart/element/null_safety_understanding_flag.dart:42:12)
#18 AnalysisDriver._createLibraryContext (package:analyzer/src/dart/analysis/driver.dart:1490:33)
#19 AnalysisDriver._computeUnitElement.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1420:28)
#20 PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#21 AnalysisDriver._computeUnitElement (package:analyzer/src/dart/analysis/driver.dart:1418:20)
#22 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1006:34)
#23 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:1967:24)
<asynchronous suspension>
The build.yml
is actually the only file i've changed
It seems i was able to solve the issue by upgrading my dependencies:
build_runner: ^1.10.6
json_serializable: ^3.5.0
freezed: ^0.12.3
And using the proposed solution of generate_for
i was able to reduce the initial build to ~35s from ~50s and the watch
to around ~4s
Still I'm a bit worried on how fast this will degrade as soon as the code base grow up 🤔
The initial build includes a lot of extra overhead (we are optimizing for incremental builds generally). It has to create a summary of your Dart sdk, snapshot the build script itself, and other startup tasks which take a fair bit of time. But those are one time fixed costs for the initial build.
Note however that you could target the json_serializable
builder in the same way as freezed
, and that would likely also get you a bit more speedup.
Thank you so much for this. I don't think there is anymore action for this issue.
Hopefully the performance of the code generation will improve overtime 🙏
Hello folks,
I was wondering why is build_runner Idling for so long, it take something around
45s
to complete something around 370 actions, which i find quite odd as this makes the code generation not really usable on scale.What I'm seeing if i run using
--verbose
is this:And this:
For up to
20s
out of45s
which basically seems to me that the runner is idling for something like the 50% of the total execution.Is this the expected behavior or it will be possible for me to improve it in any way?
Dart SDK version: 2.12.0-29.10.beta (beta) (Tue Nov 17 10:50:22 2020 +0100) on "macos_x64"
build_runner 1.10.2
0.12.3
3.3.0
MacOS 10.15.7 (Catalina)