Closed waghanza closed 5 years ago
Oh, I personally find it useless. Each Crystal framework is ultra-fast and the micro-differences only depend on amount of features a framework has. Prism uses the same Radix tree implementation as others to resolve paths, so I don't think it makes any sense.
I understand you point of view, but I disagree.
Each Crystal framework is ultra-fast and the micro-differences only depend on amount of features a framework has.
If you see the results (of some other benchmarks), we notice it a difference between frameworks, and it could be interesting to display those informations :stuck_out_tongue:
Crystal itself is single-core fast, but as a server it is dreadfully slow because of the way these keep getting implemented. As the Crystal devs themselves stated, the servers need to be run one per core with REUSE socket enabled. Running them as they are in this benchmark is entirely wrong, so before more are added, the existing ones need to be fixed first.
Crystal looks like a very interesting language. However, attracting people to it on the basis of these benchmarks is counter-productive. As soon a people try doing anything beyond a trivial 'hello world' these benchmarks collapse. As an example, JSON processing in crystal is only fractionally faster than writing the data down by hand, scanning it, and sending it to the user via email :-)
The purpose of this benchmarking project is not to attract people on crystal.
The main idea is to compare tools (frameworks)
@andymans, see https://carc.in/#/r/43pg
to json 107.79k ( 9.28µs) (± 1.23%) fastest
from json 119.36k ( 8.38µs) (± 2.09%) fastest
100k+ on my 0.9Ghz machine. Multiplied by 4 cores ($2.99 on Scaleway) results in 400k+ per second. It should be more than enough for the most of applications :thinking:
Attracting people to it on the basis of these benchmarks is actually a good thing, because if another language framework sucks even with hello world, it's a reason to think of migrating to an initially faster solution :+1:
BTW, I'm finishing Crystal version of http://realworld.io and it literally kills other languages :gun:
Excellent - very much look forward to seeing the result! The realworld is a useful app specifically because it tests > 1 facet - e.g. the router, json, plus non-infrastructure items such as jwt etc. To my mind, a good score on realworld is a far more realistic yardstick of what the language can deliver.
and it literally kills other languages gun
How so in what way? I'd love to see a blog on how! :-)
@OvermindDL1 I'll definitely post a Medium article on this!
@vladfaust Awesome, ping me with the URL when it's up? :-)
@vladfaust You seems to be right. On the last test https://github.com/waghanza/which_is_the_fastest/blob/wrk/README.md#ranking-framework all crystal
frameworks seems to be very close (what is now true for other languages)
So, I'm benchmarking it on my Xiaomi Mi Air 12':
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
Thread(s) per core: 2
Core(s) per socket: 2
Model name: Intel(R) Core(TM) m3-6Y30 CPU @ 0.90GHz
CPU MHz: 500.010
CPU max MHz: 2200,0000
CPU min MHz: 400,0000
Wrk script with threads = cpu_count + 1:
printf "> Running GET /\n"
wrk -t5 -d15s -c1000 http://127.0.0.1:3000
printf "\n> Running POST /\n"
wrk -s bench/wrk/post.lua -t5 -d15s -c1000 http://127.0.0.1:3000
printf "\n> Running GET /user/42\n"
wrk -t5 -d15s -c1000 http://127.0.0.1:3000/user/42
require "prism"
struct UserAction
include Prism::Action
include Prism::Action::Params
params do
type id : Int32
end
def call
text(params[:id])
end
end
router = Prism::Router.new do
on "/", methods: %w(get post)
get "/user/:id", UserAction
end
server = Prism::Server.new([router])
server.bind_tcp(3000, reuse_port: true)
server.listen
@ v0.24.0
require "kemal"
Kemal.config do |cfg|
cfg.serve_static = false
cfg.logging = false
end
get "/" do |env|
nil
end
get "/user/:id" do |env|
env.params.url["id"]
end
post "/user" do |env|
nil
end
Kemal.config.env = "production"
Kemal.run do |cfg|
cfg.server.not_nil!.bind_tcp 3000, reuse_port: true
end
i stands for instance
1i GET / | 4i GET / | 1i POST / | 4i POST / | 1i GET /user/42 | 4i GET/user/42 | |
---|---|---|---|---|---|---|
Prism | 43.6k | 93.1k | 35.8k | 78.1k | 36.0k | 62.2k |
Kemal | 35.7k | 78.1k | 12.0k | 17.1k | 29.5k | 59.0k |
Raze | 46.2k | 91.9k | 21.5k | 30.3k | 38.1k | 62.3k |
@sdogruyol I took Kemal code from this repo, it may be outdated, can it be improved for more performance?
Edit: I took Kemal for comparison because it's the one I've had experience with, and it is "sinatra-like", just like Prism. I haven't benched other frameworks.
Edit: Added Raze.
@vladfaust Thanks for update :stuck_out_tongue: So, you say that the assertion you made
Each Crystal framework is ultra-fast and the micro-differences
is not true
btw, the results here are no ready for any conclusion ;-) the code is quite update, so thanks for yours :heart:
@andymans -This is probably the best and most to-the-point comment I have ever read on a code thread. I keep giggling every time I read it... 😆
@aichholzer the comment above is indeed very interesting, but the assumption that this project is trying to attract people in crystal community is wrong ;-)
@waghanza we should find a way to test multiple instances of Crystal servers.
@vladfaust what do you mean by multiple instances ?
ah ok, using all available cores
on each machines ... has to be implemented on each frameworks
if you have time to PR
, I'll be glad to learn
:heart: or I'll implement later :stuck_out_tongue:
https://github.com/vladfaust/prism
ping @vladfaust