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

Remove Checkpoint module #29

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

Conversation

michalt
Copy link
Contributor

@michalt michalt commented Jan 24, 2016

Apparently the CheckpointingMonad wasn't actually used anywhere
in the code (there were only a few instances). In particular the
fixpoint algorithm did not use it at all.

Removing it seems like a reasonable idea (at least for now), since:

  • it's not used,
  • having it is confusing (both for developers and users),
  • re-adding it's functionality might have performance implications
    and we don't yet have any reasonable benchmarks.
    So I'd prefer to first do some cleanup of the library & work on it's
    performance (e.g., adding some benchmarks) and only once everything
    starts to look good, consider adding new functionality.

Apparently the CheckpointingMonad wasn't actually used anywhere
in the code (there were only a few instances). In particular the
fixpoint algorithm did not use it at all.

Removing it seems like a reasonable idea (at least for now), since:
- it's not used,
- having it is confusing (both for developers and users),
- re-adding it's functionality might have performance implications
  and we don't yet have any reasonable benchmarks.
So I'd prefer to first do some cleanup of the library & work on it's
performance (e.g., adding some benchmarks) and only once everything
starts to look good, consider adding new functionality.
@jstolarek
Copy link

Are we sure clients don't use it?

@michalt
Copy link
Contributor Author

michalt commented Feb 2, 2016

No I'm not sure about that (GHC doesn't seem to use it though). :-( Also, this would probably require a minor version bump.

But IMHO it still makes sense to make this change - if anyone is using this, then they probably expect the CheckpointingMonad to actually do something, but unless I'm missing something, restart or checkpoint are not used anywhere in the library. So the type signatures are actually pretty misleading here.

@mlite
Copy link
Contributor

mlite commented Feb 3, 2016

It (restart) was invoked in the initial implementation, but it was, accidentally?, removed in a Dataflow rewriting to improve performance.

Without CheckpointMonad, you still can write a correct analysis if you don't use a user-defined state Monad, which is likely true in the most cases. But the state of UniqueMonad cannot be restored in an analysis restart, this might not cause a lot of harm.

I think the benefit of CheckpointMonad could be big. It might be worth investigating this: using the original implementation, which still invokes restart, to write some analysis that need to restore states. I probably can give it a try in the following weeks.

@jstolarek
Copy link

It might be worth investigating this: using the original implementation, which still invokes restart, to write some analysis that need to restore states.

Do you think this could be related to issue #1 ?

@mlite
Copy link
Contributor

mlite commented Feb 3, 2016

Do you think this could be related to issue #1 ?

Using freshUniques from UniqueMonad to name new variables is not a good idea, as UniqueMonad is not restorable in restart.

It will be ideal if a state Monad which is also an instance of CheckpointMonad is used to name new variables.

Yes, I suspect issue #1 can be alleviated if a stateful CheckpointMonad instance supporting deterministic variable naming is used.

Edit: freshLabels -> freshUnqiues
a stateful CheckpointMonad -> a stateful CheckpointMonad instance supporting deterministic variable naming.

@spacekitteh
Copy link

I think CheckpointMonad would definitely useful! The fixpoint algorithm should definitely be fixed to use it.

@bollu
Copy link

bollu commented Nov 27, 2018

I stumbled on the fact that Checkpoint is not used today and was confused as well.

If it can be used, what is a good use-case for it? I wanted to use checkpointing to speculate on loop optimisations in an IR, but I feel that this maybe very expensive (to copy the entire IR data structure).

I've been coming at the problem from the other direction, [trying to study an algebraic theory of patches]
(https://github.com/bollu/deltas) --- since I believe that checkpointing will be too expensive space wise. I believe the correct trade-off is to perform some style of incremental computation. I'm now at the stage where I want to try and benchmark this. However, I couldn't find any examples that use Checkpoint :)

I'm hoping @michalt, @mlite , and @spacekitteh may have useful examples in mind?

Thanks!

@simonpj
Copy link

simonpj commented Nov 28, 2018

I don't know what Checkpoint is for. But I do remember that we had the idea of "fuel" for Hoopl. The idea was that you could give Hoopl a certain amount of fuel. When it runs out, it stops rewriting. If some transformation introduces a bug, you can use binary-chop on the fuel supply to nail the precise before-and-after of the buggy rewrite.

I'm not sure if this has anything to do with Checkpoint. I suggest deleting it if unused; it's not much code!

@bollu
Copy link

bollu commented Nov 28, 2018

@simonpj Indeed, fuel makes sense :) I wasn't sure what Checkpoint was doing. I presumed it was to be able to speculate on optimisations, but I couldn't find any such source.

@mlite
Copy link
Contributor

mlite commented Nov 29, 2018

The justification of Checkpoint Monad is in the original paper. Checkpoint Monad was used in the original Dataflow implementation and removed in the performance optimized Dataflow reimplementation. Checkpoint Monad can prevent infinite loop when rewriting has side-effect. It's not current used but it should be used.

@bollu
Copy link

bollu commented Dec 11, 2018

@mlite where is the performance optimised version described?

@mlite
Copy link
Contributor

mlite commented Dec 11, 2018

Please check the revision history of Dataflow.hs. The performance optimization was needed for integrating Hoopl into GHC.

@bollu
Copy link

bollu commented Feb 11, 2019

@mlite Sorry for pinging you after so long on this, but I just got the bandwidth to spelunk. Unfortunately, I am unable to find the relevant commit which mentions checkpoint. Could you tell me roughly what to grep / look for in the history to find this commit? Thanks a ton.

@bollu
Copy link

bollu commented Feb 11, 2019

@michalt, did you get around to benching Checkpoint? I'd be interested in setting up benchmarks.

@michalt
Copy link
Contributor Author

michalt commented Feb 12, 2019

@bollu No, disabling Checkpoint happened way before I did anything with Hoopl. I'm guessing this happened around the time Hoopl started to be used in GHC (it was super slow, so some things were disabled, the fixpoint algorithm copied to GHC codebase, etc.). Have a look at: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/HooplPerformance

@bollu
Copy link

bollu commented Feb 12, 2019

@michalt That's very interesting, thanks. Is that the most up-to-date information available on Hoopl? (Is it still very expensive, for example?)

@mlite
Copy link
Contributor

mlite commented Feb 13, 2019 via email

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.

None yet

6 participants