Re: need help to redefine packed c struct in d

2024-09-28 Thread Dakota via Digitalmars-d-learn
On Saturday, 28 September 2024 at 08:35:39 UTC, Johan wrote: On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a;

Re: need help to redefine packed c struct in d

2024-09-28 Thread Johan via Digitalmars-d-learn
On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a; uint8_t arr[14]; }; ``` the struct size in C is 24:

Re: need help to work around float union non-zero init

2024-09-23 Thread Dakota via Digitalmars-d-learn
On Friday, 20 September 2024 at 16:21:10 UTC, Nick Treleaven wrote: On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: Thanks to Dennis for the workaround. Thanks your all for the tips, void solution fix me problem.

Re: need help to work around float union non-zero init

2024-09-20 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32;

Re: need help to work around float union non-zero init

2024-09-20 Thread monkyyy via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32;

Re: need help to work around float union non-zero init

2024-09-20 Thread IchorDev via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I consider this is compiler bug (it may take years to get fixed) I've sent issues for compiler bugs and had them fixed within the next release—about month, not years. Also yes, this seems to be a compiler bug; unless there's some s

need help to work around float union non-zero init

2024-09-20 Thread Dakota via Digitalmars-d-learn
I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32; } } static assert(__traits(isZeroInit, test_t) ); ``` ``

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-23 Thread monkyyy via Digitalmars-d-learn
On Friday, 23 August 2024 at 05:50:43 UTC, Dakota wrote: any suggestions how to fix this? ```sh /ldc/bin/../import/core/stdc/stdio.d(31): Error: module ``` I dont use the std with wasm, everything imports everything else and there are just broken symbols deep in "core" that wont be fixed

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread Dakota via Digitalmars-d-learn
On Thursday, 22 August 2024 at 21:19:57 UTC, monkyyy wrote: On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? yes; you'll have to untangle my build system https://github.com/crazymonkyyy/raylib-2024 It will al

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread monkyyy via Digitalmars-d-learn
On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? yes; you'll have to untangle my build system https://github.com/crazymonkyyy/raylib-2024 It will always suck tho

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? Some years a go, i was able to build and run my hobby game using EMScripen. Things must be changed now. I drop the link here. I cannot help further since i

Re: need help to check symbol is static variable or not

2024-07-15 Thread Dakota via Digitalmars-d-learn
On Monday, 15 July 2024 at 11:16:23 UTC, Nick Treleaven wrote: I put `type_s` in a file anonstruct.c, then: ```d import anonstruct; pragma(msg, isStatic!(type_s.c)); ``` That outputs `false`, because the symbol is not a compile-time value. Is that what you meant? No, I am here deal with a lo

Re: need help to check symbol is static variable or not

2024-07-15 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 15 July 2024 at 06:44:12 UTC, Dakota wrote: ```d struct type_s { union { struct { int a; int b; } c; }; }; ``` `type c` will return false with `enum isStatic(alias V) = __traits(compiles, { enum v = V; });` I put `type_s` in

Re: need help to check symbol is static variable or not

2024-07-14 Thread Dakota via Digitalmars-d-learn
On Monday, 1 July 2024 at 11:15:46 UTC, Nick Treleaven wrote: ``` There is a case check will give wrong resutls: ```d struct type_s { union { struct { int a; int b; } c; }; }; ``` `type c` will return false with `enum isStatic(alias V

Re: need help to get bitoffsetof bitwidth for clang

2024-07-04 Thread Dakota via Digitalmars-d-learn
On Wednesday, 3 July 2024 at 21:47:32 UTC, Tim wrote: If you only want to see the layout, you can use the following command to dump it: ``` clang test.c -Xclang -fdump-record-layouts -c ``` File test.c could contain the following: ``` struct S { int a : 3; int b : 29; }; struct S dummy;

Re: need help to get bitoffsetof bitwidth for clang

2024-07-03 Thread Tim via Digitalmars-d-learn
On Tuesday, 2 July 2024 at 05:34:19 UTC, Dakota wrote: I want to get `bitoffsetof` and `bitwidth` in clang, to verify the d memory layout. I try this but not work: ```c #define offsetof_bit(type, member) ((offsetof(type, member) * 8) + __builtin_ctz(((type *)0)->member)) ``` get this error

Re: need help to check symbol is static variable or not

2024-07-01 Thread Dakota via Digitalmars-d-learn
On Monday, 1 July 2024 at 11:15:46 UTC, Nick Treleaven wrote: On Monday, 1 July 2024 at 07:32:30 UTC, Dakota wrote: this code give error: ```d static if( !__traits(compiles, mixin("enum v = V;")) ) { enum v = V; } ``` __traits(compiles, ...) can't check if a declaration is valid directl

Re: need help to check symbol is static variable or not

2024-07-01 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 1 July 2024 at 07:32:30 UTC, Dakota wrote: this code give error: ```d static if( !__traits(compiles, mixin("enum v = V;")) ) { enum v = V; } ``` __traits(compiles, ...) can't check if a declaration is valid directly. You have to wrap it in a function literal expression: ```d

need help to check symbol is static variable or not

2024-07-01 Thread Dakota via Digitalmars-d-learn
this code give error: ```d static if( !__traits(compiles, mixin("enum v = V;")) ) { enum v = V; } ``` ```sh Error: static variable `NotWorkVar` cannot be read at compile time ``` V is alias get from `typeof(__traits(getMember, M, symbol)`, M is `module` from importC. the importC so

Re: need help to use C++ callback from garnet

2024-06-04 Thread Dakota via Digitalmars-d-learn
On Wednesday, 29 May 2024 at 09:01:13 UTC, evilrat wrote: On Wednesday, 29 May 2024 at 07:47:01 UTC, Dakota wrote: [...] (here is the signature of callback) https://github.com/microsoft/garnet/blob/ade2991f3737b9b5e3151d0dd0b614adfd4bcecd/libs/storage/Tsavorite/cc/src/device/async.h#L25 [...

Re: need help to use C++ callback from garnet

2024-05-29 Thread evilrat via Digitalmars-d-learn
garnet source code to support pass a C function callback) I am newbie to C++ and D, any help will be appreciate (here is the signature of callback) https://github.com/microsoft/garnet/blob/ade2991f3737b9b5e3151d0dd0b614adfd4bcecd/libs/storage/Tsavorite/cc/src/device/async.h#L25 ```cpp typede

need help to use C++ callback from garnet

2024-05-29 Thread Dakota via Digitalmars-d-learn
k) I am newbie to C++ and D, any help will be appreciate

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-20 Thread Carl Sturtivant via Digitalmars-d-learn
I found a way to make a solution for 64 bit Windows mechanically with many MSVC intrinsics, using only mingw64. Here's an [MSYS2](https://www.msys2.org/) bash script. ```bash gcc -E -P intrin.c -o vcintrinsics.c sed -i 's/extern __inline__ __attribute__((__always_inline__,__gnu_inline__))//g'

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-10 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 7 March 2024 at 18:14:32 UTC, Gregor Mückl wrote: 2. C code referring to MSVC-specific compiler intrinsics. At least InterlockedExchangeAdd, InterlockedExchangeAdd64 and _stosb are such intrinsics. This is harder to resolve. There are two ways forward here: either implement a shim

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 7 March 2024 at 18:14:32 UTC, Gregor Mückl wrote: 1. Missing import libraries for Win32 API functions. Anything starting with `__imp_` is a symbol that should be provided by a DLL import library. MapViewOfFileNuma2 for example is provided by onecore.lib in the Windows SDK, accordi

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-07 Thread Gregor Mückl via Digitalmars-d-learn
On Tuesday, 5 March 2024 at 00:20:36 UTC, Carl Sturtivant wrote: On Monday, 4 March 2024 at 21:21:20 UTC, Carl Sturtivant wrote: ``` blah.obj: error LNK2019: unresolved external symbol _mul128 referenced in function MultiplyExtract128 blah.obj: error LNK2019: unresolved external symbol __shift

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 4 March 2024 at 21:21:20 UTC, Carl Sturtivant wrote: ``` blah.obj: error LNK2019: unresolved external symbol _mul128 referenced in function MultiplyExtract128 blah.obj: error LNK2019: unresolved external symbol __shiftright128 referenced in function MultiplyExtract128 blah.obj: error

Re: need help with simple importC

2024-02-26 Thread Dakota via Digitalmars-d-learn
On Monday, 26 February 2024 at 07:44:02 UTC, Dakota wrote: I am use importC from linux, get this error: ```sh /usr/include/x86_64-linux-gnu/bits/floatn-common.h(214): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/floatn-common.h(251): Error: illegal combinat

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-21 Thread Daniel Kozak via Digitalmars-d-learn
Dne so 20. 1. 2024 21:21 uživatel Renato via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > On Saturday, 20 January 2024 at 19:45:19 UTC, Daniel Kozak wrote: > > On Sat, Jan 20, 2024 at 2:11 PM Renato via Digitalmars-d-learn > > < digitalmars-d-learn@puremagic.com> wrote: > > >

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-20 Thread Renato via Digitalmars-d-learn
On Saturday, 20 January 2024 at 19:45:19 UTC, Daniel Kozak wrote: On Sat, Jan 20, 2024 at 2:11 PM Renato via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: Wow, fantastic feedback from lots of people, thanks so much! ... > evilrat: > There is another important difference, i

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-20 Thread Daniel Kozak via Digitalmars-d-learn
On Sat, Jan 20, 2024 at 2:11 PM Renato via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Wow, fantastic feedback from lots of people, thanks so much! > ... > > > evilrat: > > There is another important difference, i quickly looked up D > > associative array implementation and t

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-20 Thread Renato via Digitalmars-d-learn
On Saturday, 20 January 2024 at 13:07:39 UTC, Renato wrote: D overhead with the fastest compiler, LDC, compared with Rust: ``` 1.0 1.707627119 1.919527897 1.954595186 1.351342502 1.556217748 ``` Oh sorry, I only posted the rates for the Linux benchmark... On Mac M1, for some reason, D was a

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-20 Thread Renato via Digitalmars-d-learn
his table lookup is no in the hot path, so as expected, it only seems to speed up slightly loading the dictionary (which is good because D was behind for small inputs - and even this tiny improvement could help D catch up). To save from having to write a old-school verbose switch, i suspect h

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-20 Thread Siarhei Siamashka via Digitalmars-d-learn
On Saturday, 20 January 2024 at 01:27:50 UTC, H. S. Teoh wrote: On Sat, Jan 20, 2024 at 01:35:44AM +0100, Daniel Kozak via Digitalmars-d-learn wrote: [...] > Try addressing the points I wrote above and see if it makes a > difference. I have tried it (all of it) even before you wrote i

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jan 20, 2024 at 01:35:44AM +0100, Daniel Kozak via Digitalmars-d-learn wrote: [...] >> Try addressing the points I wrote above and see if it makes a >> difference. > >I have tried it (all of it) even before you wrote it here, because >I have completely the same ideas, but

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Jan 19, 2024 at 4:44 PM H. S. Teoh via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Taking a look at this code: > ... > Try addressing the points I wrote above and see if it makes a > difference. > > I have tried it (all of it) even before you wrote it here, because

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 19 January 2024 at 17:18:36 UTC, evilrat wrote: On Friday, 19 January 2024 at 16:55:25 UTC, ryuukk_ wrote: You do hash map lookup for every character in D, it's slow, whereas in Rust you do it via pattern matching, java does the same, pattern matching Yet another reason to advoc

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 19 January 2024 at 08:57:40 UTC, Renato wrote: Do you know why the whole thread seems to have disappeared?? There's a lot of good stuff in the thread, it would be a huge shame to lose all that! I agree! Thanks for posting your benchmarks, I thought your whole benching setup was pre

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread evilrat via Digitalmars-d-learn
On Friday, 19 January 2024 at 16:55:25 UTC, ryuukk_ wrote: You do hash map lookup for every character in D, it's slow, whereas in Rust you do it via pattern matching, java does the same, pattern matching Yet another reason to advocate for pattern matching in D and switch as expression Th

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 19 January 2024 at 13:40:39 UTC, Renato wrote: On Friday, 19 January 2024 at 10:15:57 UTC, evilrat wrote: On Friday, 19 January 2024 at 09:08:17 UTC, Renato wrote: I forgot to mention: the Java version is using a Trie... and it consistently beats the Rust numeric algorithm (which m

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 19, 2024 at 01:40:39PM +, Renato via Digitalmars-d-learn wrote: > On Friday, 19 January 2024 at 10:15:57 UTC, evilrat wrote: [...] > > Additionally if you comparing D by measuring DMD performance - > > don't. It is valuable in developing for fast iterations, but it > > lacks many m

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread Renato via Digitalmars-d-learn
On Friday, 19 January 2024 at 10:15:57 UTC, evilrat wrote: On Friday, 19 January 2024 at 09:08:17 UTC, Renato wrote: I forgot to mention: the Java version is using a Trie... and it consistently beats the Rust numeric algorithm (which means it's still faster than your D solution), but the Java

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread Renato via Digitalmars-d-learn
On Friday, 19 January 2024 at 10:15:57 UTC, evilrat wrote: On Friday, 19 January 2024 at 09:08:17 UTC, Renato wrote: I forgot to mention: the Java version is using a Trie... and it consistently beats the Rust numeric algorithm (which means it's still faster than your D solution), but the Java

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread Renato via Digitalmars-d-learn
On Friday, 19 January 2024 at 05:17:51 UTC, H. S. Teoh wrote: On Thu, Jan 18, 2024 at 04:23:16PM +, Renato via Digitalmars-d-learn wrote: [...] Ok, last time I'm running this for someone else :D ``` Proc,Run,Memory(bytes),Time(ms) ===> ./rust ./rust,23920640,30 ./rust,24018944,147 ./rust,24

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-18 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 18, 2024 at 04:23:16PM +, Renato via Digitalmars-d-learn wrote: [...] > Ok, last time I'm running this for someone else :D > > ``` > Proc,Run,Memory(bytes),Time(ms) > ===> ./rust > ./rust,23920640,30 > ./rust,24018944,147 > ./rust,24068096,592 > ./rust,24150016,1187 > ./rust,776601

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-18 Thread Renato via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 16:54:00 UTC, H. S. Teoh wrote: On Wed, Jan 17, 2024 at 07:57:02AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] I'll push the code to github. [...] Here: https://github.com/quickfur/prechelt/blob/master/encode_phone.d T BTW here's you main funct

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-18 Thread Renato via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 16:54:00 UTC, H. S. Teoh wrote: On Wed, Jan 17, 2024 at 07:57:02AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] I'll push the code to github. [...] Here: https://github.com/quickfur/prechelt/blob/master/encode_phone.d T Ok, last time I'm running

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread Renato via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 16:30:08 UTC, H. S. Teoh wrote: On Wed, Jan 17, 2024 at 07:19:39AM +, Renato via Digitalmars-d-learn wrote: [...] But pls run the benchmarks yourself as I am not going to keep running it for you, and would be nice if you posted your solution on a Gist for ex

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 17, 2024 at 07:57:02AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > I'll push the code to github. [...] Here: https://github.com/quickfur/prechelt/blob/master/encode_phone.d T -- Why do conspiracy theories always come from the same people??

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 17, 2024 at 07:19:39AM +, Renato via Digitalmars-d-learn wrote: [...] > But pls run the benchmarks yourself as I am not going to keep running > it for you, and would be nice if you posted your solution on a Gist > for example, pasting lots of code in the forum makes it difficult to

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 17, 2024 at 07:19:39AM +, Renato via Digitalmars-d-learn wrote: > On Tuesday, 16 January 2024 at 22:13:55 UTC, H. S. Teoh wrote: > > used for the recursive calls. Getting rid of the .format ought to > > speed it up a bit. Will try that now... > > > > That will make no difference f

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread Renato via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 11:56:19 UTC, evilrat wrote: On Wednesday, 17 January 2024 at 11:20:14 UTC, Renato wrote: That means the input file is still not ASCII (or UTF-8) as it should. Java is reading files with the ASCII encoding so it should've worked fine. It seems that it is onl

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 11:20:14 UTC, Renato wrote: That means the input file is still not ASCII (or UTF-8) as it should. Java is reading files with the ASCII encoding so it should've worked fine. It seems that it is only works with ASCII encoding though.

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread Renato via Digitalmars-d-learn
toathaydes/prechelt-phone-number-encoding/blob/master/benchmark.sh#L31): ``` java -cp "build/util" util.GeneratePhoneNumbers 1000 > phones_1000.txt ``` Perhaps using this option when running Java will help: ``` java -DFile.Encoding=UTF-8 ... ``` I've used powershell env

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
ark.sh#L31): ``` java -cp "build/util" util.GeneratePhoneNumbers 1000 > phones_1000.txt ``` Perhaps using this option when running Java will help: ``` java -DFile.Encoding=UTF-8 ... ``` I've used powershell env var to set output to utf8, D version now works but java doesn't

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread Renato via Digitalmars-d-learn
atePhoneNumbers 1000 > phones_1000.txt ``` Perhaps using this option when running Java will help: ``` java -DFile.Encoding=UTF-8 ... ```

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread Renato via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 09:15:02 UTC, evilrat wrote: On Wednesday, 17 January 2024 at 07:11:02 UTC, Renato wrote: If you want to check your performance, you know you can run the `./benchmark.sh` yourself? Out of curiosity I've tried to manually run this on Windows and it seems that

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 07:06:25 UTC, Renato wrote: On Tuesday, 16 January 2024 at 22:15:04 UTC, Siarhei Siamashka wrote: On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote: It's a GC allocations fest. Things like this make it slow: ```diff { -string digit = [digit

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 07:11:02 UTC, Renato wrote: If you want to check your performance, you know you can run the `./benchmark.sh` yourself? Out of curiosity I've tried to manually run this on Windows and it seems that Java generator for these numbers files is "broken", the resul

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Renato via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 22:13:55 UTC, H. S. Teoh wrote: used for the recursive calls. Getting rid of the .format ought to speed it up a bit. Will try that now... That will make no difference for the `count` option which is where your solution was very slow. To run the slow test manual

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Renato via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 22:15:04 UTC, Siarhei Siamashka wrote: On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote: For the record (I already posted this on GitHub)... here's [my current fastest solution](https://github.com/renatoathaydes/prechelt-phone-number-encoding/blob/dlang-k

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2024 at 10:15:04PM +, Siarhei Siamashka via Digitalmars-d-learn wrote: > On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote: [...] > > ... what I am really curious about is what the code I wrote is doing > > wrong that causes it to run 4x slower than Rust despite doing "

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote: For the record (I already posted this on GitHub)... here's [my current fastest solution](https://github.com/renatoathaydes/prechelt-phone-number-encoding/blob/dlang-key-hash-incremental/src/d/src/dencoder.d) time using the same algorithm

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2024 at 09:15:19PM +, Renato via Digitalmars-d-learn wrote: > On Tuesday, 16 January 2024 at 20:34:48 UTC, H. S. Teoh wrote: > > On Tue, Jan 16, 2024 at 12:28:49PM -0800, H. S. Teoh via > > Digitalmars-d-learn wrote: [...] > > > Anyway, I've fixed the problem, now my program pro

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote: I can't explain why it's so incredibly fast, specially for the `count` case. I tried using the same hashing function on my solution, but that didn't really help me! That's dynamic programming with memoization. Ba

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Renato via Digitalmars-d-learn
for the `count` case. I tried using the same hashing function on my solution, but that didn't really help me! Pretty cool to see different solutions to the problem, but I'm still curious to know where the solution I wrote is being slow compared to Rust which is using identical, to my u

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2024 at 12:28:49PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > Anyway, I've fixed the problem, now my program produces the exact same > output as Renato's repo. Code is posted below. [...] Oops, forgot to actually paste the code. Here it is: -

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2024 at 06:54:56PM +, Renato via Digitalmars-d-learn wrote: > On Tuesday, 16 January 2024 at 16:56:04 UTC, Siarhei Siamashka wrote: [...] > > You are not allowed to emit "1" as the first token in the output as > > long as there are any dictionary word matches at that position. T

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Renato via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 16:56:04 UTC, Siarhei Siamashka wrote: On Tuesday, 16 January 2024 at 15:50:35 UTC, H. S. Teoh wrote: Unfortunately there seems to be some discrepancy between the output I got and the prescribed output in your repository. For example, in your output the number 155

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 15:50:35 UTC, H. S. Teoh wrote: Unfortunately there seems to be some discrepancy between the output I got and the prescribed output in your repository. For example, in your output the number 1556/0 does not have an encoding, but isn't "1 Mai 0" a valid encoding ac

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
P.S. Compiling my program with `ldc -O2`, it runs so fast that I couldn't measure any meaningful running time that's greater than startup overhead. So I wrote a helper program to generate random phone numbers up to 50 characters long, and found that it could encode 1 million phone numbers in 2.2 s

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2024 at 07:50:35AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > Unfortunately there seems to be some discrepancy between the output I > got and the prescribed output in your repository. For example, in your > output the number 1556/0 does not have an encoding, but isn't

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 15, 2024 at 08:10:55PM +, Renato via Digitalmars-d-learn wrote: > On Monday, 15 January 2024 at 01:10:14 UTC, Sergey wrote: > > On Sunday, 14 January 2024 at 17:11:27 UTC, Renato wrote: > > > If anyone can find any flaw in my methodology or optmise my code so > > > that it can still

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-15 Thread Renato via Digitalmars-d-learn
On Monday, 15 January 2024 at 01:10:14 UTC, Sergey wrote: On Sunday, 14 January 2024 at 17:11:27 UTC, Renato wrote: If anyone can find any flaw in my methodology or optmise my code so that it can still get a couple of times faster, approaching Rust's performance, I would greatly appreciate tha

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-14 Thread Sergey via Digitalmars-d-learn
On Sunday, 14 January 2024 at 17:11:27 UTC, Renato wrote: If anyone can find any flaw in my methodology or optmise my code so that it can still get a couple of times faster, approaching Rust's performance, I would greatly appreciate that! But for now, my understanding is that the most promising

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-14 Thread Renato via Digitalmars-d-learn
On Sunday, 14 January 2024 at 10:02:58 UTC, Jordan Wilson wrote: On Saturday, 13 January 2024 at 11:03:42 UTC, Renato wrote: I like to use a phone encoding problem to determine the strenghtness and weaknesses of programming languages because this problem is easy enough I can write solutions in

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-14 Thread Renato via Digitalmars-d-learn
On Saturday, 13 January 2024 at 23:20:32 UTC, Sergey wrote: On Saturday, 13 January 2024 at 19:35:57 UTC, Renato wrote: On Saturday, 13 January 2024 at 17:00:58 UTC, Anonymouse wrote: On Saturday, 13 January 2024 at 12:55:27 UTC, Renato wrote: [...] I will have to try it... I thought that `Big

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-14 Thread Jordan Wilson via Digitalmars-d-learn
On Saturday, 13 January 2024 at 11:03:42 UTC, Renato wrote: I like to use a phone encoding problem to determine the strenghtness and weaknesses of programming languages because this problem is easy enough I can write solutions in any language in a few hours, but complex enough to exercise lots

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-14 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 13 January 2024 at 23:20:32 UTC, Sergey wrote: I would suggest to rewrite in the same way as Rust implemented. Probably you would like to try: [...] I would strongly argue for profiling first instead of optimising based on conjecture. If you profile you have solid evidence on wha

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-13 Thread Sergey via Digitalmars-d-learn
On Saturday, 13 January 2024 at 19:35:57 UTC, Renato wrote: On Saturday, 13 January 2024 at 17:00:58 UTC, Anonymouse wrote: On Saturday, 13 January 2024 at 12:55:27 UTC, Renato wrote: [...] I will have to try it... I thought that `BigInt` was to blame for the slowness (from what I could read f

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-13 Thread Renato via Digitalmars-d-learn
On Saturday, 13 January 2024 at 17:00:58 UTC, Anonymouse wrote: On Saturday, 13 January 2024 at 12:55:27 UTC, Renato wrote: [...] Not a great profiling experience :). Anyone has a better suggestion to "parse" the trace file? As a drive-by suggestion and I hope it doesn't derail anything, but

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-13 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 13 January 2024 at 12:55:27 UTC, Renato wrote: [...] Not a great profiling experience :). Anyone has a better suggestion to "parse" the trace file? As a drive-by suggestion and I hope it doesn't derail anything, but if you have the opportunity to run it on linux, have you tried

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-13 Thread Renato via Digitalmars-d-learn
On Saturday, 13 January 2024 at 11:03:42 UTC, Renato wrote: I tried to profile the D code but the profiler seems to be broken on my OS (Mac): I profiled it on Linux and stored [the trace.log file](https://gist.github.com/renatoathaydes/fd8752ed81b0cf792ed7ef5aa3d68acd) on a public Gist.

Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-13 Thread Renato via Digitalmars-d-learn
I like to use a phone encoding problem to determine the strenghtness and weaknesses of programming languages because this problem is easy enough I can write solutions in any language in a few hours, but complex enough to exercise lots of interesting parts of the language. You can check [my in

Re: Synchronisation help

2024-01-03 Thread Anonymouse via Digitalmars-d-learn
ould do for my scope. I'm much more confident using this compared to the naked `shared` AA I started with. Thanks everyone for the help.

Re: Synchronisation help

2024-01-02 Thread user1234 via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 11:39:12 UTC, Anonymouse wrote: On Tuesday, 2 January 2024 at 11:05:33 UTC, user1234 wrote: Do not use `shared` AA. Use `__gshared` + sync primitives. `shared` AA will lead to all sort of bugs: - https://issues.dlang.org/show_bug.cgi?id=20484#c1 - https://issues.d

Re: Synchronisation help

2024-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 2, 2024 3:41:55 AM MST Anonymouse via Digitalmars-d-learn wrote: > On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: > > [...] > > Thank you. Yes, `Foo` is a class for the purposes of inheritance > -- I left that out of the example. > > So a completely valid so

Re: Synchronisation help

2024-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 2, 2024 4:39:12 AM MST Anonymouse via Digitalmars-d-learn wrote: > On Tuesday, 2 January 2024 at 11:05:33 UTC, user1234 wrote: > > Do not use `shared` AA. Use `__gshared` + sync primitives. > > `shared` AA will lead to all sort of bugs: > > > > - https://issues.dlang.org/show_b

Re: Synchronisation help

2024-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 10:41:55 UTC, Anonymouse wrote: On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: [...] Thank you. Yes, `Foo` is a class for the purposes of inheritance -- I left that out of the example. So a completely valid solution is to write a struct wrap

Re: Synchronisation help

2024-01-02 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 11:05:33 UTC, user1234 wrote: Do not use `shared` AA. Use `__gshared` + sync primitives. `shared` AA will lead to all sort of bugs: - https://issues.dlang.org/show_bug.cgi?id=20484#c1 - https://issues.dlang.org/show_bug.cgi?id=17088 - https://issues.dlang.org/show_

Re: Synchronisation help

2024-01-02 Thread user1234 via Digitalmars-d-learn
On Monday, 1 January 2024 at 15:48:16 UTC, Anonymouse wrote: I have a `shared string[int]` AA that I access from two different threads. The function I spawn to start the second thread takes the AA as an argument. [...] What is the common solution here? Do I add a module-level `Object thing`

Re: Synchronisation help

2024-01-02 Thread Anonymouse via Digitalmars-d-learn
On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: [...] Thank you. Yes, `Foo` is a class for the purposes of inheritance -- I left that out of the example. So a completely valid solution is to write a struct wrapper around an AA of the type I need, overload the required ope

Re: Synchronisation help

2024-01-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 1 January 2024 at 15:48:16 UTC, Anonymouse wrote: What is the common solution here? Do I add a module-level `Object thing` and move everything accessing the AA into `synchronized(.thing)` statements? Or maybe add a `shared static` something to `Foo` and synchronise with `synchronize

Re: Synchronisation help

2024-01-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 1, 2024 8:48:16 AM MST Anonymouse via Digitalmars-d-learn wrote: > I have a `shared string[int]` AA that I access from two different > threads. The function I spawn to start the second thread takes > the AA as an argument. > > ```d > class Foo > { > shared string[int] bucke

Synchronisation help

2024-01-01 Thread Anonymouse via Digitalmars-d-learn
I have a `shared string[int]` AA that I access from two different threads. The function I spawn to start the second thread takes the AA as an argument. ```d class Foo { shared string[int] bucket; Tid worker; } void workerFn(shared string[int] bucket) { while (true) { //

Re: Request help on allocator.

2023-12-02 Thread IGotD- via Digitalmars-d-learn
On Saturday, 2 December 2023 at 19:13:18 UTC, Vino B wrote: Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this

Re: Request help on allocator.

2023-12-02 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 2 December 2023 at 19:13:18 UTC, Vino B wrote: Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this

Request help on allocator.

2023-12-02 Thread Vino B via Digitalmars-d-learn
Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this program allocate 8GB RAM when I have only 4GB of RAM installed

Re: Need help with 128bit integer ucent boolfilter

2023-10-10 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 6 October 2023 at 13:44:14 UTC, d007 wrote: I am search for a fast 128bit integer ucent boolfilter, used for server side duplicate request filter. Is 128bit boolfilter a doable thing? or it will not work or will be much more slow compare to 64 bit solution? Can you describe or gi

Need help with 128bit integer ucent boolfilter

2023-10-06 Thread d007 via Digitalmars-d-learn
I am search for a fast 128bit integer ucent boolfilter, used for server side duplicate request filter. I can seed there is https://github.com/MartinNowak/bloom, only accept size_t as key. Is there some library support 128bit integer boolfilter ? C or C++ or rust is ok for me. Is 128bit

  1   2   3   4   5   6   7   8   9   10   >