leahneukirchen / redo-c

An implementation of the redo build system in portable C with zero dependencies
105 stars 12 forks source link

check_deps(): changing tests order for '=' #20

Closed AndreyDobrovolskyOdessa closed 1 year ago

AndreyDobrovolskyOdessa commented 3 years ago

For big files getting hash may appear to be time-consuming. Calling check_deps() before hash calculation of dependency file may save some time in case rebuild is triggered by the changes in the small dependency file of big target.

AndreyDobrovolskyOdessa commented 3 years ago

Hi, Leah! This patch may give small performance gain. Let me explain by an example.

We have simple dependency chain: a -> b -> c -> d.

If file d is not updated, check_deps() will calculate,b,c,d hashes and test b,c dependencies. If file d is updated and changed, then check_deps() will calculate b,c,d hashes and test b,c dependencies.

After applying this patch:

If file d is not updated, check_deps() will test b,c dependencies and calculate,b,c,d hashes - just the same as above. If file d is updated and changed, then check_deps() will test b,c dependencies and will not calculate b,c hashes.

Hashes are fast, but if changes reside deep inside dependency tree, calculating hashes appears to be just an environment heating :)