I am heavily using SumType (which I like very much). The problem I am having is that is seems to be causing slow compile times (as can be observed by profiling during the compile). The problem seems to be with match (which is extremely convenient to use). I looked at the code and it does the only reasonable thing too do which is to test each handler against each type. The slow compile time makes development slower and less pleasant, so I am thinking of replacing SumType with my own tagged union and writing out the switches by hand. However, I really don't like this idea since it makes the code less readable and more prone to errors. Any suggestions?
Thread overview | |||||
---|---|---|---|---|---|
|
October 28, 2021 Re: SumType | ||||
---|---|---|---|---|
| ||||
Posted in reply to JG | On Thursday, 28 October 2021 at 09:02:52 UTC, JG wrote: >I am heavily using SumType (which I like very much). The problem I am having is that is seems to be causing slow compile times (as can be observed by profiling during the compile). The problem seems to be with match (which is extremely convenient to use). I looked at the code and it does the only reasonable thing too do which is to test each handler against each type. The slow compile time makes development slower and less pleasant, so I am thinking of replacing SumType with my own tagged union and writing out the switches by hand. However, I really don't like this idea since it makes the code less readable and more prone to errors. Any suggestions? Hi, I'm the author of If you have an example of the kind of code you are seeing poor compile-time performance for, I'd be happy to use it as a benchmark/profiling target. Any profiling data you've collected would also be helpful. I've created issues for this on Bugzilla and the sumtype Github repository: https://issues.dlang.org/show_bug.cgi?id=22447 |
October 28, 2021 Re: SumType | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Thursday, 28 October 2021 at 13:30:53 UTC, Paul Backus wrote: >On Thursday, 28 October 2021 at 09:02:52 UTC, JG wrote: >I am heavily using SumType (which I like very much). The problem I am having is that is seems to be causing slow compile times (as can be observed by profiling during the compile). The problem seems to be with match (which is extremely convenient to use). I looked at the code and it does the only reasonable thing too do which is to test each handler against each type. The slow compile time makes development slower and less pleasant, so I am thinking of replacing SumType with my own tagged union and writing out the switches by hand. However, I really don't like this idea since it makes the code less readable and more prone to errors. Any suggestions? Hi, I'm the author of If you have an example of the kind of code you are seeing poor compile-time performance for, I'd be happy to use it as a benchmark/profiling target. Any profiling data you've collected would also be helpful. I've created issues for this on Bugzilla and the sumtype Github repository: https://issues.dlang.org/show_bug.cgi?id=22447 Thank you so much for your response (and thanks for the hard work that went into SumType). Here is a rather contrived example which compiles in around 9 seconds on my machine. import std; struct A1 {int val; } alias A = SumType!(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14); T asserter(T)() { assert(0); } auto op(A1 x, A1 y, A1 z) { return x.val + y.val + z.val; }
}
|