Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 November 2017 at 14:28:38 UTC, kdevel wrote: On Thursday, 16 November 2017 at 19:37:31 UTC, ade90036 wrote: Can we enable some sort of profiling to see what is going on? You may compile the code with dmd -g -O -profile -profile=gc I currently struggle getting meaningful output.

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 16 November 2017 at 19:37:31 UTC, ade90036 wrote: Can we enable some sort of profiling to see what is going on? You may compile the code with dmd -g -O -profile -profile=gc I currently struggle getting meaningful output. I want to terminate the program after a number (say 400)

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
can you post both code, java and d, for sure we are all testing the sames On Thu, Nov 16, 2017 at 8:37 PM, ade90036 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > So, what is next? > > Can we enable some sort of profiling to see what is going on? >

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
So, what is next? Can we enable some sort of profiling to see what is going on?

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
Mediocre result... let me create a java equivalent program so we have a direct comparison.. These are the tests for a similar program in java. bombardier -c 200 -n 1 http://localhost:8081 Bombarding http://localhost:8081/ with 1 requests using 200 connections 1 / 1

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
Result: bombardier -c 200 -n 1 http://localhost: Bombarding http://localhost: with 1 requests using 200 connections 1 / 1 [===] 100.00% 1m24s Done!

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:44:11 UTC, Daniel Kozak wrote: It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior Ok, let me force the: "defaultPoolThreads(8)" and let me

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior On Thu, Nov 16, 2017 at 7:20 PM, Daniel Kozak wrote: > Hmm works ok for me. What OS? > > Dne 16. 11. 2017 12:05 dop.

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:20:36 UTC, Daniel Kozak wrote: Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn" : [...] I'm running MacOS..

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn" : > On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: > >> This one works ok for me, but I am on linux: >>

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread ade90036 via Digitalmars-d-learn
On Wednesday, 15 November 2017 at 23:04:46 UTC, kdevel wrote: On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: This one works ok for me, but I am on linux: https://dpaste.dzfl.pl/f54decee45bc It works, but it does not handle two connects in parallel. STR: 1. start the

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread kdevel via Digitalmars-d-learn
On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: This one works ok for me, but I am on linux: https://dpaste.dzfl.pl/f54decee45bc It works, but it does not handle two connects in parallel. STR: 1. start the binary in console 1 2. telnet localhost in console 2 3. telnet

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread kdevel via Digitalmars-d-learn
On Wednesday, 15 November 2017 at 14:22:51 UTC, Daniel Kozak wrote: And this one https://paste.ofcode.org/KNqxcrmACLZLseB45MvwC I thrash your code with two shell processes ``` while true; do curl 127.0.0.1: -o /dev/null; done ``` running parallel. Using strace -fFeclose on the binary

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread Daniel Kozak via Digitalmars-d-learn
And this one https://paste.ofcode.org/KNqxcrmACLZLseB45MvwC Here you can test if threads makes difference when compile with: dmd -O -release -version=SINGLE_THREAD xxx.d it will use only one thread when compile with: dmd -O -release xxx.d it will use thread pool On Wed, Nov 15, 2017 at

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread Daniel Kozak via Digitalmars-d-learn
This one works ok for me, but I am on linux: https://dpaste.dzfl.pl/f54decee45bc On Wed, Nov 15, 2017 at 12:46 PM, Daniel Kozak wrote: > Do not use your own taskPool, just use global taskPool proerty (import > std.parallelism: taskPool). > > You should not set blocking to

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread Daniel Kozak via Digitalmars-d-learn
Do not use your own taskPool, just use global taskPool proerty (import std.parallelism: taskPool). You should not set blocking to false. And dont use Thread here. There is no reason to do that. Just move that code into the main Dne 15. 11. 2017 12:15 odp. napsal uživatel "ade90036 via

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread ade90036 via Digitalmars-d-learn
So thanks for the suggestions, i have fixed HTTP response not postman cal also parse the headers correctly!! happy days. I have removed the duration from the Socket.select but the application seems to process a bunch or requests and then it stalls for several seconds (3/5) and then it

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread ade90036 via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 21:09:40 UTC, kdevel wrote: On Tuesday, 14 November 2017 at 19:57:54 UTC, ade90036 wrote: while(true) { listeningSet.add(listener); if (Socket.select(listeningSet, null, null, dur!"nsecs"(150)) > 0) { Why do you ever timeout?

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-14 Thread kdevel via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 19:57:54 UTC, ade90036 wrote: while(true) { listeningSet.add(listener); if (Socket.select(listeningSet, null, null, dur!"nsecs"(150)) > 0) { Why do you ever timeout? This loop consumes 100 % (a single core) when idle on my

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-14 Thread kdevel via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 19:57:54 UTC, ade90036 wrote: socket.send("HTTP/1.1 200 OK Server: dland:v2.076.1 Date: Tue, 11 Nov 2017 15:56:02 GMT

NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-14 Thread ade90036 via Digitalmars-d-learn
Hi Forum, Let's cut the chase, i'm a newby in Dlang. I have 15+ years experience in java and 7+ years experience in C++. I found D very fascinating and the sugar coated syntax very appealing to my style of coding. (groovy like) I've been trying to learn Dland and bring it thought the