Re: AA.values un-@safe?!

2021-07-28 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 21:39:43 UTC, jfondren wrote: I don't know, but .byValue is @safe and returns a forward range, so you could use `.init.byValue.array` instead. Great point. Thanks.

Re: AA.values un-@safe?!

2021-07-28 Thread jfondren via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 21:04:11 UTC, Per Nordlöw wrote: Why is call to `values` in, for instance, ```d auto _ = string[string].init.values; ``` not `@safe`? I don't know, but .byValue is @safe and returns a forward range, so you could use `.init.byValue.array` instead.

Re: Performance issue with fiber

2021-07-28 Thread hanabi1224 via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 16:26:49 UTC, drug wrote: I profiled the provided example (not `FiberScheduler`) using perf. Both dmd and ldc2 gave the same result - `void filterInner(int, int)` took ~90% of the run time. The time was divided between: `int

Re: Performance issue with fiber

2021-07-28 Thread hanabi1224 via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 16:31:49 UTC, Ali Çehreli wrote: I assume the opposite because normally, the number of times a thread or fiber is spawned is nothing compared to the number of times they are context-switched. So, spawning can be expensive and nobody would realize as long as

AA.values un-@safe?!

2021-07-28 Thread Per Nordlöw via Digitalmars-d-learn
Why is call to `values` in, for instance, ```d auto _ = string[string].init.values; ``` not `@safe`?

Re: Performance issue with fiber

2021-07-28 Thread hanabi1224 via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 14:39:29 UTC, Mathias LANG wrote: Hence doing: ```diff - auto scheduler = new FiberScheduler(); + scheduler = new FiberScheduler(); ``` Thanks for pointing it out! Looks like I was benchmarking thread instead of fiber. I just made the change you suggest but the

Re: Performance issue with fiber

2021-07-28 Thread Ali Çehreli via Digitalmars-d-learn
On 7/28/21 1:15 AM, hanabi1224 wrote: > On Wednesday, 28 July 2021 at 01:12:16 UTC, Denis Feklushkin wrote: >> Spawning fiber is expensive > > Sorry but I cannot agree with the logic behind this statement, the whole > point of using fiber is that, spwaning system thread is expensive, thus > ppl

Re: Performance issue with fiber

2021-07-28 Thread drug via Digitalmars-d-learn
28.07.2021 17:39, Mathias LANG пишет: On Wednesday, 21 July 2021 at 22:51:38 UTC, hanabi1224 wrote: Hi, I'm new to D lang and encounter some performance issues with fiber, not sure if there's something obviously wrong with my code. I took a quick look, and the first problem I saw was that you

Re: Performance issue with fiber

2021-07-28 Thread Mathias LANG via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 22:51:38 UTC, hanabi1224 wrote: Hi, I'm new to D lang and encounter some performance issues with fiber, not sure if there's something obviously wrong with my code. I took a quick look, and the first problem I saw was that you were using `spawnLinked` but not

Re: Performance issue with fiber

2021-07-28 Thread James Blachly via Digitalmars-d-learn
On 7/27/21 9:12 PM, Denis Feklushkin wrote: Spawning fiber is expensive (but not so expensive as spawning thread, of course), but switching is fast. Thus, you can spawn and pause "workers" fibers for avaiting of jobs. (Probably, this behaviour is already implemented in number of libraries and

Re: Performance issue with fiber

2021-07-28 Thread hanabi1224 via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 01:12:16 UTC, Denis Feklushkin wrote: Spawning fiber is expensive Sorry but I cannot agree with the logic behind this statement, the whole point of using fiber is that, spwaning system thread is expensive, thus ppl create lightweight thread 'fiber', then if a

Re: Why does Unconst exist?

2021-07-28 Thread Tejas via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 05:52:02 UTC, Ali Çehreli wrote: On 7/27/21 10:38 PM, Tejas wrote: When I initially saw it, I was hopeful that it would allow me to bypass some of the restrictions of ```const``` , but it literally just takes a type and strips the ```const``` from it, you can't

Re: Why does Unconst exist?

2021-07-28 Thread Tejas via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 05:57:31 UTC, user1234 wrote: On Wednesday, 28 July 2021 at 05:38:44 UTC, Tejas wrote: When I initially saw it, I was hopeful that it would allow me to bypass some of the restrictions of ```const``` , but it literally just takes a type and strips the ```const```

Re: Why does Unconst exist?

2021-07-28 Thread user1234 via Digitalmars-d-learn
On Wednesday, 28 July 2021 at 05:38:44 UTC, Tejas wrote: When I initially saw it, I was hopeful that it would allow me to bypass some of the restrictions of ```const``` , but it literally just takes a type and strips the ```const``` from it, you can't pass a variable to it in order to get rid