Open joliss opened 9 years ago
I'm glad to move my persistent cache work from cleanup to something per rebuild. But it really should be done after the rebuild had finished and not inline/synchronous with the current rebuild.
I'm already getting to the point where my builds are getting "slow", even in the ideal, nothing-has-changed case. This is because—in projects with thousands of files—the cost of merely walking over, stat-ing, and re-symlink-ing all of the files in an input tree is becoming significant. For one plugin/filter, that cost isn't too bad (maybe ~100ms IIRC) but when you have several filters composed together, things add up. So adding more per-rebuild/per-filter cost (the persistent data dumping) worries me.
And I assume that a new "post every rebuild" hook would have the same issues as cleanup does? (And you'd similarly be less interested to add that hook? :frowning:)
ps: FYI, to help alleviate these incremental build issues with large projects, I've tried implementing other various optimizations:
Update: I haven't been using Broccoli for over a year, so please don't worry as much about my previous work/efforts.
Currently, the main use case for the
cleanup
callback is deleting temporary directories (example). With the upcoming new API, tmp dir handling will be centralized, so this will no longer be necessary.I'm wondering if we can drop
cleanup
from the API. We can still resurrect it later if necessary, thanks to the versioned (feature-flagged) API scheme.Thinking about use cases for
cleanup
, the following come to mind:cleanup
callback.cleanup
time, because it will be killed automatically by default. See child_process.spawn#detached and setpgid(2); my testing confirms that this is the case on Linux.So I think it might be OK to drop
cleanup
. Are there other use cases forcleanup
that I'm missing?[1] We don't have first-class support for persistent caches at the moment, but we might add this in the future.
The motivation for dropping
cleanup
is that I'd like to avoid having a piece of API that is essentially unused.Another reason why I'd like to get rid of
cleanup
is that handling SIGINT (Ctrl+C) is tricky. This is perhaps only a semi-related issue, but I still wanted to bring it up:The SIGINT handler causes a delay: If you hit Ctrl+C in the middle of a rebuild, the handler will only run after the current synchronous thread of execution has finished, so that there is a delay between hitting Ctrl+C and Node actually exiting. This can take several seconds; see e.g. https://github.com/ember-cli/ember-cli/issues/3324. This problem can be alleviated but not eliminated by doing
setImmediate
in various places.If we could eliminate the handler entirely, Node would terminate immediately on Ctrl+C. Of course, Broccoli would leave all its temporary files in place, so this would require that the next Broccoli instance detects that there are old tmp directories (e.g.
/tmp/broccoli.12345
, where there is no running process with PID 12345), and clean them up. I'm not sure if this is sensible, but it would be cool if we could make it work.