dlang-tour / core

D Language online tour (https://tour.dlang.org/) and online editor (https://run.dlang.io/)
Boost Software License 1.0
120 stars 48 forks source link

Execution cache considers only the source code #668

Closed PetarKirov closed 6 years ago

PetarKirov commented 6 years ago

I noticed that when I export the example from the start page and change the compiler to dmd-nightly (https://run.dlang.io/is/mO38pH), clicking on the AST button returns the LDC IR.

I believe that the problem is in the caching code: https://github.com/dlang-tour/core/blob/8fc3f3aebae676a26b4db848c945ce18d8862451/source/exec/cache.d#L41-L57 uses only the source code (input.source) as a key in the sourceHashToOutput_ AA. Instead the whole IExecProvider.RunInput object should be used as the key type.

We just need to make sure that if two IExecProvider.RunInput object are equal, but their source members point to different pieces of memory (but with the same content) the default AA hash algorithm produces the same hash.

wilzbach commented 6 years ago

I think I have disabled the caching logic entirely because of problems I don't recall anymore and switched to NGINX's super-fast caching. That's why if you click run twice, the second time it will load sooo fast. I will look into this.

wilzbach commented 6 years ago

It's not an NGINX issue, otherwise X-Cached would be part of the response.

wilzbach commented 6 years ago

PR https://github.com/dlang-tour/core/pull/669