Re: Question on alignment

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Antonin Houska <ah(at)cybertec(dot)at>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Question on alignment
Date: 2019-04-01 09:09:09
Message-ID: 3d168cf6-e9c1-4ded-10dc-8146dfbe6be5@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01/04/2019 11:01, Antonin Houska wrote:
> In copydir.c:copy_file() I read
>
> /* Use palloc to ensure we get a maxaligned buffer */
> buffer = palloc(COPY_BUF_SIZE);
>
> No data type wider than a single byte is used to access the data in the
> buffer, and neither read() nor write() should require any specific alignment.
> Can someone please explain why alignment matters here?

An aligned buffer can allow optimizations in the kernel, when it copies
the data. So it's not strictly required, but potentially makes the
read() and write() faster.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2019-04-01 09:21:44 Re: Question on alignment
Previous Message Dave Page 2019-04-01 09:09:05 Re: GSoC proposal for pgAdmin 4 bytea support