Section 17.19

What makes an incremental validation boundary sound

Question

When can a previous validation result be reused after an implementation change?

Short answer

A previous validation result can be reused after an implementation change only when nothing the result depended on has changed, directly or through intermediate parts, in a way that could make the result false. Those dependencies include the code and data the check used, the tools and settings that built and ran that code, and every number the check assumed, such as a time bound. Results that the change can reach are redone; every other result is kept with a written reason. Nearness in the source tree decides nothing.

Terms in the question

Full answer

A validation result is a conditional statement. It says that a property held for this code, built with these tools and settings, run in this environment, on these inputs, with these numbers assumed rather than measured. The result remains true for the changed system exactly when every one of those conditions still holds, or has changed in a way shown not to alter the conclusion. The size of the edit is therefore not the question. The question is whether the edit reaches any condition of the result. Five steps answer it.

  1. Describe the change by its effect on contracts. For each changed part, list what a user of the part could observe differently: outputs, errors, effects on shared data, execution time §9.32, memory use, data formats and generated files. The lines edited are a poor guide. A one-line edit can raise a time bound, and a large reorganization of the code can leave every contract as it was.

  2. Write down the dependencies of each result. For every existing result, list the code it ran, the data it read, the tools and settings that produced the code it checked, the environment it ran in, and each number it assumed instead of measuring.

  3. Find every result the change can reach. Start from the changed items. Add every item that uses one of them, then every item that uses one of those, and repeat until no new item appears. The final set is the transitive closure of the change: the set that the adding rule no longer enlarges.

  4. Redo or justify each result inside that set. An affected result is either repeated or kept with an argument that covers exactly how the result uses the changed item. A functional result is usually redone by rerunning its regression tests §10.4, the tests kept to detect behavior that a change has broken. An argument can replace the rerun: a result that assumed a time of at most 2 ms stays valid if the new time is at most 1 ms, because the assumption is an upper bound and still holds.

  5. Keep every result outside the set, with its reason. Record for each kept result which dependencies were examined and why they are unchanged, so that a reviewer can check the decision.

The boundary between redone and kept results is sound when no kept result depends, directly or transitively, on a changed item. A boundary that is too wide wastes work but stays safe. A boundary that is too narrow accepts evidence about a system that no longer exists. Repeating every check is always sound; only a dependency argument justifies doing less.

Some dependencies are easy to miss.

The converse matters as much. Sharing a directory or a naming pattern with the changed part is not a dependency. A dataset measured on a component that never uses the changed part, directly or through other parts, stays valid even when it is stored next to the changed file.

When the dependencies are not known, the boundary cannot be shown sound, and the check must be repeated. Build tools such as Bazel skip a test whose declared inputs have not changed and reuse its cached result. That shortcut is correct only for a hermetic build §13.7, one in which every input is declared and nothing undeclared is read.

Worked example

A device runs two tasks on one processor under fixed-priority preemptive scheduling §6.37: whenever a task of higher priority becomes ready, it interrupts a task of lower priority. Task HH, of high priority, is released (made ready to run) every TH=5T_H = 5 ms and runs for at most CH=2C_H = 2 ms. Task LL, of low priority, is released every 20 ms and must finish within 12 ms of its release. Its own code takes at most 4 ms, and it calls a checksum §4.32 helper once. The validation record holds four results:

The helper is changed to compute the same checksum without a 1,024-byte lookup table. The change saves memory, but the worst-case execution time §9.33 of the helper, the longest time it can take, rises from 2 ms to 5 ms.

Result (a) is kept. Both versions compute the same mathematical function, which a review of the code established and differential testing §10.6 supports; differential testing runs both versions on the same inputs and compares the outputs. The unit tests of LL use the helper only through its outputs and errors, and neither changed. The record states this reason.

Result (b) assumed that the helper takes at most 2 ms, so the change reaches it. Response-time analysis computes the worst-case response time RR of LL, the longest time from its release to its finish, as the smallest solution of R=CL+⌈RTH⌉CH,R = C_L + \left\lceil \frac{R}{T_H} \right\rceil C_H, where CLC_L is the execution time of LL including the helper, and ⌈x⌉\lceil x \rceil means xx rounded up to a whole number. The term ⌈R/TH⌉\lceil R / T_H \rceil counts the releases of HH that can fall within a window of length RR. The solution is found by starting with R=CLR = C_L and recomputing until the value stops changing.

The old result is now false. The bound of the helper rose by 5−2=35 - 2 = 3 ms, yet the response time rose by 15−10=515 - 10 = 5 ms, because the longer run of LL leaves room for one more run of HH. A change can move a dependent result by more than its own size.

Result (c) is kept. Nothing has higher priority than HH, so its response time is its own execution time, 2 ms, and the helper does not appear in it. That reason holds only if HH never waits for something that LL holds. If the two tasks shared a lock and LL held it while running the helper, HH could wait for as long as LL holds the lock, which now includes up to 5 ms of helper time, and result (c) would depend on the helper too. Result (d) is kept: the measured component does not call the helper, directly or through other functions, although its data sit in the same directory as the source file of the helper.

Follow-up questions and limits

Is it enough to rerun the tests of the files that changed? No. A result about an unchanged file can depend on the changed one, as result (b) shows. Dependency follows use, not location.

Does a change that only lowers a number keep every result? Only when the result uses that number as an upper bound. The analysis above assumed only that the helper takes at most 2 ms, so a helper that takes at most 1 ms keeps result (b) as it is. Some systems do not behave that way. Ronald Graham showed in 1969 that when tasks are scheduled on several processors, shortening tasks can delay the moment at which all tasks have finished [485]. Such cases are called scheduling anomalies, and an analysis of such a system must be redone even after a speed-up.

What if the dependencies cannot be determined? Then reuse is not justified. Repeat the check, or first make the dependencies explicit, for example by making the build hermetic.

Is reuse worth arguing for every result? No. Reuse saves effort, and the effort matters for expensive results such as long measurement campaigns, timing analyses or proofs. Rerunning a fast suite of unit tests is simpler and safer than arguing that it need not run.

This answer does not cover how to extract dependencies from code automatically, or how many repeated measurements a redone timing result needs.

Fullest treatment: Incremental validation (§10.42).

Related entries: Transitive dependency (§10.43), Regression test (§10.4), Source closure (§13.6), Evidence eligibility (§13.14), Fixed-priority response-time analysis (§19.4.7), Hermetic build (§13.7), Differential testing (§10.6). Further reading: [89, 485].