Speeding up importing Phobos files

Neia Neutuladh neia at ikeran.org
Mon Jan 21 19:46:57 UTC 2019


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.


More information about the Digitalmars-d mailing list