]> Cypherpunks.ru repositories - goredo.git/blob - doc/ood.texi
Ability to rely on mtime, instead of ctime
[goredo.git] / doc / ood.texi
1 @node OOD
2 @unnumbered Out-of-date determination
3
4 The main task for build system is deciding if the target is out-of-date
5 and needs rebuilding. The single most reliable way to do that is to
6 compare file's content with previously recorded one. But that is too
7 expensive.
8
9 So direct content storage/comparison can be replaced with
10 collision-resistant hash function of enough length. @command{goredo}
11 uses @url{https://github.com/BLAKE3-team/BLAKE3, BLAKE3} with 256-bit
12 output for that purpose.
13
14 Also it stores file's size. Obviously if size differs, then file's
15 content too and there is no need to read and hash it.
16
17 But still it could be relatively expensive. So there are additional
18 possible checks that can skip need of hash checking, based on some trust
19 to the underlying filesystem and operating system behaviour, controlled
20 by @env{$REDO_INODE_TRUST} environment variable value:
21
22 @table @env
23
24 @item $REDO_INODE_TRUST=none
25 Do not trust filesystem at all, except for file's size knowledge.
26 Most reliable mode.
27
28 @item $REDO_INODE_TRUST=ctime
29 Trust @code{ctime} value of file's inode. It should change every time
30 inode is updated. If nothing is touched and @code{ctime} is the same,
31 then assume that file was not modified and we do not try to read its
32 content. Unfortunately @code{ctime} also changes if link count is
33 updated and ownership, that could give false positive decision and force
34 file's rereading.
35
36 @item $REDO_INODE_TRUST=mtime
37 Trust @code{mtime} value of file's inode. It should change every time
38 file's content is updated. But unfortunately there are
39 @url{https://apenwarr.ca/log/20181113, many reasons} it won't.
40
41 @end table
42
43 Pay attention that although @code{mtime} is considered harmful (link
44 above), and is hardly acceptable in build system like Make, because it
45 compares timestamps of two files, redo is satisfied only with the fact
46 of its changing, so badly jumping clocks are not so devastating. Modern
47 filesystem and operating systems with micro- and nano-seconds resolution
48 timestamps should be pretty good choice for @env{$REDO_INODE_TRUST=mtime}.
49 However GNU/Linux with @code{ext4} filesystem can easily have pretty big
50 granularity of 10ms.
51
52 @command{goredo} uses @env{$REDO_INODE_TRUST=ctime} by default.