Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 19, 2018 More zero-initialization optimizations pending in std.experimental.allocator? | ||||
---|---|---|---|---|
| ||||
Now that https://github.com/dlang/phobos/pull/6411 has been merged and DMD stable soon has the new __traits(isZeroInit, T) found here https://dlang.org/changelog/2.083.0.html#isZeroInit are there more zero-initializations that can be optimized in std.experimental.allocator? |
October 20, 2018 Re: More zero-initialization optimizations pending in std.experimental.allocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Friday, 19 October 2018 at 21:29:42 UTC, Per Nordlöw wrote:
> Now that
>
> https://github.com/dlang/phobos/pull/6411
>
> has been merged and DMD stable soon has the new
>
> __traits(isZeroInit, T)
>
> found here
>
> https://dlang.org/changelog/2.083.0.html#isZeroInit
>
> are there more zero-initializations that can be optimized in std.experimental.allocator?
I looked and identified low-hanging fruit in std.mutation.initializeAll & moveEmplace and in std.typecons.RefCounted (PR #6698), and in std.conv.emplaceInitializer (PR #6461). Other opportunities would rely on being able to identify if it's ever more efficient to write `memset(&x, 0, typeof(x).sizeof)` instead of `x = typeof(x).init` which seems like the kind of optimization that belongs in the compiler instead.
|
October 20, 2018 Re: More zero-initialization optimizations pending in std.experimental.allocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nathan S. | On Saturday, 20 October 2018 at 15:10:38 UTC, Nathan S. wrote:
> Other opportunities would rely on being able to identify if it's ever more efficient to write `memset(&x, 0, typeof(x).sizeof)` instead of `x = typeof(x).init` which seems like the kind of optimization that belongs in the compiler instead.
Not unless `mem{set, cpy, move}` etc. are made into compiler intrinsics. Carrying libc dependencies into low-level sensitive code just stinks. If anything, the `memcpy` calls should be removed from `moveEmplace`, not `memset` calls added to it.
They're also not CTFE-able.
|
October 21, 2018 Re: More zero-initialization optimizations pending in std.experimental.allocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nathan S. | On Saturday, 20 October 2018 at 15:10:38 UTC, Nathan S. wrote: >> are there more zero-initializations that can be optimized in std.experimental.allocator? > > I looked and identified low-hanging fruit in std.mutation.initializeAll & moveEmplace and in std.typecons.RefCounted (PR #6698), and in std.conv.emplaceInitializer (PR #6461). What did you search for to find these? > Other opportunities would rely on being able to identify if it's ever more efficient to write `memset(&x, 0, typeof(x).sizeof)` instead of `x = typeof(x).init` which seems like the kind of optimization that belongs in the compiler instead. So in which cases is `memset` faster than assignment? Thanks! |
October 30, 2018 Re: More zero-initialization optimizations pending in std.experimental.allocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Sunday, 21 October 2018 at 11:09:54 UTC, Per Nordlöw wrote: > What did you search for to find these? `typeid` and `.init`. > So in which cases is `memset` faster than assignment? I don't know. My guess would be maybe if the type is large, or maybe never. Certainly we'd have to benchmark. |
Copyright © 1999-2021 by the D Language Foundation