Closed balrok closed 1 week ago
hi! sure, feel free to make a PR with those improvements.
Just found there is also a related issue: #182 (just referencing it in case somebody stumbles over the other)
For the performance-problem with getting the tags I figured out a different optimization:
if the tags are stored inside .git/packed-refs, they are resolved super fast with jgit. If this file doesn't exist yet, it can be created with git gc --aggressive --prune
(warning: not sure if it can do any harm, so one might backup the .git-folder before).
Together with the overridenIsClean flag I get the scmVersion.version
-calculation down to 0.064s from initially 18s.
When following the recommended way to set the version in a gradle project:
it can take a considerable amount of time to compute it for larger projects.
How to reproduce (real project)
git clone https://github.com/spring-projects/spring-framework.git
(28k commits, 10k files) (note: this is actually not that big.)scmVersion.version
:+def start = System.currentTimeMillis(); +scmVersion.version +println("Took " + ((System.currentTimeMillis() - start) / 1000) + "s") + ext { moduleProjects = subprojects.findAll { it.name.startsWith("spring-") } javaProjects = subprojects.findAll { !it.name.startsWith("framework-") }
for i in $(seq 1 30000); do git commit --allow-empty -m"$i"; done
for i in $(seq 1 100000); do touch "$i.tmp"; done
Measurements:
Why is it important?
The current version is calculated with each execution of gradle. This means, that it also runs for each test-execution from the ide. Also my examples here don't paint the full picture: for a different project it takes 20s on my machine. Due to gradles build-directories and maybe some other random things, I have 600k files.
Proposed solutions
I think most of the time is spent in computing things, which are not always important: