digitalmars.D - More zero-initialization optimizations pending in
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (8/8) Oct 19 2018 Now that
- Nathan S. (9/17) Oct 20 2018 I looked and identified low-hanging fruit in
- Stanislav Blinov (6/11) Oct 20 2018 Not unless `mem{set, cpy, move}` etc. are made into compiler
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (4/15) Oct 21 2018 So in which cases is `memset` faster than assignment?
- Nathan S. (4/6) Oct 30 2018 I don't know. My guess would be maybe if the type is large, or
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?
Oct 19 2018
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 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.
Oct 20 2018
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.
Oct 20 2018
On Saturday, 20 October 2018 at 15:10:38 UTC, Nathan S. wrote:What did you search for to find these?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 inOther 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!
Oct 21 2018
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.
Oct 30 2018