onion icon indicating copy to clipboard operation
onion copied to clipboard

O_ONE_LOOP (with O_POLL or O_THREADED) performs badly

Open fredrikwidlund opened this issue 10 years ago • 2 comments

See below to reproduce. Without having had a closer look it seems likely that the event driven loop is blocking on something.

$ wrk -c 512 -t 4 -d 5 http://127.0.0.1:8080 Running 5s test @ http://127.0.0.1:8080 4 threads and 512 connections Thread Stats Avg Stdev Max +/- Stdev Latency 82.24ms 166.60ms 1.04s 97.96% Req/Sec 28.03 28.14 90.00 80.00% 154 requests in 5.01s, 22.86KB read Socket errors: connect 0, read 153, write 0, timeout 7 Requests/sec: 30.75 Transfer/sec: 4.56KB $ time curl -vv 127.0.0.1:8080 # immediately after "wrk" test [...] < HTTP/1.1 200 OK < Content-Length: 0 < Content-Type: text/html < Date: Wed, 22 Jul 2015 23:38:45 UTC < Server: libonion v0.7.git170.c812b - coralbits.com <

  • Connection #0 to host 127.0.0.1 left intact

real 0m8.114s user 0m0.000s sys 0m0.007s

#include <stdint.h>

#include <onion/onion.h>
#include <onion/block.h>
#include <onion/request.h>
#include <onion/response.h>
#include <onion/static.h>

onion_connection_status r(void *data, onion_request *req, onion_response *res)
{
  return OCS_PROCESSED;
}

int main()
{
  onion *o;
  onion_url *u;

  o = onion_new(O_ONE_LOOP | O_POLL);
  u = onion_root_url(o);
  onion_url_add(u, "", (void *) (uintptr_t) r);
  onion_listen(o);
}

fredrikwidlund avatar Jul 25 '15 12:07 fredrikwidlund

Use only O_POLL. Just now although you can set them all at the same time, only one of those makes sense.

My favourite anyway is O_POOL.

Regards. On 25 Jul 2015 14:13, "Fredrik Widlund" [email protected] wrote:

See below to reproduce. Without having had a closer look it seems likely that the event driven loop is blocking on something.

$ wrk -c 512 -t 4 -d 5 http://127.0.0.1:8080 Running 5s test @ http://127.0.0.1:8080 4 threads and 512 connections Thread Stats Avg Stdev Max +/- Stdev Latency 82.24ms 166.60ms 1.04s 97.96% Req/Sec 28.03 28.14 90.00 80.00% 154 requests in 5.01s, 22.86KB read Socket errors: connect 0, read 153, write 0, timeout 7 Requests/sec: 30.75 Transfer/sec: 4.56KB $ time curl -vv 127.0.0.1:8080 # immediately after "wrk" test [...] < HTTP/1.1 200 OK < Content-Length: 0 < Content-Type: text/html < Date: Wed, 22 Jul 2015 23:38:45 UTC < Server: libonion v0.7.git170.c812b - coralbits.com <

  • Connection #0 to host 127.0.0.1 left intact

real 0m8.114s user 0m0.000s sys 0m0.007s

#include <stdint.h>

#include <onion/onion.h> #include <onion/block.h> #include <onion/request.h> #include <onion/response.h> #include <onion/static.h>

onion_connection_status r(void *data, onion_request *req, onion_response *res) { return OCS_PROCESSED; }

int main() { onion *o; onion_url *u;

o = onion_new(O_ONE_LOOP | O_POLL); u = onion_root_url(o); onion_url_add(u, "", (void *) (uintptr_t) r); onion_listen(o); }

— Reply to this email directly or view it on GitHub https://github.com/davidmoreno/onion/issues/114.

davidmoreno avatar Jul 26 '15 08:07 davidmoreno

Hm, ok. I was hoping to be able to use a event driven single threaded design to avoid having to lock on the readers.

fredrikwidlund avatar Jul 26 '15 20:07 fredrikwidlund