public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Thomas Munro <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: A stack allocation API
Date: Fri, 27 Feb 2026 10:35:39 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+hUKG+ixUUYOGRcuZpkk5pmJZaUQv6VCPAjdTZXFP5vA8jxcA@mail.gmail.com>
References: <CA+hUKG+ixUUYOGRcuZpkk5pmJZaUQv6VCPAjdTZXFP5vA8jxcA@mail.gmail.com>

Thomas Munro <[email protected]> writes:
> In the locale code we often use a 1KB array for copies of strings
> where we need a NUL-terminated or transcoded version to give a library
> function, with a fallback to palloc() + pfree() if we need more space
> than that, but:

Yeah, I think there are some other use-cases too.

> I also wondered if we might have a reasonable case for using alloca(),
> where available.  It's pretty much the thing we are emulating, but
> keeps the stack nice and compact without big holes to step over for
> the following call to strcoll_l() or whatever it might be.

+1 for investigating alloca().  The one disadvantage I can see
to making this coding pattern more common is that it'll result in
increased stack usage, which is not great now and will become
considerably less great in our hypothetical multithreaded future.
If we can fix it so the typical stack consumption is a good deal
less than 1KB, that worry would be alleviated.

			regards, tom lane






view thread (6+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: A stack allocation API
  In-Reply-To: <[email protected]>

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

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