Reducing pg_ctl's reaction time
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@postgreSQL.org
Date: 2017-06-25T22:13:18Z
Lists: pgsql-hackers
Attachments
- less-wait-in-pg_ctl-waits.patch (text/x-diff) patch
I still have a bee in my bonnet about how slow the recovery TAP tests are, and especially about how low the CPU usage is while they run, suggesting that a lot of the wall clock time is being expended on useless sleeps. Some analysis I did today found some low-hanging fruit there: a significant part of the time is being spent in pg_ctl waiting for postmaster start/stop operations. It waits in quanta of 1 second, but the postmaster usually starts or stops in much less than that. (In these tests, most of the shutdown checkpoints have little to do, so that in many cases the postmaster stops in just a couple of msec. Startup isn't very many msec either.) The attached proposed patch adjusts pg_ctl to check every 100msec, instead of every second, for the postmaster to be done starting or stopping. This cuts the runtime of the recovery TAP tests from around 4m30s to around 3m10s on my machine, a good 30% savings. I experimented with different check frequencies but there doesn't seem to be anything to be gained by cutting the delay further (and presumably, it becomes counterproductive at some point due to pg_ctl chewing too many cycles). This change probably doesn't offer much real-world benefit, since few people start/stop their postmasters often, and shutdown checkpoints are seldom so cheap on production installations. Still, it doesn't seem like it could hurt. The original choice to use once-per-second checks was made for hardware a lot slower than what most of us use now; I do not think it's been revisited since the first implementation of pg_ctl in 1999 (cf 5b912b089). Barring objections I'd like to push this soon. regards, tom lane
Commits
-
Change pg_ctl to detect server-ready by watching status in postmaster.pid.
- f13ea95f9e47 10.0 landed
-
Reduce pg_ctl's reaction time when waiting for postmaster start/stop.
- c61559ec3a41 10.0 landed