Description
This issue is mostly to document an observation that impacts testing time from some Postfix utilities introducing 2 second delays when used if /etc/postfix/main.cf has been modified within that time frame.
Background
In May 2022 a change was made for how Postfix config overrides were applied. An observation was noticed here. The original approach does not incur the observed delay.
Recently I investigated this some more to reduce a few seconds from every container spun up for CI tests. I had noticed that if the configs for that override logic weren't present, 2 seconds was shaved off. And another part of the startup scripts was adding 2 seconds as well with postalias /etc/aliases. It turns out these Postfix utilities are reading /etc/postfix/main.cf during execution.
I found pausing to let /etc/postfix/main.cf cool down would be output with -vv verbosity set when running commands. This prompted to look into the source for Postfix utilities, I found the following polling / delay logic (doze() is another utility method in the source that takes microseconds). It compares the mtime of the file to load to be less than 1 second passed or a value in the future, and waits 300ms until checking again.
Thus anytime startup modifies /etc/postfix/main.cf and tries to run one of the postfix utilities shortly after, there is a delay measured of about 1.5-2 seconds.
postconf 'max_idle = 600s' can be run with no penalty. But postconf max_idle to perform a lookup will incur that delay.
To consider
This is probably only a concern with tests where the start-up time can be compounded for common start-up logic.
- Only one test actually hit the config override path, and that has been addressed in a recent PR.
- All tests presently add a default
root postmaster alias. This hit can be worked around by modifying the mtime (stat -c %Y /path/to/file for checking this value as unix epoch timestamp) via touch -d '2 seconds ago' /path/to/file. I think that should be fine? (This also reduces the output spam from the original config override observation PR, avoids the repetition)
- Other tests or logic may need to be evaluated for similar delays incurred by this stalling behaviour (although AFAIU it's intended to ensure a file is actually ready to be read by no longer being written to). An alternative approach may be to replace the
sed + postconf calls and instead queue up the modifications to be applied.
Description
This issue is mostly to document an observation that impacts testing time from some Postfix utilities introducing 2 second delays when used if
/etc/postfix/main.cfhas been modified within that time frame.Background
In May 2022 a change was made for how Postfix config overrides were applied. An observation was noticed here. The original approach does not incur the observed delay.
Recently I investigated this some more to reduce a few seconds from every container spun up for CI tests. I had noticed that if the configs for that override logic weren't present, 2 seconds was shaved off. And another part of the startup scripts was adding 2 seconds as well with
postalias /etc/aliases. It turns out these Postfix utilities are reading/etc/postfix/main.cfduring execution.I found
pausing to let /etc/postfix/main.cf cool downwould be output with-vvverbosity set when running commands. This prompted to look into the source for Postfix utilities, I found the following polling / delay logic (doze()is another utility method in the source that takes microseconds). It compares themtimeof the file to load to be less than 1 second passed or a value in the future, and waits 300ms until checking again.Thus anytime startup modifies
/etc/postfix/main.cfand tries to run one of the postfix utilities shortly after, there is a delay measured of about 1.5-2 seconds.postconf 'max_idle = 600s'can be run with no penalty. Butpostconf max_idleto perform a lookup will incur that delay.To consider
This is probably only a concern with tests where the start-up time can be compounded for common start-up logic.
rootpostmaster alias. This hit can be worked around by modifying themtime(stat -c %Y /path/to/filefor checking this value as unix epoch timestamp) viatouch -d '2 seconds ago' /path/to/file. I think that should be fine? (This also reduces the output spam from the original config override observation PR, avoids the repetition)sed+postconfcalls and instead queue up the modifications to be applied.