Rewrite std.meta.staticMap using AliasAssign#7756
Rewrite std.meta.staticMap using AliasAssign#7756WalterBright wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#7756" |
|
The error is: but I'm not seeing where |
21cb51e to
3b92e86
Compare
|
@9il can you please have a look at the buildkite failures in Mir? |
|
dscanner fails with the new syntax (buildkite) |
|
The buildkite druntime error is: |
|
@s-ludwig In buildkite taggedalgebraic I'm getting an error: |
|
Looks like the following @safe @nogc nothrow version(mir_core_test) unittest
{
import std.meta: AliasSeq;
static F[3][] vals(F) = // value,exp,ldexp
[
[ 0, 0, 0],
[ 1, 0, 1],
[ -1, 0, -1],
[ 1, 1, 2],
[ 123, 10, 125952],
[ F.max, int.max, F.infinity],
[ F.max, -int.max, 0],
[ F.min_normal, -int.max, 0],
];
static foreach(F; AliasSeq!(double, real))
{{
int i;
for (i = 0; i < vals!F.length; i++)
{
F x = vals!F[i][0];
int exp = cast(int) vals!F[i][1];
F z = vals!F[i][2];
F l = ldexp(x, exp);
assert(feqrel(z, l) >= 23);
}
}}
}
|
It looks like there is a dependency cycle between |
|
@s-ludwig thanks! Though this should behave identically to the old implementation of staticMap, warts and all. |
|
Plot of dumb timings of staticMap!(Alias, int, int, int [up to 8192 times]). Starts off better, scales worse (I assume due to memory usage, even with lowmem the heap sizes are enormous) I'll do some heavier operations later. |
|
@maxhaton Good information. I bet the result is because the old is using a binary method to build long alias sequences, while the new is using the sequential one. Changing the implementation of staticMap to a binary method should fix that. |
|
@WalterBright more perf plots Same N values for fullyQualifiedName (slower, more memory usage) fullyQualifiedNameData.pdf First few 150 plotted in more detail fullyQualifiedNameData_linear.pdf aliasplots_linear.pdf Very clear division in the log-log plot |
3b92e86 to
b2fe067
Compare
b2fe067 to
24848ea
Compare
|
The old staticMap had changed since I last worked with it. Instead of calling itself, it used a function to generate a string that enumerated all the cases, and did one big (up to 150) case AliasSeq. Unfortunately, that implementation traded off the recursive call for a rather large set of compile-time allocations in generating the string. |
|
I have accidentally edited @WalterBright's comment and was surprised that I am able to do so. That is a bit weird. |
|
@9il that's because you have privileged access. It's a superpower, I only used it once when the comment writer asked me to modify it. |
|
Same here, might be because all of the sequences in those |
|
@WalterBright please rebase? Also, what are the plans with AliasAssign and phobos? |
|
I'm going to close this as #8039 seems to be a superior implementation. |
Try out dlang/dmd#12029