digitalmars.D.learn - Benchmark Dlang vs Node vs Ruby
- llaine (9/9) May 27 2016 Hi guys,
- Vadim Lopatin (2/11) May 27 2016 Probably node and Ruby cache PGSQL connection - keeping it open.
- llaine (2/19) May 27 2016 How I'm suppose to do it ?
- llaine (3/20) May 27 2016 Okay I'll manage to do it, but still the req/sec are pretty low
- bob belcher (6/15) May 27 2016 You should know:
- Adam D. Ruppe (2/2) May 27 2016 oooh, I wanna try my libs.
- yazd (6/15) May 27 2016 The postgres library (dpq) that you're using doesn't use the
- Adam D. Ruppe (4/5) May 27 2016 So, the benchmark, the Ruby, and the JS all use the path to be
- llaine (4/9) May 27 2016 Yes it's that i'm routing to /companies to get the result, but
- Daniel Kozak (8/18) May 27 2016 Yous should enable
- llaine (7/26) May 27 2016 Hi,
- llaine (5/10) May 27 2016 All right after switching of psql client I had lower results
- yazd (4/15) May 27 2016 Your code is not doing the same thing in the benchmarks. In D,
- llaine (3/21) May 27 2016 My level of D is really slow, so can you help me to improve this?
- Rene Zwanenburg (16/18) May 27 2016 Here's an alternative getCompanies. Untested so it may contain
- Adam D. Ruppe (6/7) May 27 2016 I wrote my own web libraries starting back in ~2009ish (well
- Rene Zwanenburg (7/16) May 27 2016 Could this line be the problem?
- llaine (4/26) May 27 2016 As I said I'm sorry, my level in D is really low, so :
- Rene Zwanenburg (8/9) May 27 2016 My previous post still allocates though, through that call to
- yawniek (8/17) May 27 2016 you should:
- llaine (7/30) May 27 2016 Okay by just fixing my logic, I go up to 839.42 Req/Sec for 10
- llaine (5/23) May 27 2016 I've update my SQL dump with 100 entries and now and I have
- Daniel Kozak via Digitalmars-d-learn (4/28) May 27 2016 Why not to use distribute oprion?
- yawniek (7/11) May 28 2016 it its a flawed strategy.
Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.md
May 27 2016
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdProbably node and Ruby cache PGSQL connection - keeping it open.
May 27 2016
On Friday, 27 May 2016 at 13:54:20 UTC, Vadim Lopatin wrote:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:How I'm suppose to do it ?Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdProbably node and Ruby cache PGSQL connection - keeping it open.
May 27 2016
On Friday, 27 May 2016 at 13:54:20 UTC, Vadim Lopatin wrote:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Okay I'll manage to do it, but still the req/sec are pretty low ...Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdProbably node and Ruby cache PGSQL connection - keeping it open.
May 27 2016
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdYou should know: https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=json&l=ft4 Dlang is quite slow. I have no idea way, or how to improve it. But clear, is not that fast. Maybe for web related is slow. I'm more curious about more benchmarks :)
May 27 2016
oooh, I wanna try my libs. Where's your database dump?
May 27 2016
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdThe postgres library (dpq) that you're using doesn't use the event loop that vibe-d provides. Every call you are doing is blocking the whole server. Of course this is going to be slow. You can try using http://code.dlang.org/packages/vibe-d-postgresql.
May 27 2016
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 14:17:16 UTC, Adam D. Ruppe wrote:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Yes it's that i'm routing to /companies to get the result, but let me change the psql library delete this routing and trying again.I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 14:18:31 UTC, llaine wrote:On Friday, 27 May 2016 at 14:17:16 UTC, Adam D. Ruppe wrote:Yous should enable http://vibed.org/api/vibe.http.server/HTTPServerOption.distribute something like this: auto settings = new HTTPServerSettings; settings.port = 8080; settings.options |= HTTPServerOption.distribute; listenHTTP(settings, router);On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Yes it's that i'm routing to /companies to get the result, but let me change the psql library delete this routing and trying again.I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 14:48:19 UTC, Daniel Kozak wrote:On Friday, 27 May 2016 at 14:18:31 UTC, llaine wrote:Hi, With this option I get the same results but something interesting is displayed on the binary output : core.exception.InvalidMemoryOperationError src/core/exception.d(693): Invalid memory operation The code : https://github.com/llaine/benchmarks/blob/master/vibed/source/app.dOn Friday, 27 May 2016 at 14:17:16 UTC, Adam D. Ruppe wrote:Yous should enable http://vibed.org/api/vibe.http.server/HTTPServerOption.distribute something like this: auto settings = new HTTPServerSettings; settings.port = 8080; settings.options |= HTTPServerOption.distribute; listenHTTP(settings, router);On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Yes it's that i'm routing to /companies to get the result, but let me change the psql library delete this routing and trying again.I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 14:17:16 UTC, Adam D. Ruppe wrote:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:All right after switching of psql client I had lower results actually ... Req/Sec 22.85 for 30 seconds. What are you using to do web if you don't user Vibe.d?I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 14:46:47 UTC, llaine wrote:On Friday, 27 May 2016 at 14:17:16 UTC, Adam D. Ruppe wrote:Your code is not doing the same thing in the benchmarks. In D, you are appending 10000 companies on every request, resulting in 10000, 20000, 30000, .... companies in subsequent requests.On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:All right after switching of psql client I had lower results actually ... Req/Sec 22.85 for 30 seconds. What are you using to do web if you don't user Vibe.d?I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 14:59:44 UTC, yazd wrote:On Friday, 27 May 2016 at 14:46:47 UTC, llaine wrote:My level of D is really slow, so can you help me to improve this? :)On Friday, 27 May 2016 at 14:17:16 UTC, Adam D. Ruppe wrote:Your code is not doing the same thing in the benchmarks. In D, you are appending 10000 companies on every request, resulting in 10000, 20000, 30000, .... companies in subsequent requests.On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:All right after switching of psql client I had lower results actually ... Req/Sec 22.85 for 30 seconds. What are you using to do web if you don't user Vibe.d?I am doing something wrong ?So, the benchmark, the Ruby, and the JS all use the path to be /.... the D seems to use /companies (though I don't know vibe). Is that right?
May 27 2016
On Friday, 27 May 2016 at 15:04:31 UTC, llaine wrote:My level of D is really slow, so can you help me to improve this? :)Here's an alternative getCompanies. Untested so it may contain some mistakes. Company[] getCompanies() { auto conn = client.lockConnection(); immutable result = conn.execStatement("SELECT id, name from companies LIMIT 10000", ValueFormat.TEXT); delete conn; import std.algorithm : map; import std.array : array; return result .rangify .map!(row => Company(row["id"].as!PGtext, row["name"].as!PGtext)) .array; }
May 27 2016
On Friday, 27 May 2016 at 14:46:47 UTC, llaine wrote:What are you using to do web if you don't user Vibe.d?I wrote my own web libraries starting back in ~2009ish (well before vibe.d existed) and still use them. The modules are in here: https://github.com/adamdruppe/arsd though I don't really support it for general audiences, you're basically on your own unless you have a specific question.
May 27 2016
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdCould this line be the problem? https://github.com/llaine/benchmarks/blob/master/vibed/source/app.d#L30 You keep appending the db result to a class member, so the response size grows with every call. Additionally minimizing allocations should give a nice speed boost.
May 27 2016
On Friday, 27 May 2016 at 15:11:32 UTC, Rene Zwanenburg wrote:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:As I said I'm sorry, my level in D is really low, so : - How can I not keep appending ? - And how can I minimize allocations?Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdCould this line be the problem? https://github.com/llaine/benchmarks/blob/master/vibed/source/app.d#L30 You keep appending the db result to a class member, so the response size grows with every call. Additionally minimizing allocations should give a nice speed boost.
May 27 2016
On Friday, 27 May 2016 at 15:18:38 UTC, llaine wrote:- And how can I minimize allocations?My previous post still allocates though, through that call to array at the end. I'm not sure how to completely remove all allocations (I'm not that familiar with vibe.d), but I strongly suspect it's possible. Someone else may know how. That said, it's a an optimization which should not be necessary in the general case. Only if you're doing something where there's tight maximum latency requirements (or when doing benchmarks ^^)
May 27 2016
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdyou should: - use this https://github.com/etcimon/ddb Postgres client - fix your logic - NOT use option distribute - use LDC2 beta2 as compiler with release flag - use neweset vibe.d version and then your results should be easily above 1000 rps
May 27 2016
On Friday, 27 May 2016 at 15:32:13 UTC, yawniek wrote:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Okay by just fixing my logic, I go up to 839.42 Req/Sec for 10 sec and 601.74 Req/Sec for 30sec which is pretty impressive! My other question here is, can I specify directly in dub the compiler I want to use? Something like this : dub -compiler=ldc|dmd ... Because I really want to try to reach 1000rpsHi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdyou should: - use this https://github.com/etcimon/ddb Postgres client - fix your logic - NOT use option distribute - use LDC2 beta2 as compiler with release flag - use neweset vibe.d version and then your results should be easily above 1000 rps
May 27 2016
On Friday, 27 May 2016 at 15:48:18 UTC, llaine wrote:On Friday, 27 May 2016 at 15:32:13 UTC, yawniek wrote:I've update my SQL dump with 100 entries and now and I have better results! Pretty amazing :) If you guys want to improve it feel free to PR !!!On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Okay by just fixing my logic, I go up to 839.42 Req/Sec for 10 sec and 601.74 Req/Sec for 30sec which is pretty impressive! My other question here is, can I specify directly in dub the compiler I want to use? Something like this : dub -compiler=ldc|dmd ... Because I really want to try to reach 1000rps[...]you should: - use this https://github.com/etcimon/ddb Postgres client - fix your logic - NOT use option distribute - use LDC2 beta2 as compiler with release flag - use neweset vibe.d version and then your results should be easily above 1000 rps
May 27 2016
Why not to use distribute oprion? Dne 27. 5. 2016 17:35 napsal u=C5=BEivatel "yawniek via Digitalmars-d-learn= " < digitalmars-d-learn puremagic.com>:On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote:Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even possible ? I am doing something wrong ? Here are the numbers with the project : https://github.com/llaine/benchmarks/blob/master/README.mdyou should: - use this https://github.com/etcimon/ddb Postgres client - fix your logic - NOT use option distribute - use LDC2 beta2 as compiler with release flag - use neweset vibe.d version and then your results should be easily above 1000 rps
May 27 2016
On Friday, 27 May 2016 at 16:47:19 UTC, Daniel Kozak wrote:Why not to use distribute oprion? Dne 27. 5. 2016 17:35 napsal uživatel "yawniek via Digitalmars-d-learn" < digitalmars-d-learn puremagic.com>:it its a flawed strategy. what you should do is let the kernel handle it and use SO_ REUSEPORT libasync supports it. see e.g. https://github.com/rejectedsoftware/vibe.d/issues/1139 and https://lwn.net/Articles/542629/
May 28 2016