ultra-runner icon indicating copy to clipboard operation
ultra-runner copied to clipboard

Idea: more efficient build strategy

Open lxgreen opened this issue 3 years ago • 2 comments

Hey ultra people,

Thanks for this cool piece of code!

I'd like to share an idea. As far as I understand, currently ultra cache relies on git file hash for change detection in files, and timestamps for change detection in directories. I can see, the cache does not include the build artifact caches (e.g. in my project, the cache contains an entry for dist directory, but not for its contents).

What if the cache would contain entries for build artifacts as well, while their hashes are affected by the contents (e.g. md5 checksum)? This would provide actual change detection. Say, I've just changed a typescript annotation or a comment in package A. This change triggers package A rebuild. After the package is rebuilt, we compare bundle checksums vs cached ones. Since the change is dev-time only, it doesn't affect the bundle contents, so the rebuild can stop here and the dependent packages don't have to be rebuilt.

WDYT?

lxgreen avatar Apr 02 '21 22:04 lxgreen

I thought about something like that when I implemented ultra, but having to calculate checksums for all build artifacts might slow-down the builds quite a bit.

Triggering a rebuild on mtime changes of those directories should work for most cases and only sometimes do a build that night not have been needed.

folke avatar Apr 07 '21 10:04 folke

Agree on that, in general. Hopefully, I'll find time to make POC to see the checksum calculation impact. This calculation supposed to run after the build is complete, so if it could run somehow in the background in non-blocking manner... 🤔

lxgreen avatar Apr 07 '21 14:04 lxgreen