Is it worth adding an init(cache => 1) option to PostgresNode, where we stash an initdb'd db in tmp_check/ and just do a simple fs copy of it ?
Even default to caching and allow an option to disable the cached copy.
We're going to need to initdb a lot in the TAP tests. We often need a clean state. Tests also get harder to debug the more you pack into a single test run and more difficult to run individually to test some specific failure. So IMO the best thing is to try to make that repeat initdb as fast as possible.
It reduces our coverage of initdb only incredibly slightly - all that repeat runs will do is help find very uncommon intermittent failures. And we rerun the buildfarm all the time so it's not like there's a shortage of initdb runs anyway.
We should also have a debug --no-fsync option for initdb, or maybe allow it to take -o options to pass to child postgres so we can pass fsync=off .