purescript/trypurescript

Support loading/unloading of externs as needed on the server.

natefaubion opened this issue ยท 7 comments

In order to support opening up to the wider ecosystem, we need to support someway to load and unload externs on the compilation server. We can't keep the whole set in memory at once (at least not without a much larger budget!).

Being able to support Halogen and React Basic in Try PureScript would be a big win, and because they depend on large parts of the ecosystem they seem like good test cases to ensure this is working well.

We do also have the budget to increase memory on the machine at least a little more than it has now.

paf31 commented

When would you unload them? Presumably not between requests?

Maybe we should look at all the options for opening up to more libraries. This is mostly coming from this comment.

  • The current package set as-is requires a little over 2GB to keep everything in memory. One option is to just add more memory for now. This may grow or may not. We can certainly punt with this as it's definitely the easiest option. I honestly don't know what the constraints are for the box it's running on.
  • We can load externs from disk on every request. I don't think this is feasible with 0.13 and the JSON format. It's quite slow and CPU intensive, but maybe with 0.14 and the binary format it would be acceptable.
  • We could whitelist common (core) modules and keep them in memory if the above is too slow in general, or requires too much CPU.
  • We can potentially do a simple time based FIFO cache.
  • We can potentially use some of size heuristic for caching and purging.
  • We can potentially do something more exotic like memory mapping. I don't know what this would require.

A DigitalOcean droplet with 4GB of memory is about $20/month, which is also roughly the same amount available via the Open Collective. Try PureScript isn't the only thing running on our infrastructure, but other community resources are fairly static.

Right now Try PS is running on a $5/mo DO droplet with 1GB of memory. I think putting it on a $20/mo droplet is feasible, we'd only have to receive a little bit more in donations. We should confirm with @chexxor though because AFAIK we can't currently pay DO directly from OpenCollective, so his card gets billed first and then he gets reimbursed.

According to OpenCollective we currently have a $50/month budget. That may fluctuate as more or fewer people contribute, but it leaves plenty of room for a $20/month droplet right now.

I've just resized the Try PS droplet so that it now has 4GB memory ๐Ÿ™‚