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

Gradle build is slow again #1874

Open
petervdonovan opened this issue Jun 28, 2023 · 4 comments
Open

Gradle build is slow again #1874

petervdonovan opened this issue Jun 28, 2023 · 4 comments
Labels
build system gradle Issues regarding Gradle build configuration

Comments

@petervdonovan
Copy link
Collaborator

petervdonovan commented Jun 28, 2023

In recent days (I am not sure when) I started finding cli:lfc:run taking 45 seconds to a minute. IIRC this was fairly fast after #1779 was merged. I ran the task with the --scan flag and found this:
image

The following is strange because I do not see how this triggers the spotlessLinguaFranca task, and because when I ran cli:lfc:run with the --dry-run option, I did not see any Spotless tasks.
image

The following is strange because I did not edit any Kotlin files:
image

Configuration and Kotlin compilation appear to account for the most the time spent in this case, and much more time is spent in configuration than in anything else.

@petervdonovan petervdonovan added build system gradle Issues regarding Gradle build configuration labels Jun 28, 2023
@cmnrd
Copy link
Collaborator

cmnrd commented Jun 29, 2023

There might still be some problems in the gradle configurations. Something I still do not fully understand is when gradle actually evaluates tasks. I am also not sure what "created during configuration" means. As war as I understand, gradle always executes the full configuration, collects all tasks and configures them, but does not execute the tasks themselves. Thus, I would assume that "created during configuration" just means the task was discovered and configured, but not executed. What is still mysterious to me, is which parts of a task are actually processed during configuration and which later during execution. Interpreting the numbers you show, it looks like some task(s) have quite a high overhead during configuration.

We can try two things:

  • Identify the task(s) that cause a long configuration time and try to fix them.
  • Avoid the task configuration in the first place. Gradle provides a bunch of mechanisms for defining and referencing tasks without configuring them. Tasks are only configured when they are actually loaded (see https://docs.gradle.org/current/userguide/task_configuration_avoidance.html). We don't do this consequently at the moment.

I think the ideal solution would be to do both.

@petervdonovan
Copy link
Collaborator Author

Update: I just now realized that part of the reason why "configuring" took so long is that I had a very large number of untracked files in various src-gen and fed-gen directories. This might help us figure out what the problem is, and in any case it leads to an easy workaround (delete any files that are not needed).

@cmnrd
Copy link
Collaborator

cmnrd commented Jul 28, 2023

Interesting, except for the src-gen directory produced by xtext, we explicitly ignore all src-gen and fed-gen directories. But perhaps this ignoring is what makes Gradle slow. We have this in build.gradle:

spotless {
    format 'misc', {
        target rootProject.fileTree(rootProject.rootDir) {
            include '**/*.gradle', '**/*.md', '.gitignore', '**/*.yml', '**/*.sh', '**/*.psi'
            exclude '**/reactor-cpp/**', '**/reactor-c/**', '**/reactor-rs/**', '**/lf-python-support/**',
                    '**/src-gen/**', '**/fed-gen/**', '**/test-gen/**', '**/build/**',
                    'test/*/include', 'test/*/bin/', 'test/*/share', 'test/*/lib'
        }

        // define the steps to apply to those files
        trimTrailingWhitespace()
        indentWithSpaces(2) // or spaces. Takes an integer argument if you don't like 4
        endWithNewline()
    }

    format 'linguaFranca', {
        addStep(LfFormatStep.create())
        target 'test/*/src/**/*.lf' // you have to set the target manually
        targetExclude 'test/**/failing/**'
    }
}

Perhaps the required pattern matching on a large file tree is what slows gradle down.

@lhstrh
Copy link
Member

lhstrh commented Jul 28, 2023

Seems like we could easily remove a bunch of globstars and substitute them with relative paths...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system gradle Issues regarding Gradle build configuration
Projects
None yet
Development

No branches or pull requests

3 participants