jobd/gc.sh: compute simple gc "signature" hashes
commit520902cd741f225665595a50c094893e50186cda
authorKyle J. McKay <mackyle@gmail.com>
Sun, 28 Jun 2020 23:17:30 +0000 (28 16:17 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Sun, 28 Jun 2020 23:17:30 +0000 (28 16:17 -0700)
tree1441f4635a2b3a0e153f7a0fe78803ef36fa9836
parentcbeaefb81084c6428c9ee53cab87cbbd3d34e2a2
jobd/gc.sh: compute simple gc "signature" hashes

The gc operation can be time consuming.  If there have been no ref
changes (and nothing has been expired/pruned) then there's no reason
to run an expensive gc operation when $min_gc_interval rolls around.
Instead the lastgc time simply gets updated.

With added tolerance of linked working trees, private refs, and
supplemental packs, it becomes increasingly difficult to determine
whether or not there's been a change that warrants running gc or
whether it can be safely skipped.

As a result, gc may run when it doesn't actually need to.

As a beginning of the changes to help determine when gc can safely
be skipped, compute "signature"s (i.e. hashes) of some key
information and save that away at the end of the gc operation for
use in the future to help determine whether or not gc can be skipped.

The first "signature" hash represents the primary and supplemental
packs produced by the gc operation.  When a gc check comes up, if
there are any loose objects or the existing packs do not exactly
match this signature, gc must be performed.  This is saved in
girocco.gcsig.packs.

The second "signature" represents the state of all the refs
(including HEAD's symbolic ref state) as seen by the gc operation.
When a gc check comes up, if the ref state does not match this
signature, gc must be performed.  This is saved in girocco.gcsig.refs.

Both of these hashes are cheap and easy to generate with very little
overhead -- far, far less than an actual gc operation.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/gc.sh