question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build time peak on every 4th iteration

See original GitHub issue

I observe strange behavior because on every 4th clean build iteration I receive 10-30% build time peak. It occurs only on long time builds for at least 3 mins. image

I run this benchmark via:

gradle-profiler --benchmark --scenario-file build-time_clean-change.scen

with this scenario:

clean_build_change {
    title = "Clean Build with changes Xmx12g"
    tasks = [":app:buildDebug"]
    gradle-args = ["--parallel"]
    cleanup-tasks = ["clean"]
    jvm-args = ["-Xmx12g"]
	
    warm-ups = 4
    iterations = 10
	
    apply-abi-change-to = "app/src/main/java/com/awesome/app/MainActivity.kt"
    apply-android-resource-change-to = "app/src/main/res/values/strings.xml"
}

Tested on hardware: i7-8550U, 256 GB SSD (Toshiba 2280), 16 GB DDR4

I tried to use different -Xmx parameter but without any significant changes. Did you have any other suggestions?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jonnycaleycommented, Feb 15, 2022

Hey, yeh in hindsight I should have done that in the first place as my comment wasn’t very helpful, my bad 🤦

I managed to figure out it was due to the remote build caches being enabled, and for whatever reason these increase builds were taking longer than usual to upload to the remote cache.

Normal build Longer build
Screenshot 2022-02-15 at 14 03 27 copy Screenshot 2022-02-15 at 14 03 31 copy

I cannot say this is the reason for the original author of this issue but what I will suggest trying is the same steps I took to work it out:

  1. Enable gradle scans for the benchmarks by adding gradle-args = ["--scan"] to each scenario
  2. Add this to root project build.gradle to accept the terms and conditions automatically
  3. Run the benchmarks and once they are complete find out which one has a spike (in my case above it was measurement 8)
  4. Go to the generated profile.log file search for Publishing build scan... until you find the one associated with the anomaly build
  5. Use the link to open the build scan and try to work it out from the build timeline. I also found opening another scan of a build that took an expected amount of time to compare the differences and help narrow it down
1reaction
asodjacommented, Feb 4, 2022

My first guess would be that gc kicks in, so there is a gc pause. And then JVM increases the heap size and it’s better on the next runs. I would suggest you also set -Xms (initial heap size), since -Xmx is just the maximum heap that process can use and JVM starts with much less at the beginning (I don’t know from my head what is the default value for the -Xms).

You can also try to use --measure-gc for gradle-profiler so you can see some gc benchmarks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to go about doing something every fourth loop as well as ...
I can add a condition to make things happen every two loops, but how do I create a condition for every fourth loop?...
Read more >
every 4th iteration is very slow #5328 - iperov/DeepFaceLab
Actual behavior. ****Every 4th iteration/epoch gets stuck for some time. i have narrowed it down to the fact that , the bigger (...
Read more >
Data loader takes a lot of time for every nth iteration
Apparently it takes each worker more than 20 seconds to pull 128 samples from the server, while each training step is much faster....
Read more >
Iterations - Scaled Agile Framework
Iterations are the basic building block of Agile development. Each iteration is a standard, fixed-length timebox, where Agile Teams deliver ...
Read more >
Iterations - GitLab Docs
Iterations are a way to track issues over a period of time. ... You can use them to automate creating iterations every 1,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found