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

Figure out a way to avoid recompiling the predefs all the time #542

lihaoyi opened this issue Jan 4, 2017 · 0 comments

Figure out a way to avoid recompiling the predefs all the time #542

lihaoyi opened this issue Jan 4, 2017 · 0 comments


Copy link

@lihaoyi lihaoyi commented Jan 4, 2017

Right now, if you use Ammonite in an existing SBT project with a constantly changing classpath (e.g. because you're editing it), you find it constantly recompiling all the predef files whenever it starts:

Welcome to the Ammonite Repl 0.8.1
(Scala 2.12.0 Java 1.8.0_112)

This is because Ammonite uses the hash of the existing classpath to decide whether things need to be recompiled (in case some definition changes in a binary incompatible way).

However, many of the predefs never depend on user code (,, and really only need to be compiled only once per version of Ammonite. Others (,,, are often empty, and thus can also be skipped entirely when they don't contain any code.

When using Ammonite standalone, the caching it good enough to compile these things only once (since the starting classpath of the standalone executable doesn't change much) but we really should make this better to speed up the start time of using Ammonite as part of an existing project.

@lihaoyi lihaoyi closed this in 5ad6ad1 May 12, 2017
jhnsmth added a commit to jhnsmth/Ammonite that referenced this issue May 21, 2017
- Fix `initialClasspathSignature`:

  - Un-break `skipSuspicious`, whose boolean was flipped and was skipping
    entirely the wrong folders when traversing classpath folders

  - Start stat-ing `.jar` files on the class path, since there typically
    aren't that many so we might as well

- Convert the predef definition information from a tuple into a `PredefInfo`
  object, which has a `hardcoded: Boolean` field

- `PredefInfo`s with `hardcoded=true` means that predef doesn't need to be
  recomputed if the underlying classpath changes. Those are only depended
  on Ammonite version, and are guaranteed not to depend on third party libs
  or user code.

- Fast-path empty string (`""`) predefs to avoid compiling/loading them at all

- Break up `predef` into `defaultPredef` and `commandLinePredef`, where
  `defaultPredef` has `hardcoded=true` and `commandLinePredef` is usually
  empty, generally avoiding recompiling both
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.