Re: A micro-optimisation for walkdir()

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A micro-optimisation for walkdir()
Date: 2020-09-03 05:08:48
Message-ID: CA+hUKGLwi2m7cnsYE=g+f99TAgLtWvq1eTpPVJWHHJFxVNxkGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 3, 2020 at 3:52 AM Juan José Santamaría Flecha
<juanjo(dot)santamaria(at)gmail(dot)com> wrote:
> On Wed, Sep 2, 2020 at 4:35 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
>> > You don't need to call stat() just to find out if a dirent is a file
>> > or directory, most of the time. Please see attached.
>>
>> Hm. If we do this, I can see wanting to apply the knowledge in more
>> places than walkdir().

Good idea. Here's a new version that defines a new function
get_dirent_type() in src/common/file_utils_febe.c and uses it for both
frontend and backend walkdir().

> Win32 could also benefit from this micro-optimisation if we expanded the dirent port to include d_type. Please find attached a patch that does so.

Is GetFileAttributes() actually faster than stat()? Oh, I see that
our pgwin32_safestat() makes extra system calls. Huh. Ok then.
Thanks!

Attachment Content-Type Size
v2-0001-Skip-unnecessary-stat-calls-in-walkdir.patch text/x-patch 8.5 KB
v2-0002-Add-d_type-to-Win32-dirent-port.patch text/x-patch 2.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey V. Lepikhov 2020-09-03 05:14:41 Re: Ideas about a better API for postgres_fdw remote estimates
Previous Message Peter Eisentraut 2020-09-03 04:57:47 Re: Fix for configure error in 9.5/9.6 on macOS 11.0 Big Sur