Re: A micro-optimisation for walkdir() - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: A micro-optimisation for walkdir()
Date
Msg-id CA+hUKGLwi2m7cnsYE=g+f99TAgLtWvq1eTpPVJWHHJFxVNxkGQ@mail.gmail.com
Whole thread Raw
In response to Re: A micro-optimisation for walkdir()  (Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>)
Responses Re: A micro-optimisation for walkdir()
List pgsql-hackers
On Thu, Sep 3, 2020 at 3:52 AM Juan José Santamaría Flecha
<juanjo.santamaria@gmail.com> wrote:
> On Wed, Sep 2, 2020 at 4:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Thomas Munro <thomas.munro@gmail.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
attacheda 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

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Fix for configure error in 9.5/9.6 on macOS 11.0 Big Sur
Next
From: "Andrey V. Lepikhov"
Date:
Subject: Re: Ideas about a better API for postgres_fdw remote estimates