Speeding up DCD in big projects

WebFreak001 d.forum at webfreak.org
Tue Jul 21 17:05:18 UTC 2020


On Tuesday, 21 July 2020 at 16:46:23 UTC, Bruce Carneal 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?

before code was like this:

try
     return isFile(file);
catch (FileException)
     return false;


now it's like this:

uint attr;
bool exists = getAttrs(file, &attr);
return exists && attrIsFile(attr);


so the useless throwing was released which was the main 
alteration. I further optimized the logic of the caller (removed 
useless array pushing, added early returns and reduced FS calls) 
but that was probably relatively small.

I only really checked in the debugger how fast the loop was 
roughly, where it was before like 40-60ms and only after the 
nothrow change it was <1ms. So the nothrow change definitely made 
most of this, considering this was pretty much hot code (called 
for every import, recursively into all D files imported + calling 
FS calls like 3 times for every import path where I had 60 import 
paths)


More information about the Digitalmars-d mailing list