Skip to content

Make things simpler and more predictable - #21

Merged
simonmar merged 1 commit into
haskell:masterfrom
treeowl:simple-and-predictable
Jun 5, 2018
Merged

simonmar merged 1 commit into
haskell:masterfrom
treeowl:simple-and-predictable

Conversation

@treeowl

@treeowl treeowl commented Jun 1, 2018 •

Copy link
Copy Markdown
Contributor
  • Eval has always been a hand-written copy of IO. Use
    a newtype wrapper around IO instead. This gives us the
    necessary instances for free and shifts the proof obligations
    into base.

  • Use unsafeDupablePerformIO instead of applying realWorld#
    directly. This should make the optimizer much less likely to
    eat our shorts.

  • Redefine rparWith to do the simplest thing that could
    possibly work. It seems to do so.

  • Remove the rewrite rule for parList; as far as I can tell,
    it slows things down.

Fixes #17
Closes #9

@treeowl
treeowl force-pushed the simple-and-predictable branch 2 times, most recently from 443ce28 to ffd0073 Compare June 1, 2018 16:29
@simonmar

simonmar commented Jun 2, 2018

Copy link
Copy Markdown
Member

Great, so was the problem that the simplifier had reordered the evaluation because realWorld# was exposed?

There are a few tests for this package, but you have to run them as part of a GHC build (unfortunately). Do they still pass?

@treeowl

treeowl commented Jun 2, 2018

Copy link
Copy Markdown
Contributor Author

Oh, I didn't run tests because I assumed Travis did. I can try to do that today.

@treeowl

treeowl commented Jun 2, 2018

Copy link
Copy Markdown
Contributor Author

And yes, I believe the realWorld# was the problem, though I never tried to find the exact transformation that scrambled things. Things are pure enough here that applying the real world manually won't give wrong values, but as soon as you care what sparks are created and forced when you're really in the IO zone.

* `Eval` has always been a hand-written copy of `IO`. Use
  a newtype wrapper around `IO` instead. This gives us the
  necessary instances for free and shifts the proof obligations
  into `base`.

* Use `unsafeDupablePerformIO` instead of applying `realWorld#`
  directly. This should make the optimizer much less likely to
  eat our shorts.

* Redefine `rparWith` to do the simplest thing that could
  possibly work. It seems to do so.

* Remove the rewrite rule for `parList`; as far as I can tell,
  it slows things down.

Fixes haskell#17
@treeowl
treeowl force-pushed the simple-and-predictable branch from ffd0073 to 9ea4c07 Compare June 2, 2018 15:08
@treeowl

treeowl commented Jun 2, 2018

Copy link
Copy Markdown
Contributor Author

Looks like the tests pass. See ghc/ghc#144 (the Hadrian failure has nothing to do with me).

@treeowl

treeowl commented Jun 2, 2018

Copy link
Copy Markdown
Contributor Author

Let me restate: the various failures in different flavors seem quite unrelated to this change and to each other.

@simonmar

simonmar commented Jun 4, 2018 •

Copy link
Copy Markdown
Member

I don't think CircleCI actually ran the tests. We don't build the parallel package by default, it has to be enabled explicitly with BUILD_EXTRA_PKGS=YES in mk/build.mk.

@treeowl

treeowl commented Jun 4, 2018

Copy link
Copy Markdown
Contributor Author

I've now run the tests locally and they pass.

@simonmar

simonmar commented Jun 5, 2018

Copy link
Copy Markdown
Member

Ok. It would be good to have more tests so that this bug doesn't return, but I'll accept the PR in the meantime.

@simonmar
simonmar merged commit c450967 into haskell:master Jun 5, 2018
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