While looking at some proposed patches and pondering some questions on performance, I realized I desperately needed ways to run benchmarks with different settings without needing to edit postgresql.conf and restart/reload the server each time.
Most commonly, I want to run with synchronous_commit on or off at whim. I thought of writing a patch specifically for that, but decided a more general approach would be better. The attached patch allows any arbitrary command to be executed upon the start up of each connection intended for benchmarking (as opposed to utility connections, intended for either -i or for counting the rows in in pgbench_branches and for vacuuming), and so covers the need for changing any session-changeable GUCs, plus doing other things as well.
I created doBenchMarkConnect() to segregate bench-marking connections from utility connections. At first I thought of adding the startup code to only the normal path and leaving support for -C in the wind, but decided that was just lazy.
Will add to commitfest-next.
Cheers,
Jeff