Speeding up importing Phobos files

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jun 8 07:06:42 UTC 2019


On 1/21/19 2:46 PM, Neia Neutuladh wrote:
> On Sat, 19 Jan 2019 00:45:27 -0800, Walter Bright wrote:
>> Andrei and I were talking on the phone today, trading ideas about
>> speeding up importation of Phobos files. Any particular D file tends to
>> import much of Phobos, and much of Phobos imports the rest of it. We've
>> both noticed that file size doesn't seem to matter much for importation
>> speed, but file lookups remain slow.
> 
> I should have started out by testing this.
> 
> I replaced the file lookup with, essentially:
> 
>      if (name.startsWith("std"))
>          filename = "/phobos/" ~ name.replace(".", "/") ~ ".d";
>      else
>          filename = "/druntime/" ~ name.replace(".", "/") ~ ".d";
> 
> Plus a hard-coded set of package.d references.
> 
> Before, compiling my test file took about 0.67 to 0.70 seconds. After, it
> took about 0.67 to 0.70 seconds.
> 
> There is no point in optimizing filesystem access for importing phobos at
> this time.

Word. (Unless the libs are installed over a networked mount. Not sure 
how much we need to worry about that.)


More information about the Digitalmars-d mailing list