Bogdan Popa writes:

> Only dispatchers get direct access to the output port for the socket.
> If you use `dispatch/servlet', then it takes care of taking your
> `response' value and calling `output-response' on it.  Unless the server
> knows the connection should be closed and unless the request was a HEAD
> request, then it outputs the response by chunking it:
>
> https://github.com/racket/web-server/blob/547b3fd736684651e94ebd78902633374be6bcae/web-server-lib/web-server/http/response.rkt#L133-L181

I was wrong about this.  The web-server does the right thing if the
`Content-Length' header is present in the response value:

https://github.com/racket/web-server/blob/547b3fd736684651e94ebd78902633374be6bcae/web-server-lib/web-server/http/response.rkt#L120

When I change the benchmark to take advantage of that, throughput doubles:

https://www.techempower.com/benchmarks/#section=test&shareid=ab930604-6b19-4ab4-a2a5-93e674a81804&hw=ph&test=plaintext&a=2

I'll make a PR against the main repo to make sure all of the responses
have content lengths.

Out of curiosity, I made the app fork through FFI calls[1]:

https://www.techempower.com/benchmarks/#section=test&shareid=0197c25f-d544-4357-b3be-a40d4a8760ef&hw=ph&test=plaintext&a=2

This worked although multiple processes wake up when a connection can be
accepted and the IO layer doesn't seem to handle `EAGAIN':

racket: Connection error: tcp-accept: accept from listener failed
racket:   system error: Resource temporarily unavailable; errno=11
racket:   context...:
racket:    .../more-scheme.rkt:261:28
racket:    /root/.racket/7.7/pkgs/compatibility-lib/mzlib/thread.rkt:75:14: loop


[1]: 
https://gist.github.com/Bogdanp/b7b72ff7845f7f2c51e64bde553128d0#file-fork-app-rkt-L232-L256

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/m28sh5rc87.fsf%40192.168.0.142.

Reply via email to