Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Module caching #211

Merged
merged 4 commits into from
Oct 30, 2019
Merged

Module caching #211

merged 4 commits into from
Oct 30, 2019

Conversation

SquidDev
Copy link
Member

@SquidDev SquidDev commented Oct 30, 2019

This implements the design as discussed in #183:

  • The driver now has a "clock", with a major and minor counter.
    • Counters are used to mark places where we expect loaded files to change. Otherwise you may have a file change between a call to getSignature and getLowered, which is terribly confusing.
    • Ticks (minor updates), allow non-emitted files to be reloaded if they have changed. This means you can reimport erroring files within the repl, and we will attempt recompilation.
    • Tocks (major updates), reloads any changed file. This is only done when using :[re]load, as you need to throw away any existing values at the same time.
  • The REPL now keeps the same driver around for the whole session, ticking and tocking it where appropriate.
  • Files are considered to have changed if their SHA256 hash has changed, or any of their dependencies have changed.

It's worth noting that the REPL is still a little slow to run after each :r, as we still need to emit and run the appropriate Lua code, which takes a bit of time. It might be possible to defer the running of non-critical Lua code, but doing so is a much harder challenge.

Edit: Actually, it's not as bad as I thought it was - just tried it outside of ghci, and the performance is fine, so it probably isn't down to Lua.

@SquidDev SquidDev requested a review from plt-amy October 30, 2019 09:35
@SquidDev SquidDev added the Yet Another Module System Issues/PRs relating to YAMS label Oct 30, 2019
Doesn't support minor updates (ticks) yet, but it's a good enough
start. In need of a lot of testing.
Most importantly, this allows us to reattempt compilation of erroring
files on each new REPL input, which makes the workflow much easier.
 - Make Driver.compile take a list of files to compile instead, and use
   that for loading files within the REPL. This prevents us from running
   the prelude twice.

 - Be more selective in what driver state we reset - make resetting
   opt-in rather than opt out. This fixes several issues with fresh name
   generation.
Note to self: don't just compile within the REPL
@SquidDev SquidDev merged commit a91b017 into master Oct 30, 2019
@SquidDev SquidDev deleted the feature/cache branch October 30, 2019 13:38
plt-amy pushed a commit that referenced this pull request Jan 12, 2020
 - The driver now has a "clock", with a major and minor counter.
   - Counters are used to mark places where we expect loaded files to
     change. Otherwise you may have a file change between a call to
     `getSignature` and `getLowered`, which is terribly confusing.
   - Ticks (minor updates), allow non-emitted files to be reloaded if
     they have changed. This means you can reimport erroring files
     within the repl, and we will attempt recompilation.
   - Tocks (major updates), reloads any changed file. This is only
     done when using `:[re]load`, as you need to throw away any existing
     values at the same time.
 - The REPL now keeps the same driver around for the whole session,
   ticking and tocking it where appropriate.
 - Files are considered to have changed if their SHA256 hash has changed,
   or any of their dependencies have changed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Yet Another Module System Issues/PRs relating to YAMS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants