Browse Source

Merge pull request #1630 from stefanocasazza/master

 some tuning and add setting on prerequisites.sh for real-time priority
Mike Smith 10 years ago
parent
commit
919723dda4

+ 28 - 11
frameworks/C++/ULib/benchmark_config.json

@@ -2,8 +2,7 @@
   "framework": "ULib",
   "tests": [{
     "default": {
-      "setup_file": "setup",
-      "json_url": "/json",
+      "setup_file": "setup_plaintext",
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
@@ -20,6 +19,24 @@
       "notes": "",
       "versus": ""
     },
+    "json": {
+      "setup_file": "setup_json",
+      "json_url": "/json",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "None",
+      "framework": "ULib",
+      "language": "C++",
+      "orm": "Micro",
+      "platform": "ULib",
+      "webserver": "userver_tcp",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "ULib",
+      "notes": "",
+      "versus": ""
+    },
     "mysql": {
       "setup_file": "setup_mysql",
       "db_url": "/db",
@@ -41,15 +58,16 @@
       "notes": "",
       "versus": ""
     },
-    "sqlite": {
-      "setup_file": "setup_sqlite",
+    "postgres": {
+      "setup_file": "setup_postgres",
       "db_url": "/db",
       "query_url": "/query?queries=",
       "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
-      "database": "SQLite",
+      "database": "Postgres",
       "framework": "ULib",
       "language": "C++",
       "orm": "Micro",
@@ -57,20 +75,19 @@
       "webserver": "userver_tcp",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "ULib-sqlite",
+      "display_name": "ULib-postgres",
       "notes": "",
       "versus": ""
     },
-    "postgres": {
-      "setup_file": "setup_postgres",
+    "sqlite": {
+      "setup_file": "setup_sqlite",
       "db_url": "/db",
       "query_url": "/query?queries=",
       "fortune_url": "/fortune",
-      "update_url": "/update?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
-      "database": "Postgres",
+      "database": "SQLite",
       "framework": "ULib",
       "language": "C++",
       "orm": "Micro",
@@ -78,7 +95,7 @@
       "webserver": "userver_tcp",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "ULib-postgres",
+      "display_name": "ULib-sqlite",
       "notes": "",
       "versus": ""
     }

+ 10 - 9
frameworks/C++/ULib/install.sh

@@ -1,5 +1,6 @@
 #!/bin/bash
 
+# --------------------------------------------------------------------------------------------------------
 # install.sh
 # --------------------------------------------------------------------------------------------------------
 # toolset/run-tests.py --install server --test ULib-mysql  --type all --verbose
@@ -18,15 +19,15 @@
 
 ULIB_VERSION=1.4.2
 ULIB_ROOT=$IROOT/ULib
-ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
+ULIB_DOCUMENT_ROOT=$ULIB_ROOT/ULIB_DOCUMENT_ROOT
 
 # Check if ULib is already installed
-ULIB_INSTALLED_FILE="${IROOT}/ULib-${ULIB_VERSION}.installed"
-RETCODE=$(fw_exists ${ULIB_INSTALLED_FILE})
+ULIB_INSTALLED_FILE="$IROOT/ULib-${ULIB_VERSION}.installed"
+RETCODE=$(fw_exists $ULIB_INSTALLED_FILE)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
 # Create a run directory for ULIB
-[ ! -e ${ULIB_INSTALLED_FILE} -a -d ${IROOT}/ULib ] && rm -rf ${IROOT}/ULib*
+[ ! -e $ULIB_INSTALLED_FILE -a -d $IROOT/ULib ] && rm -rf $IROOT/ULib*
 
 if [ ! -d "$ULIB_ROOT" ]; then
   mkdir -p $ULIB_ROOT
@@ -42,9 +43,8 @@ if [ ! -f "benchmark.cfg" ]; then
 userver {
  PORT 8080
  PREFORK_CHILD 4
- MAX_KEEP_ALIVE 1023
- LISTEN_BACKLOG 16384
- CLIENT_FOR_PARALLELIZATION 256
+ TCP_LINGER_SET -1
+ LISTEN_BACKLOG 256
  ORM_DRIVER "mysql pgsql sqlite"
  DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
 }
@@ -88,10 +88,11 @@ USP_FLAGS="-DAS_cpoll_cppsp_DO" \
 #USP_LIBS="-ljson" \
 
 make install
-cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db ${ULIB_ROOT}
+cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db $ULIB_ROOT
 
 cd examples/userver
 make install
+setcap cap_sys_nice,cap_sys_resource+eip $ULIB_ROOT/bin/userver_tcp
 
 # 3. Compile usp pages for benchmark
 cd ../../src/ulib/net/server/plugin/usp
@@ -105,4 +106,4 @@ fi
 mkdir -p $ULIB_DOCUMENT_ROOT
 cp .libs/db.so .libs/fortune.so .libs/json.so .libs/plaintext.so .libs/query.so .libs/update.so $ULIB_DOCUMENT_ROOT
 
-touch ${ULIB_INSTALLED_FILE}
+touch $ULIB_INSTALLED_FILE

+ 0 - 13
frameworks/C++/ULib/setup.sh

@@ -1,13 +0,0 @@
-#!/bin/bash
-
-export ULIB_VERSION=1.4.2
-export ULIB_ROOT=$IROOT/ULib
-export ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
-
-export UMEMPOOL="136,0,0,85,1160,155,-17,-22,40"
-
-# 1. Change ULib Server configuration
-sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
-
-# 2. Start ULib Server (userver_tcp)
-${IROOT}/ULib/bin/userver_tcp -c ${IROOT}/ULib/benchmark.cfg &

+ 12 - 0
frameworks/C++/ULib/setup_json.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# 1. Change ULib Server (userver_tcp) configuration
+sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g"										$IROOT/ULib/benchmark.cfg
+sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g"								  $IROOT/ULib/benchmark.cfg
+sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g"					  $IROOT/ULib/benchmark.cfg
+sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 100|g" $IROOT/ULib/benchmark.cfg
+
+# 2. Start ULib Server (userver_tcp)
+export UMEMPOOL="56,0,0,40,150,-24,-13,-20,0"
+
+$IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

+ 7 - 9
frameworks/C++/ULib/setup_mysql.sh

@@ -1,16 +1,14 @@
 #!/bin/bash
 
-export ULIB_VERSION=1.4.2
-export ULIB_ROOT=$IROOT/ULib
-export ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
+# 1. Change ULib Server (userver_tcp) configuration
+sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g"								  $IROOT/ULib/benchmark.cfg
+sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g"								  $IROOT/ULib/benchmark.cfg
+sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g"					  $IROOT/ULib/benchmark.cfg
+sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 100|g" $IROOT/ULib/benchmark.cfg
 
+# 2. Start ULib Server (userver_tcp)
 export ORM_DRIVER="mysql"
+export UMEMPOOL="146,0,0,90,150,-22,-12,-20,0"
 export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
 
-export UMEMPOOL="136,0,0,85,1160,155,-17,-22,40"
-
-# 1. Change ULib Server configuration
-sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg
-
-# 2. Start ULib Server (userver_tcp)
 $IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

+ 12 - 0
frameworks/C++/ULib/setup_plaintext.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# 1. Change ULib Server (userver_tcp) configuration
+sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g"										$IROOT/ULib/benchmark.cfg
+sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 16384|g"								$IROOT/ULib/benchmark.cfg
+sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g"						$IROOT/ULib/benchmark.cfg
+sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 8000|g" $IROOT/ULib/benchmark.cfg
+
+# 2. Start ULib Server (userver_tcp)
+export UMEMPOOL="982,0,0,36,9846,-24,-23,1727,1151"
+
+$IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

+ 8 - 6
frameworks/C++/ULib/setup_postgres.sh

@@ -1,12 +1,14 @@
 #!/bin/bash
 
+# 1. Change ULib Server (userver_tcp) configuration
+sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g"								  $IROOT/ULib/benchmark.cfg
+sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g"								  $IROOT/ULib/benchmark.cfg
+sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g"					  $IROOT/ULib/benchmark.cfg
+sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 100|g" $IROOT/ULib/benchmark.cfg
+
+# 2. Start ULib Server (userver_tcp)
 export ORM_DRIVER="pgsql"
+export UMEMPOOL="146,0,0,90,150,-22,-12,-20,0"
 export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world client_encoding=UTF8"
 
-export UMEMPOOL="136,0,0,85,1160,155,-17,-22,40"
-
-# 1. Change ULib Server configuration
-sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg
-
-# 2. Start ULib Server (userver_tcp)
 $IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

+ 9 - 11
frameworks/C++/ULib/setup_sqlite.sh

@@ -1,16 +1,14 @@
 #!/bin/bash
 
-export ULIB_VERSION=1.4.2
-export ULIB_ROOT=$IROOT/ULib
-export ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
+# 1. Change ULib Server (userver_tcp) configuration
+sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g"									  $IROOT/ULib/benchmark.cfg
+sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g"								  $IROOT/ULib/benchmark.cfg
+sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g"					  $IROOT/ULib/benchmark.cfg
+sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 100|g" $IROOT/ULib/benchmark.cfg
 
+# 2. Start ULib Server (userver_tcp)
 export ORM_DRIVER="sqlite"
-export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=${ULIB_ROOT}/db/%.*s"
-
-export UMEMPOOL="136,0,0,85,1160,155,-17,-22,40"
+export UMEMPOOL="146,0,0,90,150,-22,-12,-20,0"
+export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=${IROOT}/ULib/db/%.*s"
 
-# 1. Change ULib Server configuration
-sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
-
-# 2. Start ULib Server (userver_tcp)
-${IROOT}/ULib/bin/userver_tcp -c ${IROOT}/ULib/benchmark.cfg &
+$IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

+ 15 - 13
frameworks/C++/ULib/src/fortune.usp

@@ -7,6 +7,7 @@ TechEmpower Web Framework Benchmarks
 
 static Fortune*           pfortune;
 static UString*           pmessage;
+static UString*           pencoded;
 static UOrmSession*       psql_fortune;
 static UOrmStatement*     pstmt_fortune;
 static UVector<Fortune*>* pvfortune;
@@ -29,6 +30,7 @@ static void usp_fork_fortune()
 
       pstmt_fortune->into(*pfortune);
 
+      pencoded  = U_NEW(UString(100U));
       pmessage  = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time."));
       pvfortune = U_NEW(UVector<Fortune*>);
       }
@@ -40,21 +42,19 @@ static void usp_end_fortune()
    U_TRACE(5, "::usp_end_fortune()")
 
    if (pstmt_fortune)
-   {
-   delete pstmt_fortune;
+      {
+      delete pstmt_fortune;
 
-   delete psql_fortune;
-   delete pvfortune;
-   delete pfortune;
-   delete pmessage;
-   }
+      delete psql_fortune;
+      delete pvfortune;
+      delete pfortune;
+      delete pmessage;
+      delete pencoded;
+      }
 }
 #endif
 -->
 <!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
-Fortune* elem;
-unsigned char encoded[1024];
-
 pstmt_fortune->execute();
 
      pvfortune->push_back(U_NEW(Fortune(0, *pmessage)));
@@ -64,14 +64,16 @@ pvfortune->sort(Fortune::cmp_obj);
 
 for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
    {
-   elem = (*pvfortune)[i];
+   Fortune* elem = (*pvfortune)[i];
+
+   UXMLEscape::encode(elem->message, *pencoded);
 
    USP_PRINTF_ADD(
       "<tr>"
       "<td>%u</td>"
-      "<td>%.*s</td>"
+      "<td>%v</td>"
       "</tr>",
-      elem->id, u_xml_encode((const unsigned char*)U_STRING_TO_PARAM(elem->message), encoded), encoded);
+      elem->id, pencoded->rep);
    }
 
 pvfortune->clear();

+ 2 - 0
toolset/setup/linux/prerequisites.sh

@@ -62,6 +62,8 @@ RETCODE=$(fw_exists ~/.bash_profile.bak)
 }
 
 sudo sh -c "echo '*               -    nofile          65535' >> /etc/security/limits.conf"
+sudo sh -c "echo '*            hard    rtprio             99' >> /etc/security/limits.conf"
+sudo sh -c "echo '*            soft    rtprio             99' >> /etc/security/limits.conf"
 
 # Sudo in case we don't have permissions on IROOT
 sudo touch fwbm_prereqs_installed