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

Add optional ability to use Turbine #165

Merged
merged 14 commits into from
Jun 24, 2022
Merged

Conversation

treblereel
Copy link
Collaborator

@treblereel treblereel commented May 3, 2022

Turbine is a header compiler for Java that allows us to reduce the
source code to parse, leading to decreased compile time. By ignoring
changes in the body, we can also avoid downstream builds that can be
skipped.

This feature is optional for now, but may be set to the default in a
future release. To enable this, assign the taskMappings key of
stripped_bytecode_headers to the value turbine.

Co-authored-by: Colin Alworth colin@vertispan.com
Fixes #150

@treblereel treblereel requested a review from niloc132 May 4, 2022 02:46
@treblereel treblereel self-assigned this May 4, 2022
@treblereel treblereel added the enhancement New feature or request label May 4, 2022
@treblereel treblereel added this to the 0.20 milestone May 4, 2022
@treblereel
Copy link
Collaborator Author

i did few perf test on my mac mini m1 16gb:

i used my crysknife demo that contains elemental2-* and many gwtproject modules including heavy like gwt-widgets

with turbine:

(base) treblereel@Dmitiis-Mac-mini demo % hyperfine --runs 10 'mvn clean package'
Benchmark 1: mvn clean package
Time (mean ± σ): 97.681 s ± 1.508 s [User: 356.236 s, System: 268.646 s]
Range (min … max): 95.731 s … 100.939 s 10 runs

without :

Benchmark 1: mvn clean package
Time (mean ± σ): 103.222 s ± 0.706 s [User: 371.494 s, System: 274.101 s]
Range (min … max): 102.359 s … 104.468 s 10 runs

as @niloc132 can see, tubine is slightly faster, the main bottle neck is ADVANCED comp mode.

So i think, adding turbine makes sense only if we want to have incremental mode. The good news, turbine isn't slower.

@niloc132
Copy link
Member

niloc132 commented May 5, 2022

Excellent - I wasn't hoping for performance improvements here, but that this would instead make non-clean builds faster with only some modules changing.

@treblereel
Copy link
Collaborator Author

@niloc132 few notes:

@niloc132
Copy link
Member

niloc132 commented May 6, 2022

As long as you are only focusing on the stripped-bytecode and stripped-bytecode-headers, we don't care about APT, that is already finished. It would make sense later to follow up and work on the APT also, but that's an earlier phase of the build, and we're still using javac for that.

If this task fails, whether turbine or javac, we can safely ignore it, since APT isn't necessary (and we can't tell which dependencies are apt-only, which are actual runtime deps).

--

if jars are not optional, we can either tweak how j2cl runs to use that jar (assuming that the jar is 100% deterministic...), or we can add a "make a jar before compiling" like how you unzip afterwards. Not pretty, but it will work, and probably still worth it performance-wise.

Definitely should consider patching turbine to support just reading off the filesystem though.

dependabot bot and others added 3 commits May 28, 2022 19:29
Bumps [maven-shared-utils](https://github.com/apache/maven-shared-utils) from 3.1.0 to 3.3.3.
- [Release notes](https://github.com/apache/maven-shared-utils/releases)
- [Commits](apache/maven-shared-utils@maven-shared-utils-3.1.0...maven-shared-utils-3.3.3)

---
updated-dependencies:
- dependency-name: org.apache.maven.shared:maven-shared-utils
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@niloc132
Copy link
Member

Update from discussion in gitter: we're going to have this feature optional (but disabled by default in 0.20), and require java11 rather than add the java version check.

Starting in 0.21, the tooling will require java11, since closure compiler is also dropping java8 support. Turbine will likely be enabled by default starting in 0.21.


@Override
public Task resolve(Project project, Config config) {
int version = getJavaVersion();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@niloc132 so we keep it for now and ll remove it in 0.21, right ?

Copy link
Member

Choose a reason for hiding this comment

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

Sure - we could probably just fail now too though, your call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let simplify it for now

.setSources(ImmutableList.copyOf(sources))
.setOutput(output.toString())
.setClassPath(ImmutableList.copyOf(deps))
//TODO take a look at ReducedClasspathMode
Copy link
Member

Choose a reason for hiding this comment

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

ticket for TODO

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ticket is created

extractJar(output.toString(), resultFolder.toString());
} catch (TurbineError e) {
//ohhhh apt is in maven reactor
System.out.println(e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

use the logger in the context, or just drop the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -44,4 +48,12 @@ public Scope getScope() {
public void setScope(Scope scope) {
this.scope = scope;
}

public File getJar() {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be unused now, read but never written - can we revert this?

};
}

public void extractJar(String zipFilePath, String extractDirectory) {
Copy link
Member

Choose a reason for hiding this comment

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

Take a quick look at 22319e6? I used that zip unpacking code originally to deal with j2cl tools that didnt know how to use the filesystem directly. That would let us drop the new commons-compress dependency.

pom.xml Outdated
@@ -105,6 +105,7 @@
<error.prone.annotations.version>2.1.3</error.prone.annotations.version>
<jsr305.version>3.0.2</jsr305.version>
<commons.lang3.version>3.8.1</commons.lang3.version>
<google.turbine.version>v20220503-SNAPSHOT</google.turbine.version>
Copy link
Member

Choose a reason for hiding this comment

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

I'll finish this release so you can skip SNAPSHOT here, since it looks like we're solid, just some future plans to stop requiring a zip right?

treblereel and others added 5 commits June 23, 2022 10:28
…y.java

Co-authored-by: Colin Alworth <colin@vertispan.com>
…bineTask.java

Co-authored-by: Colin Alworth <colin@vertispan.com>
…bineTask.java

Co-authored-by: Colin Alworth <colin@vertispan.com>
…bineTask.java

Co-authored-by: Colin Alworth <colin@vertispan.com>
@treblereel treblereel changed the title Turbine stub Add optional ability to use Turbine Jun 23, 2022
@niloc132 niloc132 merged commit ff6b1ae into Vertispan:main Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java bytecode ijar/turbine research work
2 participants