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

Programmable Classpath to support Pickle caching, Build Pipelining #27

Closed
wants to merge 4 commits into from

Conversation

retronym
Copy link
Owner

@retronym retronym commented Aug 13, 2018

Provide an extension point for plugins to implement classpath caching and build pipelining.

Part of scala/scala-dev#416

@jvican
Copy link

jvican commented Aug 25, 2018

You can see my implementation of this in sbt/zinc, supported in 2.11, 2.12 and 2.13: https://github.com/scalacenter/zinc/blob/topic/pipelined-parallel-compilation-rebase/internal/compiler-bridge/src/main/scala_2.12-13-only/scala/tools/nsc/ZincPicklePath.scala and https://github.com/scalacenter/zinc/blob/topic/pipelined-parallel-compilation-rebase/internal/compiler-bridge/src/main/scala_2.12-13-only/xsbt/ZincSymbolLoaders.scala (note: I don't implement symbol invalidation)

The beauty of having this implemented in Zinc instead of the Scala compiler is that Zinc is compiler agnostic. For example, I can support pipelining in Dotty as soon as the bridge supports this capability.

I like the changes in this PR but I wonder if we need this abstraction. At a higher level, all we need to implement pipelining and classpath caching is a way to communicate to the compiler which classpath entries have changed, whether they are class files in a directory or jars. If we add such an interface to the compiler, Zinc could tell the compiler directly which things need to be invalidated, and the compiler will invalidate the symbol table accordingly.

I feel this is a better approach because what changes or not is already known by the tools using the compiler (build tools, incremental compiler, IDEs/editors).

@jvican
Copy link

jvican commented Aug 25, 2018

For example, how do you feel about adding the following two compiler settings instead:

  1. -hashpath: contains a classpath-formatted list of hashes, one per classpath entry. This interface would be a generic mechanism to invalidate caches of classpath entries (no need to add different strategies to detect changes in the compiler).
  2. --invalidate-class-files: a list of class files that are present in the classpath and changed. With this information, the compiler can invalidate the symbol table entries associated with the symbols that created the class files.

@retronym retronym force-pushed the topic/pickle-jar branch 3 times, most recently from 447fbd3 to 641d2ee Compare September 21, 2018 08:27
@retronym retronym changed the base branch from 2.13.x to 2.12.x September 21, 2018 08:28
@retronym retronym force-pushed the topic/pickle-jar branch 2 times, most recently from 4b20674 to 1126fd7 Compare September 23, 2018 06:32
@retronym
Copy link
Owner Author

retronym commented Sep 25, 2018

Using https://github.com/guardian/frontend as a test case:

Traditional:

image

Pipeliining (via Outline Typing) + Parallel compilation of large sub-projects:

image

The latter has better utilization, but the throwaway work of outline typing has too high a cost in this case.

I'm about to implement the variation of build pipelining that grabs the pickles from a regular compilation run instead. (UPDATE: Done)

Pipelining (via extracting pickles from regular compilation)

image

@retronym
Copy link
Owner Author

I've moved the pattern matcher phase after pickler which should slightly improve pipelining efficiency.

Build traces for the three strategies above: https://www.dropbox.com/sh/42bzdwag94ywlpo/AACxjoumoDZh0Oolz8t0dymwa?dl=0

  • Save locally.
  • Open chrome://tracing in Chrome
  • Load the file

@retronym retronym changed the title WIP classpath plugin Programmable Classpath to support Pickle caching, Build Pipelining Oct 17, 2018
@retronym retronym force-pushed the topic/pickle-jar branch 2 times, most recently from 8b24244 to 83e6a7c Compare October 26, 2018 05:18
@retronym retronym closed this May 26, 2019
retronym pushed a commit that referenced this pull request Aug 20, 2020
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.

2 participants