Skip to content
Snippets Groups Projects
Commit a8f508b1 authored by Martin Karsten's avatar Martin Karsten
Browse files

- clerical updates to webserver program (max listen backlog, Go concurrency)

- bug fixes in debugging support
- make poller pthread with tight polling default
- change order of scheduling when using poller fibre
parent a1ee7c32
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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();
}
......
......@@ -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]
......
......@@ -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
......
......@@ -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()
......
......@@ -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;
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment