Speeding up DCD in big projects

Steven Schveighoffer schveiguy at gmail.com
Tue Jul 21 17:12:04 UTC 2020


On 7/21/20 1:02 PM, H. S. Teoh wrote:
> On Tue, Jul 21, 2020 at 04:46:23PM +0000, Bruce Carneal via Digitalmars-d wrote:
>> On Tuesday, 21 July 2020 at 12:53:10 UTC, WebFreak001 wrote:
>>> Essential to this were `nothrow` overloads of isFile/isDir in
>>> std.file, which I now manually implemented. Having functions for
>>> those in phobos would be awesome and clearly would offer huge
>>> performance improvements.
>>
>> Was the change to nothrow the only alteration?  I ask because I
>> thought that a move to nothrow only wins big if it enables inlining
>> within a hot loop.
>>
>> Perhaps your manual implementation wins in other ways?
> [...]
> 
> I'm skeptical of "huge performance improvements" with nothrow in
> anything that involves disk I/O.  An I/O roundtrip far outweighs
> whatever meager savings you may have won with nothrow.  I have a hard
> time conceiving of a situation where nothrow would confer significant
> performance improvements to isFile/isDir.  IMO you'd get much better
> savings by reducing the number of I/O roundtrips instead.

If you look at the change, it's not the nothrow optimization that Walter 
always talks about (where code that is marked nothrow performs slightly 
better than code that isn't marked nothrow but doesn't end up throwing), 
it's that the COMMON CASE was that an exception is thrown and caught, 
and then bool is returned. Instead, just return the bool.

Also, just because it involves file info, doesn't mean it's doing disk 
i/o for every call.

-Steve


More information about the Digitalmars-d mailing list