Date: Sun, 01 Sep 2024 15:26:22 -0700
On Sunday 1 September 2024 13:08:51 GMT-7 Andrey Semashev via Std-Proposals
wrote:
> > The MS STL implementation uses GetFileInformationByHandleEx(), so it can
> > compare the 128-bit unique identifier. The libstdc++v3 and libcxx
> > implementations use GetFileInformationByHandle(), so they suffer from the
> > same problem as Coverity did.
>
> They don't, as long as they keep both files open while obtaining and
> comparing file ids. Which std::filesystem::equivalent is able to do,
> unlike Coverity or a C++ compiler, as that would substantially increase
> system resource consumption during compilation.
Ah right. fs::equivalent compares whether two files (which must be openable)
are the same. Which in turn means it's unlikely to be what gets used to
implement the functionality in the compiler, because opening every previously-
used file to compare it to the one you're about to open is too expensive: O(n²)
to the number of distinct file paths. Especially on Windows, where opening files
is slow all by itself, and only gets worse with networked filesystems.
The solution needs to be O(n).
wrote:
> > The MS STL implementation uses GetFileInformationByHandleEx(), so it can
> > compare the 128-bit unique identifier. The libstdc++v3 and libcxx
> > implementations use GetFileInformationByHandle(), so they suffer from the
> > same problem as Coverity did.
>
> They don't, as long as they keep both files open while obtaining and
> comparing file ids. Which std::filesystem::equivalent is able to do,
> unlike Coverity or a C++ compiler, as that would substantially increase
> system resource consumption during compilation.
Ah right. fs::equivalent compares whether two files (which must be openable)
are the same. Which in turn means it's unlikely to be what gets used to
implement the functionality in the compiler, because opening every previously-
used file to compare it to the one you're about to open is too expensive: O(n²)
to the number of distinct file paths. Especially on Windows, where opening files
is slow all by itself, and only gets worse with networked filesystems.
The solution needs to be O(n).
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel DCAI Platform & System Engineering
Received on 2024-09-01 22:26:24