diff --git a/src/libfibre/EventEngine.h b/src/libfibre/EventEngine.h index dcdd7f69f340d550cfabb1f320d4291cbd42a9b7..8a5b01e434e9f76cf48b346a5fdc724d83b90997 100644 --- a/src/libfibre/EventEngine.h +++ b/src/libfibre/EventEngine.h @@ -152,7 +152,7 @@ public: template<bool Input, bool Yield, bool Lock, typename T, class... Args> T syncIO( T (*iofunc)(int, Args...), int fd, Args... a) { - GENASSERT(fd >= 0 && fd < fdcount); + GENASSERTN(fd >= 0 && fd < fdcount, fd, fdcount); SyncIO& sync = Input ? fdSyncVector[fd].RD : fdSyncVector[fd].WR; if (Yield) Fibre::yield(); if (Lock) sync.lock.acquire(); diff --git a/src/libfibre/Fibre.h b/src/libfibre/Fibre.h index 75b426a36ce7c3abc61d1108229c3dfe90d198a3..0e861a8f47794045daf191d9b015930e591509ca 100644 --- a/src/libfibre/Fibre.h +++ b/src/libfibre/Fibre.h @@ -102,15 +102,13 @@ public: : StackContext(sp), stackSize(0) { initDebug(); } // synchronize at object destruction - ~Fibre() { - join(); - clearDebug(); - } + ~Fibre() { join(); } void join() { done.wait(); } void detach() { done.detach(); } // callback from StackContext via Runtime after terminal context switch void destroy(_friend<Runtime>) { + clearDebug(); stackFree(); done.post(); } diff --git a/src/libfibre/libfibre.so-gdb.py b/src/libfibre/libfibre.so-gdb.py index ec8f23774bcd12143245dd83084b75dd27f070b2..659f04753c8d66b373ea1e4c580762c54313e412 100644 --- a/src/libfibre/libfibre.so-gdb.py +++ b/src/libfibre/libfibre.so-gdb.py @@ -9,13 +9,10 @@ class FibreSupport(): FibreSupport.list = [] FibreSupport.active = {} FibreSupport.saved = False - if (gdb.lookup_symbol("_globalStackList")[0] == None): - print() - print("WARNING: no fibre debugging support - did you enable TESTING_ENABLE_DEBUGGING?") - print() def stop_handler(event): if (gdb.lookup_symbol("_globalStackList")[0] == None): + print("WARNING: no fibre debugging support - did you enable TESTING_ENABLE_DEBUGGING?") return # save register context for later continuation FibreSupport.rsp = str(gdb.parse_and_eval("$rsp")).split(None, 1)[0] diff --git a/src/libfibre/webserver.cpp b/src/libfibre/webserver.cpp index 04a5193691db37ba51d6cf174c31a187bdaf77c7..e52a93f6cd95d32cd6b58d75a16684220032bf87 100644 --- a/src/libfibre/webserver.cpp +++ b/src/libfibre/webserver.cpp @@ -16,6 +16,7 @@ ******************************************************************************/ #include <iostream> #include <sstream> +#include <fstream> #include <string> #include <list> #include <map> @@ -93,6 +94,9 @@ static unsigned int threadCount = 1; static bool affinityFlag = false; static bool singleServerSocket = true; +// system configuration, if needed (set listen backlog to maximum value) +static int maxBacklog = -1; + // define request handler typedef void (*UrlHandler)(void* fd, const char* path, int minor_version); @@ -274,7 +278,7 @@ closeAndOut: #if defined __U_CPLUSPLUS__ static uSocketServer* create_socket() { - return new uSocketServer(8800, SOCK_STREAM, 0, 65535); + return new uSocketServer(8800, SOCK_STREAM, 0, maxBacklog); } #else @@ -302,8 +306,8 @@ static int create_socket(bool singleAccept = false) { sockaddr_in addr = { AF_INET, htons(8800), { INADDR_ANY }, { 0 } }; #endif SYSCALL(lfBind(fd, (sockaddr*)&addr, sizeof(addr))); - if (singleAccept) SYSCALL(lfListen(fd, 4)); - else SYSCALL(lfListen(fd, 16384)); + if (singleAccept) SYSCALL(lfListen(fd, 0)); + else SYSCALL(lfListen(fd, maxBacklog)); return fd; } #endif @@ -379,6 +383,12 @@ int main(int argc, char** argv) { SYSCALL(sigaction(SIGQUIT, &sa, 0)); SYSCALL(sigaction(SIGTERM, &sa, 0)); +#if __linux__ + // read max backlog setting + ifstream f("/proc/sys/net/ipv4/tcp_max_syn_backlog"); + f >> maxBacklog; +#endif + #if defined __LIBFIBRE__ || defined __U_CPLUSPLUS__ // set additional clusters and processors diff --git a/src/libfibre/webserver.go b/src/libfibre/webserver.go index e92f08c9d1116c0d1bec1c7c92870ebb68d8856d..f40098c481929126956288619cd3cae048523cad 100644 --- a/src/libfibre/webserver.go +++ b/src/libfibre/webserver.go @@ -13,7 +13,7 @@ import ( var ( clusterSize = flag.Int("c", 64, "Size of clusters (ignored)") - listenerCount = flag.Int("l", 1, "Number of listeners (ignored)") + listenerCount = flag.Int("l", 1, "Number of listeners") threadcount = flag.Int("t", 1, "Number of system threads") listenAddr = flag.String("addr", ":8800", "TCP address to listen to") ) @@ -30,8 +30,9 @@ func main() { flag.Parse() runtime.GOMAXPROCS(*threadcount) s := &fasthttp.Server{ - Handler: mainHandler, - Name: "go", + Name: "go", + Handler: mainHandler, + Concurrency: 1048576, } for i := 0; i < *listenerCount; i++ { ln := GetListener() diff --git a/src/runtime/BaseProcessor.cc b/src/runtime/BaseProcessor.cc index cb175c50d7837e2a40210258cc298f73d0efa514..c70770543ccadf4d0c29729450b6beb84aef02a1 100644 --- a/src/runtime/BaseProcessor.cc +++ b/src/runtime/BaseProcessor.cc @@ -102,8 +102,14 @@ StackContext* BaseProcessor::schedule(_friend<StackContext>) { StackContext* nextStack; if (tryDequeue(nextStack)) return nextStack; if (terminate) return idleStack; +#if TESTING_POLLER_FIBRES + if (tryBorrow(nextStack)) return nextStack; + if (tryStage(nextStack)) return nextStack; + if (trySteal(nextStack)) return nextStack; +#else if (tryStage(nextStack)) return nextStack; if (trySteal(nextStack)) return nextStack; if (tryBorrow(nextStack)) return nextStack; +#endif return idleStack; } diff --git a/src/testoptions.h b/src/testoptions.h index eaa907be16d89972c7a818717d134bfcd3647a96..77debd74bb8bcaacdbfc678fb4b6a59c39d880ed 100644 --- a/src/testoptions.h +++ b/src/testoptions.h @@ -30,8 +30,8 @@ // **** libfibre options - event handling //#define TESTING_POLLER_FIBRES 1 // vs. per-cluster poller pthread -#define TESTING_POLLER_IDLEWAIT 1 // vs. wake up poller thread anytime -#define TESTING_POLLER_IDLETIMEDWAIT 1 // vs. wait indefinitely for idle +//#define TESTING_POLLER_IDLEWAIT 1 // vs. wake up poller thread anytime +//#define TESTING_POLLER_IDLETIMEDWAIT 1 // vs. wait indefinitely for idle #define TESTING_BULK_RESUME 1 // vs. individual resume #define TESTING_LAZY_FD_REGISTRATION 1 // vs. eager registration after fd creation