From ac40f5d7d0babb1b93ef398f88adec1c44c187eb Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 16 Dec 2023 19:13:40 -0800 Subject: fixes #1663 Request/Reply Protocol Throughput and Scalability This eliminates the req protocols use of nni_timer (and setting a single timer node per request. This was problematic because it devolves into O(n^2) as we wind up inserting timer nodes and having to scan the list for the timer node. The solution is to use a single scan - stop worrying about insertion, but instead use a coarse granularity timer (defaults to 1 second) for retries. Then do the O(n) scan just once per interval. A new option, NNG_OPT_REQ_RESENDTICK, can be used to change the tick interval for cases (like unit tests) where more fine grained timing is required. --- src/compat/nanomsg/nn.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/compat') diff --git a/src/compat/nanomsg/nn.c b/src/compat/nanomsg/nn.c index 0f975b2d..af4db5d3 100644 --- a/src/compat/nanomsg/nn.c +++ b/src/compat/nanomsg/nn.c @@ -1144,6 +1144,13 @@ nn_setsockopt(int s, int nnlevel, int nnopt, const void *valp, size_t sz) nn_seterror(rv); return (-1); } + if ((nnlevel == NN_REQ) && (nnopt == NN_REQ_RESEND_IVL)) { + // Only one context here, so it won't be too bad to tick + // as quickly as this, and it avoids some possible friction + // (e.g. with legacy tests). + (void) nng_socket_set_ms(sid, NNG_OPT_REQ_RESENDTICK, 10); + } + return (0); } -- cgit v1.2.3-70-g09d2