pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve some ancient, crufty code in bootstrap + initdb.
Date: Sat, 05 Sep 2020 20:20:11 +0000
Message-ID: <E1kEefT-000342-QG@gemulon.postgresql.org> (raw)

Improve some ancient, crufty code in bootstrap + initdb.

At some point back in the last century, somebody felt that reading
all of pg_type twice was cheaper, or at least easier, than using
repalloc() to resize the Typ[] array dynamically.  That seems like an
entirely wacko proposition, so rewrite the code to do it the other
way.  (To add insult to injury, there were two not-quite-identical
copies of said code.)

initdb.c's readfile() function had the same disease of preferring
to do double the I/O to avoid resizing its output array.  Here,
we can make things easier by using the just-invented pg_get_line()
function to handle reading individual lines without a predetermined
notion of how long they are.

On my machine, it's difficult to detect any net change in the
overall runtime of initdb from these changes; but they should
help on slower buildfarm machines (especially since a buildfarm
cycle involves a lot of initdb's these days).

My attention was drawn to these places by scan-build complaints,
but on inspection they needed a lot more work than just suppressing
dead stores :-(

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e0f05cd5ba76a75e2ce3b85ba050e48e857dca00

Modified Files
--------------
src/backend/bootstrap/bootstrap.c | 119 +++++++++++++++++++-------------------
src/bin/initdb/initdb.c           |  46 +++++----------
2 files changed, 74 insertions(+), 91 deletions(-)



Message-ID: <E1kEefT-000342-QG@gemulon.postgresql.org>
Permalink:  ../E1kEefT-000342-QG@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kEefT-000342-QG@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Improve some ancient, crufty code in bootstrap + initdb.
  In-Reply-To: <E1kEefT-000342-QG@gemulon.postgresql.org>
  References: <E1kEefT-000342-QG@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox