On Saturday, 4 September 2021 at 12:40:02 UTC, Per Nordlöw wrote:
>Omg. It really seems like it's motivated to do a benchmark with phobos unittests prefixed with
Should have been a reply to
>The "never" is false, https://d.godbolt.org/z/c4oeYM7rG
September 04, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Saturday, 4 September 2021 at 12:40:02 UTC, Per Nordlöw wrote: >Omg. It really seems like it's motivated to do a benchmark with phobos unittests prefixed with Should have been a reply to >The "never" is false, https://d.godbolt.org/z/c4oeYM7rG |
September 04, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan | On 9/4/21 7:43 AM, Johan wrote: >On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote: >On Saturday, 4 September 2021 at 00:09:37 UTC, H. S. Teoh wrote: >This is related to the bogonity of the current behaviour of -unittest, which compiles all unittests of all imported modules, even when you're compiling user code that has no interest in Phobos unittests. Well, no; it compiles all unittests of all compiled modules, not all imported modules. So it does not actually include Phobos unittests. [...] As Steven Schveighoffer [pointed out][1], Phobos unittests are never included in user code, regardless of whether The "never" is false, https://d.godbolt.org/z/c4oeYM7rG Unittests inside template code will be added to user code, unless the compiler has determined that the template is already instantiated in Phobos code (the "template culling" that the frontend does, whose behavior is not easily influenced by the programmer). It's always included (or at least it was when I last looked at it), as -unittest implies some form of -allinst. There was some effort to fix this, but I can't remember if the outcome was that it was merged or not. -Steve |
September 04, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On 9/4/21 5:42 AM, Per Nordlöw wrote: >On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote: >As Steven Schveighoffer [pointed out][1], Phobos unittests are never included in user code, regardless of whether Yes, but they are lexed and parsed, right? Yes, and I think this is trivially so for any versioned code in the file. Note that lexing and parsing is extremely quick, and I wouldn't focus on trying to trim this out, you won't get much performance out of that. -Steve |
September 04, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Saturday, 4 September 2021 at 13:12:49 UTC, Steven Schveighoffer wrote: >Note that lexing and parsing is extremely quick, and I wouldn't focus on trying to trim this out, you won't get much performance out of that. -Steve For the record, a D file containing only
in 0.20s whereas
in 0.45s on my ThreadRipper. |
September 04, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Saturday, 4 September 2021 at 20:05:17 UTC, Per Nordlöw wrote: >
should be
|
September 04, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Saturday, 4 September 2021 at 20:06:27 UTC, Per Nordlöw wrote: >On Saturday, 4 September 2021 at 20:05:17 UTC, Per Nordlöw wrote: >
should be
When you generate the object files, I get 13K vs. 75K from a file containing just
|
September 05, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On 9/4/21 4:05 PM, Per Nordlöw wrote: >On Saturday, 4 September 2021 at 13:12:49 UTC, Steven Schveighoffer wrote: >Note that lexing and parsing is extremely quick, and I wouldn't focus on trying to trim this out, you won't get much performance out of that. -Steve For the record, a D file containing only
in 0.20s whereas
in 0.45s on my ThreadRipper. I doubt that's because of the parsing. I've gone down these kinds of rabbit holes. It's one of the reasons I tried to remove ALL version(unittest) blocks from phobos that import other modules. But you just can't remove them all. And any unittests inside templates are going to compile and get included, even if you don't instantiate anything. I also discovered that CTFE initializers run, even if you don't use the imported symbol, and even if you don't need type inference. Can't remember if that got fixed. I think you would find you could probably attribute the 0.25s there to a few modules that do things when unittests are turned on. According to https://github.com/dlang/dmd/blob/1ae5fee06ddd0599fb187595f8b0cebf8c840ebd/src/dmd/parse.d#L642-L683, if unittests aren't turned on, indeed the parser simplifies its parsing of the unittest. It skips over the unittest block, and doesn't allocate any AST nodes for it. But that difference I don't think is going to be the cause for a significant slowdown. One can construct a test to check the parsing:
Using phobos as a test case is rife with things that may be contributing besides the parser. -Steve |
September 07, 2021 Re: Phobos Unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Friday, 3 September 2021 at 23:39:44 UTC, Per Nordlöw wrote: >When is a phobos unittest supposed to be qualified with version For reference, see my previous attempt at making dmd more flexible at compiling unittests at |