Skip to content

Improve performance of multimodule build by reusing compiler objects #720

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

micossow
Copy link

Hi,

We're using the scala-maven-plugin for one of our projects having multiple maven modules with scala code.
We observed, that each invocation of scala:compile hangs the build for several seconds.
After some digging into the plugin code I found out, that it does cold start of the compiler infrastructure each time it is invoked.
I managed to rearrange some code to make it possible to share the compiler bridge jar and compiler objects via static fields.
This simple change reduces mvn clean install (without tests) execution time by ~50%.

@davidB
Copy link
Owner

davidB commented Sep 16, 2023

@micossow Thanks for the PR.

I no longer actively maintain the plugin, especially the SBT parts. @slandelle can you look at it when you'll have time?

@tgodzik
Copy link

tgodzik commented Apr 22, 2025

@davidB would you be open to moving the repo under scala or scalameta organizations? We could provide some basic maintenance there.

@tgodzik
Copy link

tgodzik commented Apr 22, 2025

Although I do see active maintenance in the repo, it might still be less of a burden for you if we moved to an organization.

There was a topic raised in https://contributors.scala-lang.org/t/scala-maven-plugin-may-need-some-care/7108

@davidB
Copy link
Owner

davidB commented Apr 22, 2025

@tgodzik,

Please open a dedicated issue to discuss (more) about the "transfer" topic.
My short answer: I'll transfer to an individual (member or not of an organization) who will be active enough; I'll not transfer to an organization's umbrella to increase its number of inactive projects.

ref: #226

compiler = ZincUtil.defaultIncrementalCompiler();
}

private static Compilers makeCompilers(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we can make use of Lazy thing from vavr to avoid

scalaVersion, compilerAndDependencies, libraryAndDependencies);

compilers = makeCompilers(scalaInstance, javaHome, compilerBridgeJar);
compiler = ZincUtil.defaultIncrementalCompiler();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix compilers with this.?

if (path.getFileName().toString().equals("classes")) {
analysisStoreFileName = "compile";

} else if (path.getFileName().toString().equals("test-classes")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract path.getFileName().toString() to a varaible

import xsbti.compile.*;

public final class SbtIncrementalCompilers {

private static File COMPILER_BRIDGE_JAR = null;
private static SbtIncrementalCompiler SBT_INCREMENTAL_COMPILER = null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better protect with vavr's Lazy or a AtomicReference to avoid concurrent update

@tgodzik
Copy link

tgodzik commented Apr 22, 2025

@tgodzik,

Please open a dedicated issue to discuss (more) about the "transfer" topic. My short answer: I'll transfer to an individual (member or not of an organization) who will be active enough; I'll not transfer to an organization's umbrella to increase its number of inactive projects.

ref: #226

That's just a proposal, I hoped it could ease some burden on you, but totally fine not to move it. I will try to help out with some reviews instead maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants