Skip to content

Cache last rebuild#2083

Merged
paf31 merged 5 commits intopurescript:0.9from
kritzcreek:cache-last-rebuild
May 22, 2016
Merged

Cache last rebuild#2083
paf31 merged 5 commits intopurescript:0.9from
kritzcreek:cache-last-rebuild

Conversation

@kritzcreek
Copy link
Copy Markdown
Member

@kritzcreek kritzcreek commented May 2, 2016

Rebased on top of the 0.9 branch.

I think this is ready for review. If you can think of a way to make reviewing changes like this easier let me know. I can offer to implement the functionality in my psc-ide-emacs fork but I don't think anyone but me is using emacs?

@hdgarrood
Copy link
Copy Markdown
Contributor

I'm actually giving spacemacs another try at the moment.

@LiamGoodacre
Copy link
Copy Markdown
Member

I use spacemacs too.

@kritzcreek
Copy link
Copy Markdown
Member Author

kritzcreek commented May 2, 2016

@hdgarrood @LiamGoodacre well if you want to give it a try you can stack install the binaries from this branch and use my private layer. Using a private layer means copying it into the .emacs/private directory,

I'll document it 🔜, but for now if you swap the purescript layer for the kc-purescript layer you can open a file in a purescript project and do:

, m s Return - Start the server
, m l - Load all modules

If you now try to get completions in a module you should only be able to complete exported identifiers.

, m b - rebuild

If rebuilding succeeds and you try to get completions you should now also get suggestions for private identifiers.

P.S. rebased again

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from 6732395 to 3b3bc8b Compare May 2, 2016 18:50
@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 2, 2016

Do we know why the build fails?

@kritzcreek
Copy link
Copy Markdown
Member Author

Sorry, but I have no idea O.o

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 2, 2016

Looks like Appveyor is having trouble with Node.

@kritzcreek
Copy link
Copy Markdown
Member Author

kritzcreek commented May 2, 2016

@garyb Could you maybe run the tests for this branch on windows, that would be really nice? I don't see why this wouldn't work on windows.

@garyb
Copy link
Copy Markdown
Member

garyb commented May 2, 2016

I can do sure, I think this is just an AppVeyor glitch though. @hdgarrood can you restart it? Also, is there any way you can give us permission to do stuff with setup/restarting on there too?

@hdgarrood
Copy link
Copy Markdown
Contributor

I've restarted it. I have no idea how to give you access, though. :(

@garyb
Copy link
Copy Markdown
Member

garyb commented May 2, 2016

Hmm, it timed out again, weird. Got a lot further that time though.

@hdgarrood No problem about the AppVeyor thing, you'd think it would just work anyway, as it should be able to tell from our organisation membership the way Travis does.

@texastoland
Copy link
Copy Markdown

Maybe http://help.appveyor.com/discussions/questions/1459-mirroring-github-organization-permissions? Y'all are doing awesome code but I figured I could at least google in between configuring WebPack 😄

@garyb
Copy link
Copy Markdown
Member

garyb commented May 2, 2016

That probably deserved a "lmgtfy", I was just too lazy to check 😆. Thanks though! I need to do the same for SlamData soon.

@hdgarrood
Copy link
Copy Markdown
Contributor

Thanks @AppShipIt, I think that should do the trick. Anyone in the owners team of the purescript org should be able to restart builds now, I think.

@texastoland
Copy link
Copy Markdown

Much obliged jealous of y'all's productivity today 👏

@kritzcreek
Copy link
Copy Markdown
Member Author

Sorry but I have no idea why this fails on appveyor. I can squash and have it rebuild again but it's just guessing from my side.

@garyb
Copy link
Copy Markdown
Member

garyb commented May 4, 2016

I'll try it locally, see if there's any more info.

@garyb
Copy link
Copy Markdown
Member

garyb commented May 4, 2016

Nope, no more useful info, but it does get up to:

Language.PureScript.Ide.Imports.Integration
  Adding imports

and then hangs indefinitely... well, for at least 5 minutes before I killed it anyway, and more like 60mins on AppVeyor by the looks of it, since it's timing out there. 😢

@kritzcreek
Copy link
Copy Markdown
Member Author

Argh... Thank you for the information! I'll see if I can add in a few timeouts and see where it hangs.

@garyb
Copy link
Copy Markdown
Member

garyb commented May 4, 2016

The only other thing I can say is it doesn't appear to be using any CPU time and the memory usage is static when it gets stuck too.

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from 3b3bc8b to feb569d Compare May 5, 2016 18:55
@kritzcreek
Copy link
Copy Markdown
Member Author

Setting up a Windows environment atm. I have no idea what is going on :D

@garyb
Copy link
Copy Markdown
Member

garyb commented May 6, 2016

Doh 🙈

@kritzcreek
Copy link
Copy Markdown
Member Author

Sank enough time into this for today... this is really frustrating :D It looks like something is deadlocking, but I think that really shouldn't happen when I'm only using STM.

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from d9e01b4 to ed5fa86 Compare May 6, 2016 21:39

hidden x _ = x

exported :: forall a. a -> a
Copy link
Copy Markdown
Member Author

@kritzcreek kritzcreek May 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paf31 @garyb This is the change that fixes the hanging. Without it psc gets stuck. I can't reproduce it on the commandline though.... it only happens in compile in tests/Language.PureScript.Ide.RebuildSpec, only on Windows.

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from ed5fa86 to 34fd508 Compare May 8, 2016 21:21
@kritzcreek
Copy link
Copy Markdown
Member Author

Squashed and rebased on the newest 0.9 branch

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 14, 2016

Perhaps it is easier to just do externs generation twice then?

Edit: that does thave the downside that we need to change the Make API though.

@kritzcreek
Copy link
Copy Markdown
Member Author

kritzcreek commented May 14, 2016

I kind of talked about this with @hdgarrood and @nwolverson and they didn't like the idea that this would now allow users to access private members of their modules. I was kind of asking for this in #1620.

Writing the opened externs file to disc that is.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 14, 2016

I tend to agree, but we don't have to save the modified externs.

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from a2adead to 18723c7 Compare May 14, 2016 19:46
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 55.627% when pulling 18723c7 on kRITZCREEK:cache-last-rebuild into 46f1687 on purescript:0.9.

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from 18723c7 to 8e61d9a Compare May 15, 2016 11:46
@kritzcreek
Copy link
Copy Markdown
Member Author

rebased again and adopted Rebuild.hs to utilize #2126

@kritzcreek
Copy link
Copy Markdown
Member Author

kritzcreek commented May 15, 2016

I don't think changing the Make API to accomodate for this very narrow usecase is a good idea. I still think it's a good idea to give tools the ability to turn off the cache, because tools that only report errors (pscid, webpack-loader) and don't offer any completions shouldn't have to wait twice as long.

I image that Atom or Emacs would turn it on by default and allow the user to disable it with an option.

Once we start working on emulating ghci's :load for psci we can still look to unify the two approaches but I think it's best to defer that decision until we know what we need for psci. It's not that much code after all.

EDIT: The CI failure is some git problem on OSX

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 55.612% when pulling 8e61d9a on kRITZCREEK:cache-last-rebuild into 7f29fad on purescript:0.9.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 15, 2016

What if the secondary build were sparked on another thread in the background? That way, we can cache the result, but not hold up the UI. You'd have to be careful to avoid race conditions when updating the state of course.

@kritzcreek
Copy link
Copy Markdown
Member Author

kritzcreek commented May 15, 2016

I don't feel confident handling concurrency yet. Spinning up worker threads makes testing a lot harder and I don't want to take that complexity until we have a really good reason.

Thinking about this a bit more, I am fine with just removing the flag and always rebuilding twice, since a lot of the "rebuild" time is actually spent sorting the externs and we don't have to do that twice.

@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from 8e61d9a to 9bfa4ff Compare May 15, 2016 23:38
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 55.607% when pulling 9bfa4ff on kRITZCREEK:cache-last-rebuild into 2da4825 on purescript:0.9.

It's cached with its exports opened up, so that we can source
completions from private members when we are editing a module.

* Adds documentation to the functions inside ...Ide.State and breaks the
  functions into a pure and a stateful part to minimize time spent in
  STM

* Cleans up json instances for Command to use Applicative style where
  possible
rebuildModule inside ...Make already does that now
Now that multiple modules per file are forbidden, we can simplify the
parsing code in Rebuild a bit.
@kritzcreek kritzcreek force-pushed the cache-last-rebuild branch from 9bfa4ff to 4396720 Compare May 16, 2016 10:52
@kritzcreek
Copy link
Copy Markdown
Member Author

Rebased and merged again :)

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 55.661% when pulling 4396720 on kRITZCREEK:cache-last-rebuild into 4852b5d on purescript:0.9.

@kritzcreek
Copy link
Copy Markdown
Member Author

Is this PR going in with 0.9? It's not a breaking change so if it's too much to review until then we could easily put it into 0.9.1

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 17, 2016

I think it should, but I won't be able to review it for a couple of days.

Sent from my iPhone

On May 17, 2016, at 4:06 AM, Christoph Hegemann notifications@github.com wrote:

Is this PR going in with 0.9? It's not a breaking change so if it's too much to review until then we could easily put it into 0.9.1


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Left parseError ->
throwError . RebuildError . toJSONErrors False P.Error $ parseError
Right [m] -> pure m
Right _ -> throwError . GeneralError $ "Please define exactly one module."
Copy link
Copy Markdown
Contributor

@paf31 paf31 May 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this case can be an internalError now, since we only allow a single module per file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you're looking at an outdated diff. I did that in this PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, weird. Thanks, looks good.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 22, 2016

Looks good to me!

@paf31 paf31 merged commit 57e9201 into purescript:0.9 May 22, 2016
@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 22, 2016

Thanks @kritzcreek !

@kritzcreek kritzcreek deleted the cache-last-rebuild branch May 22, 2016 18:24
@kritzcreek
Copy link
Copy Markdown
Member Author

Cool thanks!

archaeron pushed a commit to archaeron/purescript that referenced this pull request Apr 6, 2017
* Cache the last rebuilt module inside psc-ide state

It's cached with its exports opened up, so that we can source
completions from private members when we are editing a module.

* Adds documentation to the functions inside ...Ide.State and breaks the
  functions into a pure and a stateful part to minimize time spent in
  STM

* Cleans up json instances for Command to use Applicative style where
  possible

* Don't add a default import for Prim

rebuildModule inside ...Make already does that now

* only parse a single module when rebuilding

Now that multiple modules per file are forbidden, we can simplify the
parsing code in Rebuild a bit.

* remove the cacheSuccess flag

* fix docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants