Skip to content

Commit

Permalink
Setting for FrameworkBenchmarks participations
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocasazza committed Mar 6, 2015
1 parent 6d145b3 commit f5654ee
Show file tree
Hide file tree
Showing 19 changed files with 272 additions and 250 deletions.
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -32,15 +32,14 @@ The current version offers the following features :
* Support for (apache-like) log [NCSA extended/combined format](http://httpd.apache.org/docs/2.0/mod/mod_log_config.html)
* Support for [JSONRequest](http://json.org/JSONRequest.html).
* Accept HTTP uploads up to 4 GB without increasing memory usage.
* Support for upload progress via USP (ULib Servlet Page).
* General [CGI](http://it.wikipedia.org/wiki/Common_Gateway_Interface) support (run any CGI script) with automatic output compression (using gzip method).
* CGI support for shell script processes (with automatic management of form and cookie).
* CGI support for the X-Sendfile feature and also supports X-Accel-Redirect headers transparently.
* Support for minify HTML CGI output with wrapping [google page speed SDK](http://code.google.com/speed/page-speed/download.html#pagespeed-sdk).
* Support for running JavaScript code with wrapping [google V8 JavaScript Engine](http://code.google.com/apis/v8/intro.html).
* Support for minify HTML CGI output by wrapping [google page speed SDK](http://code.google.com/speed/page-speed/download.html#pagespeed-sdk).
* Support for running JavaScript code by wrapping [google V8 JavaScript Engine](http://code.google.com/apis/v8/intro.html).
* [HTTP pseudo-streaming](http://www.phpmotionwiz.com/what-is-pseudo-streaming) for FLV video managed transparently.
* [C Servlet Support](http://bellard.org/tcc/) with libtcc (if available) as a backend for dynamic code generation (experimental).
* Preforking mode to improve concurrency.
* Preforking mode to improve concurrency with dedicated process for long-time request.
* Support for Windows (without preforking).
* Customizable builds (you can remove unneeded functionality).
* Requests cut in phases for modular architecture (apache-like).
Expand Down Expand Up @@ -68,6 +67,8 @@ The current version offers the following features :
* Immune to [Slow Read DoS attack](http://code.google.com/p/slowhttptest/)
* [High SSL server quality score](https://www.ssllabs.com/ssltest/analyze.html?d=wifi-aaa.comune.fi.it)

It is the main software component of [city of Florence wireless network](http://wifi-aaa.comune.fi.it/login?mac=00%3A00%3A00%3A00%3A00%3A00&ip=172.22.11.124&redirect=http%3A//pasta.dianxinos.com/api/data&gateway=159.213.248.230%3A5280&timeout=0&token=1810300063&ap=05@159.213.248.230)

We're hoping to get included in [TechEmpower's](http://techempower.com/) [next round of benchmarks](http://www.techempower.com/benchmarks/). A pull request has been already issued.

ULib is normally built and installed as a set of shared object libraries and header files. These libraries and headers are installed using directories selected through a "configure" script that has been prepared with automake and autoconf. As such, they should build and install similarly to and in a manner compatible and consistent with most other GNU software. ULib is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Expand Down
35 changes: 17 additions & 18 deletions src/ulib/net/server/plugin/usp/db.usp
@@ -1,27 +1,17 @@
<!--#
TechEmpower Web Framework Benchmarks
Test type 2: Single database query
TechEmpower Web Framework Benchmarks
-->
<!--#declaration
#include "world.h"

#ifndef AS_cpoll_cppsp_DO
static UValue* pvalue;
#endif
static World* pworld_db;
static UOrmSession* psql_db;
static UOrmStatement* pstmt_db;

static void usp_init_db()
{
U_TRACE(5, "::usp_init_db()")

pworld_db = U_NEW(World);

#ifndef AS_cpoll_cppsp_DO
pvalue = U_NEW(UValue(OBJECT_VALUE));
static UValue* pvalue;
#endif
}

static void usp_fork_db()
{
Expand All @@ -35,8 +25,14 @@ static void usp_fork_db()

if (pstmt_db == 0) U_ERROR("usp_fork_db(): we cound't connect to db");

pworld_db = U_NEW(World);

pstmt_db->use( pworld_db->id);
pstmt_db->into(pworld_db->randomNumber);

# ifndef AS_cpoll_cppsp_DO
pvalue = U_NEW(UValue(OBJECT_VALUE));
# endif
}
}

Expand All @@ -45,13 +41,16 @@ static void usp_end_db()
{
U_TRACE(5, "::usp_end_db()")

if (pstmt_db) delete pstmt_db;
if (pstmt_db)
{
delete pstmt_db;
delete psql_db;
delete pworld_db;

delete psql_db;
delete pworld_db;
#ifndef AS_cpoll_cppsp_DO
delete pvalue;
#endif
# ifndef AS_cpoll_cppsp_DO
delete pvalue;
# endif
}
}
#endif
-->
Expand Down
27 changes: 13 additions & 14 deletions src/ulib/net/server/plugin/usp/fortune.usp
@@ -1,38 +1,34 @@
<!--#
TechEmpower Web Framework Benchmarks
Test type 4: Fortunes
TechEmpower Web Framework Benchmarks
-->
<!--#declaration
#include "fortune.h"

static UOrmSession* psql_fortune;
static UOrmStatement* pstmt_fortune;
static Fortune* pfortune;
static UString* pmessage;
static UOrmSession* psql_fortune;
static UOrmStatement* pstmt_fortune;
static UVector<Fortune*>* pvfortune;

static void usp_init_fortune()
{
U_TRACE(5, "::usp_init_fortune()")

pfortune = U_NEW(Fortune);
pvfortune = U_NEW(UVector<Fortune*>);
pmessage = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time."));
}

static void usp_fork_fortune()
{
U_TRACE(5, "::usp_fork_fortune()")

psql_fortune = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
psql_fortune = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("fortune")));

if (psql_fortune->isReady())
{
pstmt_fortune = U_NEW(UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));

if (pstmt_fortune == 0) U_ERROR("usp_fork_fortune(): we cound't connect to db");

pfortune = U_NEW(Fortune);

pstmt_fortune->into(*pfortune);

pmessage = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time."));
pvfortune = U_NEW(UVector<Fortune*>);
}
}

Expand All @@ -41,12 +37,15 @@ static void usp_end_fortune()
{
U_TRACE(5, "::usp_end_fortune()")

if (pstmt_fortune) delete pstmt_fortune;
if (pstmt_fortune)
{
delete pstmt_fortune;

delete psql_fortune;
delete pvfortune;
delete pfortune;
delete pmessage;
}
}
#endif
-->
Expand Down
2 changes: 1 addition & 1 deletion src/ulib/net/server/plugin/usp/json.usp
@@ -1,6 +1,6 @@
<!--#
TechEmpower Web Framework Benchmarks
Test type 1: JSON serialization
TechEmpower Web Framework Benchmarks
-->
<!--#declaration
#ifdef AS_cpoll_cppsp_DO
Expand Down
38 changes: 19 additions & 19 deletions src/ulib/net/server/plugin/usp/query.usp
@@ -1,44 +1,41 @@
<!--#
TechEmpower Web Framework Benchmarks
Test type 3: Multiple database queries
TechEmpower Web Framework Benchmarks
-->
<!--#declaration
#include "world.h"

#ifndef AS_cpoll_cppsp_DO
static UValue* pvalue;
#endif
static World* pworld_query;
static UOrmSession* psql_query;
static UOrmStatement* pstmt_query;
static World* pworld_query;
static UVector<World*>* pvworld_query;

static void usp_init_query()
{
U_TRACE(5, "::usp_init_query()")

pworld_query = U_NEW(World);
pvworld_query = U_NEW(UVector<World*>(500));

#ifndef AS_cpoll_cppsp_DO
pvalue = U_NEW(UValue(ARRAY_VALUE));
static UValue* pvalue;
#endif
}

static void usp_fork_query()
{
U_TRACE(5, "::usp_fork_query()")

psql_query = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
psql_query = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));

if (psql_query->isReady())
{
pstmt_query = U_NEW(UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));

if (pstmt_query == 0) U_ERROR("usp_fork_query(): we cound't connect to db");

pworld_query = U_NEW(World);

pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);

pvworld_query = U_NEW(UVector<World*>(500));

# ifndef AS_cpoll_cppsp_DO
pvalue = U_NEW(UValue(ARRAY_VALUE));
# endif
}
}

Expand All @@ -47,14 +44,17 @@ static void usp_end_query()
{
U_TRACE(5, "::usp_end_query()")

if (pstmt_query) delete pstmt_query;

delete psql_query;
if (pstmt_query)
{
delete pstmt_query;
delete psql_query;
delete pvworld_query;
delete pworld_query;
delete pworld_query;

#ifndef AS_cpoll_cppsp_DO
delete pvalue;
#endif
}
}
#endif
-->
Expand Down
48 changes: 24 additions & 24 deletions src/ulib/net/server/plugin/usp/update.usp
@@ -1,30 +1,19 @@
<!--#
TechEmpower Web Framework Benchmarks
Test type 5: Database updates
TechEmpower Web Framework Benchmarks
-->
<!--#declaration
#include "world.h"

#ifndef AS_cpoll_cppsp_DO
static UValue* pvalue;
#endif
static World* pworld_update;
static UOrmSession* psql_update;
static UOrmStatement* pstmt1;
static UOrmStatement* pstmt2;
static World* pworld_update;
static UVector<World*>* pvworld_update;

static void usp_init_update()
{
U_TRACE(5, "::usp_init_update()")

pworld_update = U_NEW(World);
pvworld_update = U_NEW(UVector<World*>(500));

#ifndef AS_cpoll_cppsp_DO
pvalue = U_NEW(UValue(ARRAY_VALUE));
static UValue* pvalue;
#endif
}

static void usp_fork_update()
{
Expand All @@ -43,9 +32,17 @@ static void usp_fork_update()
U_ERROR("usp_fork_update(): we cound't connect to db");
}

pworld_update = U_NEW(World);

pstmt1->use( pworld_update->id);
pstmt1->into(pworld_update->randomNumber);
pstmt2->use( pworld_update->randomNumber, pworld_update->id);

pvworld_update = U_NEW(UVector<World*>(500));

# ifndef AS_cpoll_cppsp_DO
pvalue = U_NEW(UValue(ARRAY_VALUE));
# endif
}
}

Expand All @@ -54,15 +51,20 @@ static void usp_end_update()
{
U_TRACE(5, "::usp_end_update()")

if (pstmt1) delete pstmt1;
if (pstmt2) delete pstmt2;
if (pstmt1 &&
pstmt2)
{
delete pstmt1;
delete pstmt2;

delete psql_update;
delete pvworld_update;
delete pworld_update;

delete psql_update;
delete pvworld_update;
delete pworld_update;
#ifndef AS_cpoll_cppsp_DO
delete pvalue;
#endif
# ifndef AS_cpoll_cppsp_DO
delete pvalue;
# endif
}
}
#endif
-->
Expand All @@ -88,8 +90,6 @@ while (true)

pstmt1->execute();

U_INTERNAL_DUMP("pworld_update->randomNumber = %u", pworld_update->randomNumber)

pworld_update->randomNumber = u_get_num_random(10000);

pstmt2->execute();
Expand Down
2 changes: 1 addition & 1 deletion src/ulib/net/server/server.cpp
Expand Up @@ -1477,7 +1477,7 @@ void UServer_Base::init()
U_INTERNAL_ASSERT_DIFFERS(ptr_shared_data, MAP_FAILED)

#ifdef ENABLE_THREAD
bool bpthread_time = (preforked_num_kids >= 8); // intuitive heuristic...
bool bpthread_time = (preforked_num_kids >= 4); // intuitive heuristic...
#else
bool bpthread_time = false;
#endif
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/FrameworkBenchmarks.sh
Expand Up @@ -20,14 +20,14 @@ rm -f /tmp/*.memusage.* \

unset ORM_DRIVER ORM_OPTION

#ORM_DRIVER="sqlite"
#ORM_OPTION="host=10.30.1.131 dbname=../db/hello_world"
ORM_DRIVER="sqlite"
ORM_OPTION="host=10.30.1.131 dbname=../db/hello_world"
#ORM_DRIVER="mysql"
#ORM_OPTION="host=10.30.1.131 user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
#ORM_DRIVER="pgsql"
#ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"

UMEMPOOL="152,85,0,37,8330,105,-17,-22,40"
UMEMPOOL="176,100,0,37,1110,105,-17,-22,40"
export ORM_DRIVER ORM_OPTION UMEMPOOL

DIR_CMD="../../examples/userver"
Expand Down
Expand Up @@ -41,7 +41,7 @@ if [ ! -f "benchmark.cfg" ]; then
cat <<EOF >benchmark.cfg
userver {
PORT 8080
PREFORK_CHILD 8
PREFORK_CHILD 4
MAX_KEEP_ALIVE 1023
LISTEN_BACKLOG 16384
CLIENT_FOR_PARALLELIZATION 256
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/benchmark/FrameworkBenchmarks/ULib/setup.sh
@@ -1,6 +1,6 @@
#!/bin/bash

export UMEMPOOL="152,85,0,37,8330,105,-17,-22,40"
export UMEMPOOL="176,100,0,37,1110,105,-17,-22,40"

# 1. Change ULib Server configuration
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
Expand Down
@@ -1,9 +1,10 @@
#!/bin/bash

export UMEMPOOL="152,85,0,37,8330,105,-17,-22,40"
export ORM_DRIVER="mysql"
export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"

export UMEMPOOL="176,100,0,37,1110,105,-17,-22,40"

# 1. Change ULib Server configuration
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg

Expand Down

0 comments on commit f5654ee

Please sign in to comment.