Speeding up importing Phobos files

Steven Schveighoffer schveiguy at gmail.com
Mon Jun 10 20:53:37 UTC 2019


On 6/8/19 3:12 AM, Andrei Alexandrescu wrote:
> On 1/21/19 2:35 PM, Neia Neutuladh wrote:
>> On Mon, 21 Jan 2019 19:10:11 +0000, Vladimir Panteleev wrote:
>>> On Monday, 21 January 2019 at 19:01:57 UTC, Steven Schveighoffer wrote:
>>>> I still find it difficult to believe that calling exists x4 is a huge
>>>> culprit. But certainly, caching a directory structure is going to be
>>>> more efficient than reading it every time.
>>>
>>> For large directories, opendir+readdir, especially with stat, is much
>>> slower than open/access.
>>
>> We can avoid stat() except with symbolic links.
>>
>> Opendir + readdir for my example would be about 500 system calls, so it
>> breaks even with `import std.stdio;` assuming the cost per call is
>> identical and we're reading eagerly. Testing shows that this is the case.
> 
> Another simple test:
> 
> import std.experimental.all;
> void main(){}
> 
> Use "time -c test.d". On my SSD laptop that takes 0.55 seconds. Without 
> the import, it takes 0.02 seconds. In an ideal world there should be no 
> difference. Those 0.53 seconds are the upper bound of the gains to be 
> made by first-order improvements to import mechanics. (IMHO: low impact 
> yet not negligible.)


Might it be due to something like this?

https://issues.dlang.org/show_bug.cgi?id=19874

-Steve


More information about the Digitalmars-d mailing list