Pauan/rollup-plugin-purs

Long runtime on large-ish project, even with all optimizations switched off

jazmit opened this issue · 6 comments

Running on our medium-sized project (10k LOC of purescript app code + 30k LOC purescript library code, 2.5Mb after pulp browserify -O), the runtime is more than an hour, even with all optimizations turned off.

The list of warnings is printed relatively quickly, then rollup hangs for over an hour on my laptop before printing the optimization stats and exiting.

I'm sorry I haven't had time to dig further into this, as we're sticking with pulp for now, but I'd thought I'd create this issue to let others know and get some discussion going.

I'm running NixOS, and installed rollup globally in my user profile. We're using the following rollup.config:

import purs from "rollup-plugin-purs";

export default {
  entry: "src/Main.purs",
  format: "iife",
  sourceMap: true,
  moduleName: "PS",
  plugins: [
    purs({
      runMain: false,
      optimizations: {
        uncurry: false,         // Whether to apply the uncurrying optimization or not
        inline: false,          // Whether to inline some functions or not
        removeDeadCode: false,  // Whether to remove dead code or not
        assumePureVars: false   // Whether to assume that variable assignment is always pure
      }
    })
  ]
};
Pauan commented

Yes, I've noticed this as well. I'm not sure what the problem is, but I suspect it has to do with Rollup itself.

Hey, I really wanted to use this plugin but had the same issue. After some digging and experimentation, I found that the major slowdown is in the replace.js transformation.

The rest is quite fast, apart from transform-es2015-block-scoping which is slowish, but on my small-medium project at around 10 secs it's not really a problem for a production build.

$removeIIFE raises a stack size error, which goes away when I use eg: --stack-size=2000.

Pauan commented

@FrigoEU Thanks for the information! I'll look into this and see if I can improve the performance.

I was looking into this, but couldn't figure out what the replace plugin is supposed to do? It just renames every identifier, and nothing else?

Pauan commented

@FrigoEU Yes, that's correct. Specifically it renames every identifier to be unique. This simplifies the later optimizations, since they can move around identifiers, inline functions, etc. without needing to worry about identifier conflicts.

Aha, I've been running the plugin without it because of how long it runs, and that actually caused both #20 and #24. I've made PR's for both of those, but you can reject them if you think it's better.