soegaard2
2022-6-14 13:28:46


popa.bogdanp
2022-6-14 14:47:03

Racket could do better on this benchmark through improvements to the web server (those alone would probably get it at least in the “10%” group). At the same time, some of the comparisons aren’t necessarily apples-to-apples.

For the “fortunes” benchmark, the Racket app uses x-expressions to render the HTML, which means that it has to construct a tree of x-expressions on every request then render the whole tree to HTML. The cost of both of those things adds up over many requests and many of the frameworks that do better than Racket on that particular benchmark use templating frameworks that cache/precompute a large part of the resulting HTML. Of course, we also have something like that in Racket (via scribble, include-template), but I tend to prefer xexprs so that’s what I used.

For the “queries”/postgres benchmarks, nearly all of those languages use libpq under the hood, whereas the postgres driver for Racket is written in Racket. Additionally, some of the top frameworks on that benchmark use a fork of libq that supports pipelining.

So definitely take those benchmarks w/ a grain of salt. The Racket web server’s perf. is good enough for most apps.


samth
2022-6-14 14:54:51

Does the racket/db binding need optimization? Or is it just naturally going to be a bit slower?


samth
2022-6-14 14:55:24

It would be fun to write an optimized, pre-compiled xexpr->html pipeline using macros, but probably not actually worth it for real applications


samth
2022-6-14 14:55:38

What are the web server optimizations you’re thinking of?


popa.bogdanp
2022-6-14 15:07:26

> Does the racket/db binding need optimization? Or is it just naturally going to be a bit slower? It already does surprisingly well (compare the “multiple queries” results for Racket vs some of the other frameworks with high results on “plaintext”). I just assume libpq is going to win in most cases when called from languages where C interop is cheap.

> What are the web server optimizations you’re thinking of? I don’t have anything top of mind right now, I just remember that a couple of years ago when I last looked there was room to do better even after the optimizations I made then.


popa.bogdanp
2022-6-14 15:08:51

Re. db, I actually used it to live migrate between two Postgres databases (30TiB)… on something like three separate occasions so I consider it extremely solid :smile:


ryanc
2022-6-14 17:31:51

I looked at the benchmark, and one thing I noticed is that the worlds-ref/random function would probably benefit from changing from running the select-one-world query in a loop to using the following SQL: SELECT id, randomnumber FROM worlds WHERE id =ANY ($1::integer[]) and passing a list of ids.


ryanc
2022-6-14 17:43:27

Oh, I see, the rules forbid it. Well, they specifically forbid IN, but presumably they intended to forbid =ANY also.


popa.bogdanp
2022-6-14 20:17:31

Yeah, the point of that part of the benchmark is specifically to run multiple queries per request.


hj93
2022-6-14 21:19:10

What makes a server fast? What makes the racket server faster than Django? Is it partly because Python is slower?


hj93
2022-6-14 21:21:04

Thanks for the answers/discussion


sschwarzer
2022-6-14 21:25:53

> Faster than Django and Rails :slightly_smiling_face: But slower than flask and aiohttp (two other Python HTTP frameworks/libraries). :wink:


sschwarzer
2022-6-14 21:33:19

> What makes a server fast? What makes the racket server faster than Django? Is it partly because Python is slower? I think that’s very hard to tell without careful profiling.