From 656b408655a676d770c8e5ef1030accc7653680d Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 26 Mar 2013 09:06:56 -0700 Subject: Quick hack to background gzip, real fix in testing --- src/map/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index 6470d97..af49ad4 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1846,7 +1846,7 @@ static void map_close_logfile (void) if (map_logfile) { char *filenameop_buf = (char*)malloc (strlen (map_logfile_name) + 50); - sprintf (filenameop_buf, "gzip -f %s.%ld", map_logfile_name, + sprintf (filenameop_buf, "gzip -f %s.%ld &", map_logfile_name, map_logfile_index); fclose (map_logfile); -- cgit v1.2.3-60-g2f50 From 655730e5a02a053a83fdecb053034c91377f51f7 Mon Sep 17 00:00:00 2001 From: MadCamel Date: Sat, 6 Apr 2013 15:43:21 -0400 Subject: Removed sorting of character data file. It accomplished nothing except making it look pretty, and chewed an inordinate amount of CPU. Also inlined mmo_char_tostr and set things up so players end up in tulimshar if their map save location is bad. --- src/char/char.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/char/char.cpp b/src/char/char.cpp index acb52fd..c8b3e76 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -213,7 +213,7 @@ char *search_character_name (int index) //------------------------------------------------- // Function to create the character line (for save) //------------------------------------------------- -static +__inline__ static int mmo_char_tostr (char *str, struct mmo_charstatus *p) { int i; @@ -222,7 +222,7 @@ int mmo_char_tostr (char *str, struct mmo_charstatus *p) // on multi-map server, sometimes it's posssible that last_point become void. (reason???) We check that to not lost character at restart. if (p->last_point.map[0] == '\0') { - memcpy (p->last_point.map, "prontera.gat", 16); + memcpy (p->last_point.map, "001-1.gat", 10); p->last_point.x = 273; p->last_point.y = 354; } @@ -707,26 +707,6 @@ void mmo_char_sync (void) int i, j, k; int lock; FILE *fp; - int id[char_num]; - - // Sorting before save (by [Yor]) - for (i = 0; i < char_num; i++) - { - id[i] = i; - for (j = 0; j < i; j++) - { - if ((char_dat[i].account_id < char_dat[id[j]].account_id) || - // if same account id, we sort by slot. - (char_dat[i].account_id == char_dat[id[j]].account_id && - char_dat[i].char_num < char_dat[id[j]].char_num)) - { - for (k = i; k > j; k--) - id[k] = id[k - 1]; - id[j] = i; // id[i] - break; - } - } - } // Data save fp = lock_fopen (char_txt, &lock); @@ -740,7 +720,7 @@ void mmo_char_sync (void) for (i = 0; i < char_num; i++) { // create only once the line, and save it in the 2 files (it's speeder than repeat twice the loop and create twice the line) - mmo_char_tostr (line, &char_dat[id[i]]); // use of sorted index + mmo_char_tostr (line, &char_dat[i]); // use of sorted index fprintf (fp, "%s\n", line); } fprintf (fp, "%d\t%%newid%%\n", char_id_count); @@ -762,7 +742,7 @@ void mmo_char_sync (void) for (i = 0; i < char_num; i++) { // create only once the line, and save it in the 2 files (it's speeder than repeat twice the loop and create twice the line) - mmo_char_tostr (line, &char_dat[id[i]]); // use of sorted index + mmo_char_tostr (line, &char_dat[i]); // use of sorted index fprintf (fp, "%s\n", line); } fprintf (fp, "%d\t%%newid%%\n", char_id_count); -- cgit v1.2.3-60-g2f50 From 6b83d27d53e24bfe7c37e9f7578cfec9540aae1f Mon Sep 17 00:00:00 2001 From: MadCamel Date: Sun, 7 Apr 2013 17:07:03 -0400 Subject: Enable tcp_thin socket optimizations on Linux See kernel/Documentation/networking/tcp-thin.txt These TCP optimizations were designed for the specific purpose of low latency TCP gameservers and can help reduce latency in adverse network conditions. --- src/common/socket.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/socket.cpp b/src/common/socket.cpp index cc6e4b3..e79f27a 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -117,10 +117,19 @@ static void connect_client (int listen_fd) setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); /// Send packets as soon as possible /// even if the kernel thinks there is too little for it to be worth it! - // I'm not convinced this is a good idea; although in minimizes the - // latency for an individual write, it increases traffic in general. + /// Testing shows this is indeed a good idea. setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof yes); + // Linux-ism: Set socket options to optimize for thin streams + // See http://lwn.net/Articles/308919/ and + // Documentation/networking/tcp-thin.txt .. Kernel 3.2+ +#ifdef TCP_THIN_LINEAR_TIMEOUTS + setsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, &yes, sizeof yes); +#endif +#ifdef TCP_THIN_DUPACK + setsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, &yes, sizeof yes); +#endif + FD_SET (fd, &readfds); fcntl (fd, F_SETFL, O_NONBLOCK); -- cgit v1.2.3-60-g2f50