1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
This commit is contained in:
stefanocasazza 2018-07-28 20:07:07 +02:00
parent b5184ba45e
commit d2421aa734
28 changed files with 1171 additions and 943 deletions

View File

@ -109,6 +109,7 @@ cleandist:
$(distdir)/src/ulib/orm/driver/.libs \ $(distdir)/src/ulib/orm/driver/.libs \
$(distdir)/src/ulib/orm/driver/Makefile \ $(distdir)/src/ulib/orm/driver/Makefile \
$(distdir)/src/ulib/orm/driver/libpq/Makefile \ $(distdir)/src/ulib/orm/driver/libpq/Makefile \
$(distdir)/src/ulib/orm/driver/libpq/libpq.la \
$(distdir)/src/ulib/net/server/plugin/*.o \ $(distdir)/src/ulib/net/server/plugin/*.o \
$(distdir)/src/ulib/net/server/plugin/*.l? \ $(distdir)/src/ulib/net/server/plugin/*.l? \
$(distdir)/src/ulib/net/server/plugin/.deps \ $(distdir)/src/ulib/net/server/plugin/.deps \

View File

@ -1032,6 +1032,7 @@ cleandist:
$(distdir)/src/ulib/orm/driver/.libs \ $(distdir)/src/ulib/orm/driver/.libs \
$(distdir)/src/ulib/orm/driver/Makefile \ $(distdir)/src/ulib/orm/driver/Makefile \
$(distdir)/src/ulib/orm/driver/libpq/Makefile \ $(distdir)/src/ulib/orm/driver/libpq/Makefile \
$(distdir)/src/ulib/orm/driver/libpq/libpq.la \
$(distdir)/src/ulib/net/server/plugin/*.o \ $(distdir)/src/ulib/net/server/plugin/*.o \
$(distdir)/src/ulib/net/server/plugin/*.l? \ $(distdir)/src/ulib/net/server/plugin/*.l? \
$(distdir)/src/ulib/net/server/plugin/.deps \ $(distdir)/src/ulib/net/server/plugin/.deps \

101
configure vendored
View File

@ -775,8 +775,6 @@ TCC_TRUE
PRG_LDFLAGS PRG_LDFLAGS
POSTGRESQL_USE_OPENSSL_FALSE POSTGRESQL_USE_OPENSSL_FALSE
POSTGRESQL_USE_OPENSSL_TRUE POSTGRESQL_USE_OPENSSL_TRUE
HAVE_PGSQL_BATCH_API_FALSE
HAVE_PGSQL_BATCH_API_TRUE
HAVE_PGSQL_FALSE HAVE_PGSQL_FALSE
HAVE_PGSQL_TRUE HAVE_PGSQL_TRUE
POSTGRESQL_LIBS POSTGRESQL_LIBS
@ -30414,14 +30412,6 @@ else
HAVE_PGSQL_FALSE= HAVE_PGSQL_FALSE=
fi fi
if false; then
HAVE_PGSQL_BATCH_API_TRUE=
HAVE_PGSQL_BATCH_API_FALSE='#'
else
HAVE_PGSQL_BATCH_API_TRUE='#'
HAVE_PGSQL_BATCH_API_FALSE=
fi
if false; then if false; then
POSTGRESQL_USE_OPENSSL_TRUE= POSTGRESQL_USE_OPENSSL_TRUE=
POSTGRESQL_USE_OPENSSL_FALSE='#' POSTGRESQL_USE_OPENSSL_FALSE='#'
@ -30443,87 +30433,6 @@ fi
$as_echo "#define USE_PGSQL 1" >>confdefs.h $as_echo "#define USE_PGSQL 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing PQenterBatchMode" >&5
$as_echo_n "checking for library containing PQenterBatchMode... " >&6; }
if ${ac_cv_search_PQenterBatchMode+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS="$LIBS"
ac_cv_search_PQenterBatchMode="no"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char PQenterBatchMode ();
int
main ()
{
return PQenterBatchMode ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_search_PQenterBatchMode="none required"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
test "$ac_cv_search_PQenterBatchMode" = "no" && for i in pq; do
LIBS="-l$i $ac_func_search_save_LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char PQenterBatchMode ();
int
main ()
{
return PQenterBatchMode ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_search_PQenterBatchMode="-l$i"
break
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
done
LIBS="$ac_func_search_save_LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_PQenterBatchMode" >&5
$as_echo "$ac_cv_search_PQenterBatchMode" >&6; }
if test "$ac_cv_search_PQenterBatchMode" != "no"; then
test "$ac_cv_search_PQenterBatchMode" = "none required" || POSTGRESQL_LIBS="$POSTGRESQL_LIBS $ac_cv_search_PQenterBatchMode"
else :
fi
if test "$ac_cv_search_PQenterBatchMode" = "yes"; then
if true; then
HAVE_PGSQL_BATCH_API_TRUE=
HAVE_PGSQL_BATCH_API_FALSE='#'
else
HAVE_PGSQL_BATCH_API_TRUE='#'
HAVE_PGSQL_BATCH_API_FALSE=
fi
$as_echo "#define USE_PGSQL_BATCH_API 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether PostgreSQL use openssl" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether PostgreSQL use openssl" >&5
$as_echo_n "checking whether PostgreSQL use openssl... " >&6; } $as_echo_n "checking whether PostgreSQL use openssl... " >&6; }
if test -n "`pg_config --configure | grep openssl`"; then if test -n "`pg_config --configure | grep openssl`"; then
@ -34142,7 +34051,7 @@ fi
CXX_MAYBE_FLAGS_MODERN="" CXX_MAYBE_FLAGS_MODERN=""
if test "$found_postgresql" = "yes"; then if test "$found_postgresql" = "yes"; then
if test "$ac_cv_search_PQenterBatchMode" = "yes"; then if test "$static_handler_pgsql" != "yes"; then
CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wc++-compat -Wold-style-definition" CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wc++-compat -Wold-style-definition"
else else
CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wno-discarded-qualifiers -Wno-switch-enum -Wno-missing-field-initializers -Wno-sign-compare -Wno-strict-aliasing \ CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wno-discarded-qualifiers -Wno-switch-enum -Wno-missing-field-initializers -Wno-sign-compare -Wno-strict-aliasing \
@ -36021,10 +35930,6 @@ if test -z "${HAVE_PGSQL_TRUE}" && test -z "${HAVE_PGSQL_FALSE}"; then
as_fn_error $? "conditional \"HAVE_PGSQL\" was never defined. as_fn_error $? "conditional \"HAVE_PGSQL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi fi
if test -z "${HAVE_PGSQL_BATCH_API_TRUE}" && test -z "${HAVE_PGSQL_BATCH_API_FALSE}"; then
as_fn_error $? "conditional \"HAVE_PGSQL_BATCH_API\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${POSTGRESQL_USE_OPENSSL_TRUE}" && test -z "${POSTGRESQL_USE_OPENSSL_FALSE}"; then if test -z "${POSTGRESQL_USE_OPENSSL_TRUE}" && test -z "${POSTGRESQL_USE_OPENSSL_FALSE}"; then
as_fn_error $? "conditional \"POSTGRESQL_USE_OPENSSL\" was never defined. as_fn_error $? "conditional \"POSTGRESQL_USE_OPENSSL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@ -36033,10 +35938,6 @@ if test -z "${HAVE_PGSQL_TRUE}" && test -z "${HAVE_PGSQL_FALSE}"; then
as_fn_error $? "conditional \"HAVE_PGSQL\" was never defined. as_fn_error $? "conditional \"HAVE_PGSQL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi fi
if test -z "${HAVE_PGSQL_BATCH_API_TRUE}" && test -z "${HAVE_PGSQL_BATCH_API_FALSE}"; then
as_fn_error $? "conditional \"HAVE_PGSQL_BATCH_API\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${POSTGRESQL_USE_OPENSSL_TRUE}" && test -z "${POSTGRESQL_USE_OPENSSL_FALSE}"; then if test -z "${POSTGRESQL_USE_OPENSSL_TRUE}" && test -z "${POSTGRESQL_USE_OPENSSL_FALSE}"; then
as_fn_error $? "conditional \"POSTGRESQL_USE_OPENSSL\" was never defined. as_fn_error $? "conditional \"POSTGRESQL_USE_OPENSSL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -1433,17 +1433,11 @@ AC_CHECK_MYSQL
AX_LIB_POSTGRESQL AX_LIB_POSTGRESQL
AM_CONDITIONAL(HAVE_PGSQL, false) AM_CONDITIONAL(HAVE_PGSQL, false)
AM_CONDITIONAL(HAVE_PGSQL_BATCH_API, false)
AM_CONDITIONAL(POSTGRESQL_USE_OPENSSL, false) AM_CONDITIONAL(POSTGRESQL_USE_OPENSSL, false)
if test "$found_postgresql" = "yes"; then if test "$found_postgresql" = "yes"; then
AM_CONDITIONAL(HAVE_PGSQL, true) AM_CONDITIONAL(HAVE_PGSQL, true)
AC_DEFINE(USE_PGSQL, 1, [Define if enable PostgreSQL database support]) AC_DEFINE(USE_PGSQL, 1, [Define if enable PostgreSQL database support])
AC_SEARCH_LIBS_VAR([PQenterBatchMode], pq, , , , POSTGRESQL_LIBS)
if test "$ac_cv_search_PQenterBatchMode" = "yes"; then
AM_CONDITIONAL(HAVE_PGSQL_BATCH_API, true)
AC_DEFINE(USE_PGSQL_BATCH_API, 1, [Define if PostgreSQL database support batch API])
fi
AC_MSG_CHECKING([whether PostgreSQL use openssl]) AC_MSG_CHECKING([whether PostgreSQL use openssl])
if test -n "`pg_config --configure | grep openssl`"; then if test -n "`pg_config --configure | grep openssl`"; then
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
@ -2424,7 +2418,7 @@ if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$OPERATINGSYSTEM" = xlinux; then
CXX_MAYBE_FLAGS_MODERN="" CXX_MAYBE_FLAGS_MODERN=""
if test "$found_postgresql" = "yes"; then if test "$found_postgresql" = "yes"; then
if test "$ac_cv_search_PQenterBatchMode" = "yes"; then if test "$static_handler_pgsql" != "yes"; then
CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wc++-compat -Wold-style-definition" CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wc++-compat -Wold-style-definition"
else else
CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wno-discarded-qualifiers -Wno-switch-enum -Wno-missing-field-initializers -Wno-sign-compare -Wno-strict-aliasing \ CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wno-discarded-qualifiers -Wno-switch-enum -Wno-missing-field-initializers -Wno-sign-compare -Wno-strict-aliasing \

View File

@ -777,9 +777,6 @@
/* Define if enable PostgreSQL database support */ /* Define if enable PostgreSQL database support */
#undef USE_PGSQL #undef USE_PGSQL
/* Define if PostgreSQL database support batch API */
#undef USE_PGSQL_BATCH_API
/* Define if enable php support */ /* Define if enable php support */
#undef USE_PHP #undef USE_PHP

View File

@ -10,11 +10,9 @@ EXTRA_DIST = base/* container/* db/* debug/* dynamic/* flex/* internal/* ldap/*
if HAVE_PGSQL if HAVE_PGSQL
if STATIC_ORM_DRIVER_PGSQL if STATIC_ORM_DRIVER_PGSQL
if !HAVE_PGSQL_BATCH_API
SUBDIRS = orm/driver/libpq SUBDIRS = orm/driver/libpq
endif endif
endif endif
endif
DEFAULT_INCLUDES = -I. -I$(top_builddir)/include DEFAULT_INCLUDES = -I. -I$(top_builddir)/include
@ -311,10 +309,8 @@ lib@ULIB@_la_LDFLAGS = @ULIB_LIBS@
if STATIC_ORM_DRIVER_PGSQL if STATIC_ORM_DRIVER_PGSQL
SRC_CPP += orm/driver/orm_driver_pgsql.cpp SRC_CPP += orm/driver/orm_driver_pgsql.cpp
if !HAVE_PGSQL_BATCH_API
lib@ULIB@_la_LDFLAGS += $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ lib@ULIB@_la_LDFLAGS += $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@
endif endif
endif
lib@ULIB@_la_LDFLAGS += -version-info 1:0:0 -release @ULIB_VERSION@ lib@ULIB@_la_LDFLAGS += -version-info 1:0:0 -release @ULIB_VERSION@

View File

@ -153,7 +153,7 @@ target_triplet = @target@
@STATIC_ORM_DRIVER_SQLITE_TRUE@am__append_63 = orm/driver/orm_driver_sqlite.cpp @STATIC_ORM_DRIVER_SQLITE_TRUE@am__append_63 = orm/driver/orm_driver_sqlite.cpp
@STATIC_ORM_DRIVER_MYSQL_TRUE@am__append_64 = orm/driver/orm_driver_mysql.cpp @STATIC_ORM_DRIVER_MYSQL_TRUE@am__append_64 = orm/driver/orm_driver_mysql.cpp
@STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_65 = orm/driver/orm_driver_pgsql.cpp @STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_65 = orm/driver/orm_driver_pgsql.cpp
@HAVE_PGSQL_BATCH_API_FALSE@@STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_66 = $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_66 = $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@
@MINGW_TRUE@am__append_67 = -export-symbols $(srcdir)/@ULIB@.def -no-undefined -Wl,ULib-win32-res.o @MINGW_TRUE@am__append_67 = -export-symbols $(srcdir)/@ULIB@.def -no-undefined -Wl,ULib-win32-res.o
# Handler static http servlet # Handler static http servlet
@ -769,7 +769,7 @@ EXTRA_DIST = base/* container/* db/* debug/* dynamic/* flex/* internal/* ldap/*
net/server/plugin/*.cpp net/server/plugin/Makefile.* \ net/server/plugin/*.cpp net/server/plugin/Makefile.* \
*.cpp all_c.c ULib.pc.in ULib.rc.in utility/bin *.cpp all_c.c ULib.pc.in ULib.rc.in utility/bin
@HAVE_PGSQL_BATCH_API_FALSE@@HAVE_PGSQL_TRUE@@STATIC_ORM_DRIVER_PGSQL_TRUE@SUBDIRS = orm/driver/libpq @HAVE_PGSQL_TRUE@@STATIC_ORM_DRIVER_PGSQL_TRUE@SUBDIRS = orm/driver/libpq
DEFAULT_INCLUDES = -I. -I$(top_builddir)/include DEFAULT_INCLUDES = -I. -I$(top_builddir)/include
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = ULib.pc pkgconfig_DATA = ULib.pc

View File

@ -39,7 +39,9 @@ void UEventDB::addClientImage(vPFpvu handlerResult, uint32_t num_query)
(void) U_SYSCALL(PQflush, "%p", (PGconn*)conn); (void) U_SYSCALL(PQflush, "%p", (PGconn*)conn);
#endif #endif
#if defined(U_SERVER_CAPTIVE_PORTAL) && defined(ENABLE_THREAD)
UClientImage_Base::setRequestProcessed(); UClientImage_Base::setRequestProcessed();
#endif
U_INTERNAL_DUMP("start = %u end = %u", start, end) U_INTERNAL_DUMP("start = %u end = %u", start, end)

View File

@ -3,6 +3,7 @@ Test type 1: JSON serialization
TechEmpower Web Framework Benchmarks TechEmpower Web Framework Benchmarks
--> -->
<!--#declaration <!--#declaration
static char* ptr;
static UString* pkey; static UString* pkey;
static UString* pvalue; static UString* pvalue;
@ -32,7 +33,7 @@ if (*pwbuffer == '\0')
u_put_unalignedp64(pwbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n')); u_put_unalignedp64(pwbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
u_put_unalignedp16(pwbuffer+52, U_MULTICHAR_CONSTANT16('\r','\n')); u_put_unalignedp16(pwbuffer+52, U_MULTICHAR_CONSTANT16('\r','\n'));
UValue::pstringify = pwbuffer + U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n"); ptr = pwbuffer + U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n");
UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n") + 27); UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n") + 27);
} }
@ -40,5 +41,7 @@ if (*pwbuffer == '\0')
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')) U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(44)), U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n')) U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(44)), U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'))
UValue::pstringify = ptr;
UValue(*pkey, *pvalue).stringify(); UValue(*pkey, *pvalue).stringify();
--> -->

View File

@ -1 +1,2 @@
loadStaticLinkedModules(U_STRING_FROM_CONSTANT("pgsql"));

View File

@ -105,12 +105,25 @@ set_ADDRESS() {
# function : prepare_usp # function : prepare_usp
prepare_usp() { prepare_usp() {
# rm -f db.la query.la update.la fortune.la cached_worlds.la \
# mdb.la mquery.la mupdate.la mfortune.la \
# rdb.la rquery.la rupdate.la rfortune.la \
# edb.la equery.la eupdate.la; \
# AM_LDFLAGS="-lWorld" make db.la query.la update.la cached_worlds.la 2>&1; \
# AM_LDFLAGS="-lWorld -lWorldNoSql" make mdb.la mquery.la mupdate.la 2>&1; \
# AM_LDFLAGS="-lWorld -lWorldNoSql" make rdb.la rquery.la rupdate.la 2>&1; \
# AM_LDFLAGS="-lWorld -lWorldNoSql" make edb.la equery.la eupdate.la 2>&1; \
# AM_LDFLAGS="-lFortune" make fortune.la 2>&1; \
# AM_LDFLAGS="-lFortune -lFortuneNoSql" make mfortune.la 2>&1; \
# AM_LDFLAGS="-lFortune -lFortuneNoSql" make rfortune.la 2>&1; \
if [ "$TERM" != "cygwin" ]; then if [ "$TERM" != "cygwin" ]; then
if [ ! -d ../db ]; then if [ ! -d ../db ]; then
mkdir -p ../db mkdir -p ../db
fi fi
rm -f ../db/session.ssl.jnl rm -f ../db/session.ssl.jnl
( cd ../../src/ulib/net/server/plugin/usp/; ./usp2so.sh >/tmp/usp2so.sh.out 2>&1 || exit 1; \ ( cd ../../src/ulib/net/server/plugin/usp/; make; \
./usp2so.sh >/tmp/usp2so.sh.out 2>&1 || exit 1; \
test -d ../.libs && cd ../.libs; \ test -d ../.libs && cd ../.libs; \
ln -sf ../v8/.libs/server_plugin_v8.so; \ ln -sf ../v8/.libs/server_plugin_v8.so; \
ln -sf ../php/.libs/server_plugin_php.so; \ ln -sf ../php/.libs/server_plugin_php.so; \

View File

@ -32,36 +32,36 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
#Running 15s test @ http://localhost:8080/plaintext #Running 15s test @ http://localhost:8080/plaintext
# 4 threads and 256 connections # 4 threads and 256 connections
# Thread Stats Avg Stdev Max +/- Stdev # Thread Stats Avg Stdev Max +/- Stdev
# Latency 0.91ms 564.97us 25.85ms 97.24% # Latency 0.91ms 208.81us 11.38ms 80.51%
# Req/Sec 615.24k 52.86k 0.90M 75.81% # Req/Sec 606.98k 39.03k 699.20k 71.14%
# Latency Distribution # Latency Distribution
# 50% 0.86ms # 50% 0.90ms
# 75% 0.95ms # 75% 1.01ms
# 90% 1.04ms # 90% 1.11ms
# 99% 1.80ms # 99% 1.76ms
# 34769232 requests in 15.00s, 4.18GB read # 34226368 requests in 14.94s, 4.11GB read
#Requests/sec: 2318061.92 #Requests/sec: 2290284.44
#Transfer/sec: 285.18MB #Transfer/sec: 281.76MB
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
# JSON # JSON
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
UMEMPOOL="237,0,0,49,273,-15,-14,-20,36" #UMEMPOOL="237,0,0,49,273,-15,-14,-20,36"
sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg #sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg #sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
#Running 15s test @ http://localhost:8080/json #Running 15s test @ http://localhost:8080/json
# 4 threads and 256 connections # 4 threads and 256 connections
# Thread Stats Avg Stdev Max +/- Stdev # Thread Stats Avg Stdev Max +/- Stdev
# Latency 404.71us 577.61us 13.07ms 98.46% # Latency 353.08us 168.28us 8.74ms 84.43%
# Req/Sec 92.85k 19.62k 174.55k 79.88% # Req/Sec 93.33k 8.35k 167.78k 68.27%
# Latency Distribution # Latency Distribution
# 50% 333.00us # 50% 327.00us
# 75% 458.00us # 75% 451.00us
# 90% 581.00us # 90% 516.00us
# 99% 1.86ms # 99% 745.00us
# 5256998 requests in 15.00s, 747.01MB read # 5280348 requests in 15.00s, 750.32MB read
#Requests/sec: 350480.62 #Requests/sec: 352026.18
#Transfer/sec: 49.80MB #Transfer/sec: 50.02MB
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
# DB # DB
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
@ -69,53 +69,67 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
#ORM_OPTION="host=localhost dbname=../db/hello_world" #ORM_OPTION="host=localhost dbname=../db/hello_world"
#ORM_DRIVER="mysql" #ORM_DRIVER="mysql"
#ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world" #ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
#ORM_DRIVER="pgsql" ORM_DRIVER="pgsql"
#ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world" ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"
#UMEMPOOL="545,0,0,49,275,-14,-13,-25,41" UMEMPOOL="581,0,0,66,16416,-7,-20,-23,31"
#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
#Running 15s test @ http://localhost:8080/fortune #Running 15s test @ http://localhost:8080/fortune
# 4 threads and 256 connections # 4 threads and 256 connections
# Thread Stats Avg Stdev Max +/- Stdev # Thread Stats Avg Stdev Max +/- Stdev
# Latency 0.97ms 444.01us 7.95ms 66.95% # Latency 5.97ms 2.42ms 16.39ms 94.85%
# Req/Sec 35.76k 4.13k 53.33k 62.05% # Req/Sec 8.63k 2.15k 11.82k 92.32%
# Latency Distribution # Latency Distribution
# 50% 0.93ms # 50% 5.21ms
# 75% 1.26ms # 75% 6.09ms
# 90% 1.56ms # 90% 6.47ms
# 99% 2.16ms # 99% 16.39ms
# 2023409 requests in 15.00s, 2.53GB read # 520090 requests in 16.00s, 674.06MB read
#Requests/sec: 134905.88 #Requests/sec: 32502.85
#Transfer/sec: 172.91MB #Transfer/sec: 42.13MB
# #
#Running 15s test @ http://localhost:8080/db #Running 15s test @ http://localhost:8080/db
# 4 threads and 256 connections # 4 threads and 256 connections
# Thread Stats Avg Stdev Max +/- Stdev # Thread Stats Avg Stdev Max +/- Stdev
# Latency 663.80us 318.91us 22.24ms 74.68% # Latency 5.59ms 1.04ms 11.43ms 78.71%
# Req/Sec 51.90k 4.80k 69.00k 76.78% # Req/Sec 9.25k 1.44k 12.09k 90.49%
# Latency Distribution # Latency Distribution
# 50% 631.00us # 50% 5.69ms
# 75% 839.00us # 75% 6.05ms
# 90% 1.04ms # 90% 6.39ms
# 99% 1.47ms # 99% 11.05ms
# 2917228 requests in 15.00s, 425.05MB read # 539816 requests in 16.01s, 78.25MB read
#Requests/sec: 194484.25 #Requests/sec: 33720.45
#Transfer/sec: 28.34MB #Transfer/sec: 4.89MB
# #
#Running 15s test @ http://localhost:8080/query?queries=20 #Running 15s test @ http://localhost:8080/query?queries=20
# 4 threads and 256 connections # 4 threads and 256 connections
# Thread Stats Avg Stdev Max +/- Stdev # Thread Stats Avg Stdev Max +/- Stdev
# Latency 2.44ms 1.20ms 32.83ms 68.96% # Latency 30.71ms 1.41ms 37.71ms 75.83%
# Req/Sec 14.40k 2.68k 24.89k 68.36% # Req/Sec 1.34k 355.28 2.00k 62.54%
# Latency Distribution # Latency Distribution
# 50% 2.31ms # 50% 30.01ms
# 75% 3.16ms # 75% 31.05ms
# 90% 4.05ms # 90% 33.01ms
# 99% 5.66ms # 99% 34.28ms
# 817586 requests in 15.00s, 592.28MB read # 59809 requests in 16.02s, 43.63MB read
#Requests/sec: 54503.98 #Requests/sec: 3734.19
#Transfer/sec: 39.48MB #Transfer/sec: 2.72MB
#
#Running 15s test @ http://localhost:8080/update?queries=20
# 4 threads and 256 connections
# Thread Stats Avg Stdev Max +/- Stdev
# Latency 979.35ms 123.76ms 1.23s 74.15%
# Req/Sec 37.42 25.76 70.00 52.78%
# Latency Distribution
# 50% 954.28ms
# 75% 1.03s
# 90% 1.23s
# 99% 1.23s
# 1263 requests in 16.01s, 0.92MB read
#Requests/sec: 78.89
#Transfer/sec: 58.70KB
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
#export REDIS_HOST=localhost #export REDIS_HOST=localhost
#UMEMPOOL="1261,0,0,49,274,-14,-15,-24,40" #UMEMPOOL="1261,0,0,49,274,-14,-15,-24,40"
@ -143,7 +157,7 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------
DIR_CMD="../../examples/userver" DIR_CMD="../../examples/userver"
prepare_usp #prepare_usp
mkdir -p $DOC_ROOT mkdir -p $DOC_ROOT
@ -151,23 +165,27 @@ mkdir -p $DOC_ROOT
# ln -sf ../../../docroot/servlet; \ # ln -sf ../../../docroot/servlet; \
# ln -sf ../../../docroot/100.html; \ # ln -sf ../../../docroot/100.html; \
# ln -sf ../../../docroot/1000.html; \ # ln -sf ../../../docroot/1000.html; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rdb.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mdb.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rupdate.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mupdate.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rquery.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mquery.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rfortune.so; \
# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mfortune.so;
# make json.la plaintext.la
#AM_LDFLAGS="-lWorld" make db.la query.la update.la cached_worlds.la
#AM_LDFLAGS="-lFortune" make fortune.la
if [ "$TERM" != "cygwin" ]; then if [ "$TERM" != "cygwin" ]; then
( cd $DOC_ROOT; rm -f *; \ ( cd $DOC_ROOT; rm -f *; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/json.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/json.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/plaintext.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/plaintext.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/db.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rdb.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mdb.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/update.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rupdate.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mupdate.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/query.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/query.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rquery.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/db.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mquery.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/update.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/fortune.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/fortune.so )
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rfortune.so; \
ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mfortune.so )
fi fi
# ---------------------------------------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1 +1 @@
0230 023E

View File

@ -5,26 +5,33 @@ TechEmpower Web Framework Benchmarks
<!--#declaration <!--#declaration
#include "world.h" #include "world.h"
#ifdef U_STATIC_ORM_DRIVER_PGSQL
static void handlerResult(void* res, uint32_t num_result)
{
U_TRACE(5, "::handlerResult(%p,%u)", res, num_result)
U_INTERNAL_ASSERT_EQUALS(num_result, 1)
U_INTERNAL_ASSERT_EQUALS(PQnfields((PGresult*)res), 1)
U_INTERNAL_ASSERT_EQUALS(PQntuples((PGresult*)res), 1)
char* randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, 0, 0);
World::handlerOneResult(ntohl(*(uint32_t*)randomNumber));
}
#endif
static void usp_init_db() { World::handlerInitSql(); }
static void usp_fork_db() { World::handlerForkSql(); } static void usp_fork_db() { World::handlerForkSql(); }
--> -->
<!--#header <!--#header
--> -->
<!--#code <!--#code
World::initOneResult();
#ifdef U_STATIC_ORM_DRIVER_PGSQL #ifdef U_STATIC_ORM_DRIVER_PGSQL
if (World::pdrv) if (World::pdrv)
{ {
PGresult* res = World::execPrepared(); World::sendQueryPrepared();
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 1) ((UEventDB*)UServer_Base::handler_db1)->addClientImage(handlerResult);
U_INTERNAL_ASSERT_EQUALS(PQntuples(res), 1)
char* randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
World::handlerOneResult(World::rnumber[0], ntohl(*(uint32_t*)randomNumber));
U_SYSCALL_VOID(PQclear, "%p", res);
} }
else else
#endif #endif
@ -33,8 +40,6 @@ World::pworld_query->id = World::rnumber[0];
(void) World::pstmt_query->execute(); (void) World::pstmt_query->execute();
World::handlerOneResult(World::pworld_query->id, World::pworld_query->randomNumber); World::handlerOneResult(World::pworld_query->randomNumber);
} }
World::endOneResult();
--> -->

View File

@ -11,11 +11,19 @@
#include <ulib/net/server/client_image.h> #include <ulib/net/server/client_image.h>
#ifdef U_STATIC_ORM_DRIVER_PGSQL #ifdef U_STATIC_ORM_DRIVER_PGSQL
# include <ulib/event/event_db.h>
# include <ulib/orm/driver/orm_driver_pgsql.h> # include <ulib/orm/driver/orm_driver_pgsql.h>
#endif #endif
class Fortune { class U_EXPORT Fortune {
public: public:
// Check for memory error
U_MEMORY_TEST
// Allocator e Deallocator
U_MEMORY_ALLOCATOR
U_MEMORY_DEALLOCATOR
uint32_t id; uint32_t id;
UString message; UString message;
@ -102,12 +110,35 @@ public:
} }
static uint32_t uid; static uint32_t uid;
static char* pwbuffer;
static UString* pmessage; static UString* pmessage;
static UVector<Fortune*>* pvfortune; static UVector<Fortune*>* pvfortune;
static UOrmSession* psql_fortune; static UOrmSession* psql_fortune;
static UOrmStatement* pstmt_fortune; static UOrmStatement* pstmt_fortune;
#ifdef U_STATIC_ORM_DRIVER_PGSQL
static PGconn* conn;
static UOrmDriverPgSql* pdrv;
static UPgSqlStatement* pstmt;
static PGresult* execPrepared()
{
U_TRACE_NO_PARAM(5, "Fortune::execPrepared()")
PGresult* res = (PGresult*) U_SYSCALL(PQexecPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 0, 0, 0, 0, 1);
U_RETURN_POINTER(res, PGresult);
}
static void sendQueryPrepared()
{
U_TRACE_NO_PARAM(5, "Fortune::sendQueryPrepared()")
(void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 0, 0, 0, 0, 1);
}
#endif
static void replace(uint32_t i, uint32_t _id, const char* msg, uint32_t len) static void replace(uint32_t i, uint32_t _id, const char* msg, uint32_t len)
{ {
U_TRACE(5, "Fortune::replace(%u,%u,%.*S,%u)", i, _id, len, msg, len) U_TRACE(5, "Fortune::replace(%u,%u,%.*S,%u)", i, _id, len, msg, len)
@ -126,41 +157,54 @@ public:
static void replace(uint32_t i, const UString& message) { replace(i, i+1, U_STRING_TO_PARAM(message)); } static void replace(uint32_t i, const UString& message) { replace(i, i+1, U_STRING_TO_PARAM(message)); }
static void replace(uint32_t i, uint32_t _id, const UString& message) { replace(i, _id, U_STRING_TO_PARAM(message)); } static void replace(uint32_t i, uint32_t _id, const UString& message) { replace(i, _id, U_STRING_TO_PARAM(message)); }
static void doQuery(vPF handlerQuery) static void initQuery()
{ {
U_TRACE(5, "Fortune::doQuery(%p)", handlerQuery) U_TRACE_NO_PARAM(5, "::initQuery()")
U_INTERNAL_ASSERT_POINTER(pvfortune) char* ptr = UClientImage_Base::wbuffer->data();
char* pwbuffer = UClientImage_Base::wbuffer->data(); U_INTERNAL_DUMP("wbuffer(%u) = %#.10S", UClientImage_Base::wbuffer->size(), ptr)
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')); if (*ptr == '\0')
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' ')); {
u_put_unalignedp64(pwbuffer+16, U_MULTICHAR_CONSTANT64('1','2','2','7','\r','\n','C','o')); u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(pwbuffer+24, U_MULTICHAR_CONSTANT64('n','t','e','n','t','-','T','y')); u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
u_put_unalignedp64(pwbuffer+32, U_MULTICHAR_CONSTANT64('p','e',':',' ','t','e','x','t')); u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('1','2','2','7','\r','\n','C','o'));
u_put_unalignedp64(pwbuffer+40, U_MULTICHAR_CONSTANT64('/','h','t','m','l',';',' ','c')); u_put_unalignedp64(ptr+24, U_MULTICHAR_CONSTANT64('n','t','e','n','t','-','T','y'));
u_put_unalignedp64(pwbuffer+48, U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U')); u_put_unalignedp64(ptr+32, U_MULTICHAR_CONSTANT64('p','e',':',' ','t','e','x','t'));
u_put_unalignedp64(pwbuffer+56, U_MULTICHAR_CONSTANT64('T','F','-','8','\r','\n','\r','\n')); u_put_unalignedp64(ptr+40, U_MULTICHAR_CONSTANT64('/','h','t','m','l',';',' ','c'));
u_put_unalignedp64(pwbuffer+64, U_MULTICHAR_CONSTANT64('<','!','d','o','c','t','y','p')); u_put_unalignedp64(ptr+48, U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U'));
u_put_unalignedp64(pwbuffer+72, U_MULTICHAR_CONSTANT64('e',' ','h','t','m','l','>','<')); u_put_unalignedp64(ptr+56, U_MULTICHAR_CONSTANT64('T','F','-','8','\r','\n','\r','\n'));
u_put_unalignedp64(pwbuffer+80, U_MULTICHAR_CONSTANT64('h','t','m','l','>','<','h','e')); u_put_unalignedp64(ptr+64, U_MULTICHAR_CONSTANT64('<','!','d','o','c','t','y','p'));
u_put_unalignedp64(pwbuffer+88, U_MULTICHAR_CONSTANT64('a','d','>','<','t','i','t','l')); u_put_unalignedp64(ptr+72, U_MULTICHAR_CONSTANT64('e',' ','h','t','m','l','>','<'));
u_put_unalignedp64(pwbuffer+96, U_MULTICHAR_CONSTANT64('e','>','F','o','r','t','u','n')); u_put_unalignedp64(ptr+80, U_MULTICHAR_CONSTANT64('h','t','m','l','>','<','h','e'));
u_put_unalignedp64(pwbuffer+104, U_MULTICHAR_CONSTANT64('e','s','<','/','t','i','t','l')); u_put_unalignedp64(ptr+88, U_MULTICHAR_CONSTANT64('a','d','>','<','t','i','t','l'));
u_put_unalignedp64(pwbuffer+112, U_MULTICHAR_CONSTANT64('e','>','<','/','h','e','a','d')); u_put_unalignedp64(ptr+96, U_MULTICHAR_CONSTANT64('e','>','F','o','r','t','u','n'));
u_put_unalignedp64(pwbuffer+120, U_MULTICHAR_CONSTANT64('>','<','b','o','d','y','>','<')); u_put_unalignedp64(ptr+104, U_MULTICHAR_CONSTANT64('e','s','<','/','t','i','t','l'));
u_put_unalignedp64(pwbuffer+128, U_MULTICHAR_CONSTANT64('t','a','b','l','e','>','<','t')); u_put_unalignedp64(ptr+112, U_MULTICHAR_CONSTANT64('e','>','<','/','h','e','a','d'));
u_put_unalignedp64(pwbuffer+136, U_MULTICHAR_CONSTANT64('r','>','<','t','h','>','i','d')); u_put_unalignedp64(ptr+120, U_MULTICHAR_CONSTANT64('>','<','b','o','d','y','>','<'));
u_put_unalignedp64(pwbuffer+144, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','t','h')); u_put_unalignedp64(ptr+128, U_MULTICHAR_CONSTANT64('t','a','b','l','e','>','<','t'));
u_put_unalignedp64(pwbuffer+152, U_MULTICHAR_CONSTANT64('>','m','e','s','s','a','g','e')); u_put_unalignedp64(ptr+136, U_MULTICHAR_CONSTANT64('r','>','<','t','h','>','i','d'));
u_put_unalignedp64(pwbuffer+160, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','/','t')); u_put_unalignedp64(ptr+144, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','t','h'));
u_put_unalignedp16(pwbuffer+168, U_MULTICHAR_CONSTANT16('r','>')); u_put_unalignedp64(ptr+152, U_MULTICHAR_CONSTANT64('>','m','e','s','s','a','g','e'));
u_put_unalignedp64(ptr+160, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','/','t'));
u_put_unalignedp16(ptr+168, U_MULTICHAR_CONSTANT16('r','>'));
pwbuffer += U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n" pwbuffer = ptr + U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n"
"<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"); "<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>");
handlerQuery(); UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n") + 1227);
}
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(48)), U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U'))
}
static void endQuery()
{
U_TRACE_NO_PARAM(5, "::endQuery()")
U_INTERNAL_ASSERT_POINTER(pvfortune)
Fortune* elem = pvfortune->last(); Fortune* elem = pvfortune->last();
@ -169,32 +213,55 @@ public:
pvfortune->sort(Fortune::cmp_obj); pvfortune->sort(Fortune::cmp_obj);
char* ptr = pwbuffer;
for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i) for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i)
{ {
elem = pvfortune->at(i); elem = pvfortune->at(i);
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>')); u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
pwbuffer = u_num2str32(elem->id, pwbuffer+8); ptr = u_num2str32(elem->id, ptr+8);
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d')); u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
pwbuffer += 8; ptr += 8;
*pwbuffer++ = '>'; *ptr++ = '>';
(void) memcpy(pwbuffer, elem->message.data(), sz = elem->message.size()); (void) memcpy(ptr, elem->message.data(), sz = elem->message.size());
pwbuffer += sz; ptr += sz;
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t')); u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>')); u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>'));
pwbuffer += 8+2; ptr += 8+2;
} }
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','a','b','l','e','>')); u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','a','b','l','e','>'));
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('<','/','b','o','d','y','>','<')); u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('<','/','b','o','d','y','>','<'));
u_put_unalignedp64(pwbuffer+16, U_MULTICHAR_CONSTANT64('/','h','t','m','l','>','\0','\0')); u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('/','h','t','m','l','>','\0','\0'));
}
UClientImage_Base::wbuffer->size_adjust_constant(pwbuffer + U_CONSTANT_SIZE("</table></body></html>")); static void doQuery(vPF handlerQuery)
{
U_TRACE(5, "Fortune::doQuery(%p)", handlerQuery)
initQuery();
handlerQuery();
endQuery();
}
static void handlerInitSql()
{
U_TRACE_NO_PARAM(5, "Fortune::handlerInitSql()")
# ifdef U_STATIC_ORM_DRIVER_PGSQL
U_INTERNAL_DUMP("UServer_Base::handler_db2 = %p", UServer_Base::handler_db2)
if (UServer_Base::handler_db2 == U_NULLPTR)
{
U_NEW_WITHOUT_CHECK_MEMORY(UEventDB, UServer_Base::handler_db2, UEventDB);
}
# endif
} }
static void handlerFork() static void handlerFork()
@ -239,9 +306,51 @@ public:
handlerFork(); handlerFork();
pstmt_fortune->into(uid, *pmessage); pstmt_fortune->into(uid, *pmessage);
# ifdef U_STATIC_ORM_DRIVER_PGSQL
if (UOrmDriver::isPGSQL())
{
conn = (PGconn*)(pdrv = (UOrmDriverPgSql*)psql_fortune->getDriver())->UOrmDriver::connection;
pstmt = (UPgSqlStatement*)pstmt_fortune->getStatement();
pstmt->prepareStatement(pdrv);
((UEventDB*)UServer_Base::handler_db2)->setConnection(conn);
}
# endif
} }
} }
#ifdef DEBUG
static void handlerEnd()
{
U_TRACE_NO_PARAM(5, "Fortune::handlerEnd()")
U_INTERNAL_ASSERT_POINTER(pmessage)
U_INTERNAL_ASSERT_POINTER(pvfortune)
U_DELETE(pmessage)
U_DELETE(pvfortune)
}
static void handlerEndSql()
{
U_TRACE_NO_PARAM(5, "Fortune::handlerEndSql()")
if (pstmt_fortune)
{
handlerEnd();
U_DELETE(psql_fortune)
U_DELETE(pstmt_fortune)
pstmt_fortune = U_NULLPTR;
}
}
const char* dump(bool breset) const;
#endif
private: private:
U_DISALLOW_ASSIGN(Fortune) U_DISALLOW_ASSIGN(Fortune)
}; };

View File

@ -5,12 +5,6 @@ TechEmpower Web Framework Benchmarks
<!--#declaration <!--#declaration
#include "fortune.h" #include "fortune.h"
static vPF handle_query;
#ifdef U_STATIC_ORM_DRIVER_PGSQL
static UOrmDriverPgSql* pdrv;
static UPgSqlStatement* pstmt;
#endif
static void handlerQuery() static void handlerQuery()
{ {
U_TRACE_NO_PARAM(5, "::handlerQuery()") U_TRACE_NO_PARAM(5, "::handlerQuery()")
@ -25,53 +19,49 @@ static void handlerQuery()
while (Fortune::pstmt_fortune->nextRow()); while (Fortune::pstmt_fortune->nextRow());
} }
static void handlerQueryPGSQL()
{
U_TRACE_NO_PARAM(5, "::handlerQueryPGSQL()")
#ifdef U_STATIC_ORM_DRIVER_PGSQL #ifdef U_STATIC_ORM_DRIVER_PGSQL
static void handlerResult(void* res, uint32_t num_result)
{
U_TRACE(5, "::handlerResult(%p,%u)", res, num_result)
U_INTERNAL_ASSERT_EQUALS(num_result, 1)
U_INTERNAL_ASSERT_EQUALS(PQnfields((PGresult*)res), 2)
int sz; int sz;
char* id; char* id;
char* ptr; char* ptr;
PGresult* res = pdrv->execPrepared(pstmt);
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 2) Fortune::initQuery();
for (uint32_t i = 0, n = U_SYSCALL(PQntuples, "%p", res); i < n; ++i) for (uint32_t i = 0, n = U_SYSCALL(PQntuples, "%p", (PGresult*)res); i < n; ++i)
{ {
id = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, i, 0); id = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 0);
ptr = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, i, 1); ptr = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 1);
sz = U_SYSCALL(PQgetlength, "%p,%d,%d", res, i, 1); sz = U_SYSCALL(PQgetlength, "%p,%d,%d", (PGresult*)res, i, 1);
Fortune::replace(i, ntohl(*(uint32_t*)id), ptr, sz); Fortune::replace(i, ntohl(*(uint32_t*)id), ptr, sz);
} }
U_SYSCALL_VOID(PQclear, "%p", res); Fortune::endQuery();
}
#endif #endif
}
static void usp_fork_fortune() static void usp_init_fortune() { Fortune::handlerInitSql(); }
{ static void usp_fork_fortune() { Fortune::handlerForkSql(); }
U_TRACE_NO_PARAM(5, "::usp_fork_fortune()")
Fortune::handlerForkSql();
if (UOrmDriver::isPGSQL() == false) handle_query = handlerQuery;
else
{
handle_query = handlerQueryPGSQL;
# ifdef U_STATIC_ORM_DRIVER_PGSQL
pdrv = (UOrmDriverPgSql*) Fortune::psql_fortune->getDriver();
pstmt = (UPgSqlStatement*) Fortune::pstmt_fortune->getStatement();
pstmt->prepareStatement(pdrv);
# endif
}
}
--> -->
<!--#header <!--#header
--> -->
<!--#code <!--#code
Fortune::doQuery(handle_query); #ifdef U_STATIC_ORM_DRIVER_PGSQL
if (Fortune::pdrv)
{
Fortune::sendQueryPrepared();
((UEventDB*)UServer_Base::handler_db2)->addClientImage(handlerResult);
}
else
#endif
{
Fortune::doQuery(handlerQuery);
}
--> -->

View File

@ -12,7 +12,7 @@
# include <ulib/net/client/mongodb.h> # include <ulib/net/client/mongodb.h>
#endif #endif
class FortuneNoSql { class U_EXPORT FortuneNoSql {
public: public:
#ifdef USE_MONGODB #ifdef USE_MONGODB
@ -109,6 +109,38 @@ public:
} }
} }
#ifdef DEBUG
static void handlerEndMongoDB()
{
U_TRACE_NO_PARAM(5, "FortuneNoSql::handlerEndMongoDB()")
# ifdef USE_MONGODB
if (mc)
{
Fortune::handlerEnd();
U_DELETE(mc)
mc = U_NULLPTR;
}
# endif
}
static void handlerEndREDIS()
{
U_TRACE_NO_PARAM(5, "FortuneNoSql::handlerEndREDIS()")
if (rc)
{
Fortune::handlerEnd();
U_DELETE(rc)
rc = U_NULLPTR;
}
}
#endif
private: private:
U_DISALLOW_ASSIGN(FortuneNoSql) U_DISALLOW_ASSIGN(FortuneNoSql)
}; };

View File

@ -3,6 +3,7 @@ Test type 1: JSON serialization
TechEmpower Web Framework Benchmarks TechEmpower Web Framework Benchmarks
--> -->
<!--#declaration <!--#declaration
static char* ptr;
static UString* pkey; static UString* pkey;
static UString* pvalue; static UString* pvalue;
@ -19,6 +20,10 @@ static void usp_init_json()
<!--#code <!--#code
char* pwbuffer = UClientImage_Base::wbuffer->data(); char* pwbuffer = UClientImage_Base::wbuffer->data();
U_INTERNAL_DUMP("pwbuffer = %#.10S", pwbuffer)
if (*pwbuffer == '\0')
{
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')); u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' ')); u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
u_put_unalignedp32(pwbuffer+16, U_MULTICHAR_CONSTANT32('2','7','\r','\n')); u_put_unalignedp32(pwbuffer+16, U_MULTICHAR_CONSTANT32('2','7','\r','\n'));
@ -28,9 +33,15 @@ u_put_unalignedp64(pwbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','
u_put_unalignedp64(pwbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n')); u_put_unalignedp64(pwbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
u_put_unalignedp16(pwbuffer+52, U_MULTICHAR_CONSTANT16('\r','\n')); u_put_unalignedp16(pwbuffer+52, U_MULTICHAR_CONSTANT16('\r','\n'));
UValue::pstringify = pwbuffer + U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n"); ptr = pwbuffer + U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n");
UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n") + 27);
}
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(44)), U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'))
UValue::pstringify = ptr;
UValue(*pkey, *pvalue).stringify(); UValue(*pkey, *pvalue).stringify();
UClientImage_Base::wbuffer->size_adjust_constant(UValue::pstringify);
--> -->

View File

@ -2,8 +2,31 @@
#include "fortune.h" #include "fortune.h"
char* Fortune::pwbuffer;
uint32_t Fortune::uid; uint32_t Fortune::uid;
UString* Fortune::pmessage; UString* Fortune::pmessage;
UOrmSession* Fortune::psql_fortune; UOrmSession* Fortune::psql_fortune;
UOrmStatement* Fortune::pstmt_fortune; UOrmStatement* Fortune::pstmt_fortune;
UVector<Fortune*>* Fortune::pvfortune; UVector<Fortune*>* Fortune::pvfortune;
#ifdef U_STATIC_ORM_DRIVER_PGSQL
PGconn* Fortune::conn;
UOrmDriverPgSql* Fortune::pdrv;
UPgSqlStatement* Fortune::pstmt;
#endif
#ifdef DEBUG
const char* Fortune::dump(bool breset) const
{
*UObjectIO::os << "id " << id << '\n'
<< "message (UString " << (void*)&message << ')';
if (breset)
{
UObjectIO::output();
return UObjectIO::buffer_output;
}
return U_NULLPTR;
}
#endif

View File

@ -3,10 +3,11 @@
#include "world.h" #include "world.h"
char World::wbuffer[18000]; char World::wbuffer[18000];
char* World::ptr;
char* World::pwbuffer; char* World::pwbuffer;
World* World::pworld_query; World* World::pworld_query;
uint32_t World::rnum; uint32_t World::rnum;
uint32_t World::rnumber[500]; uint32_t World::rnumber[501];
UOrmSession* World::psql_query; UOrmSession* World::psql_query;
UOrmStatement* World::pstmt_query; UOrmStatement* World::pstmt_query;
#ifdef U_STATIC_ORM_DRIVER_PGSQL #ifdef U_STATIC_ORM_DRIVER_PGSQL
@ -15,3 +16,20 @@ PGconn* World::conn;
UOrmDriverPgSql* World::pdrv; UOrmDriverPgSql* World::pdrv;
UPgSqlStatement* World::pstmt; UPgSqlStatement* World::pstmt;
#endif #endif
#ifdef DEBUG
const char* World::dump(bool breset) const
{
*UObjectIO::os << "id " << id << '\n'
<< "randomNumber " << randomNumber;
if (breset)
{
UObjectIO::output();
return UObjectIO::buffer_output;
}
return U_NULLPTR;
}
#endif

View File

@ -1 +1,18 @@
Hello, World! <!--#header
-->
<!--#code
char* pwbuffer = UClientImage_Base::wbuffer->data();
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
u_put_unalignedp32(pwbuffer+16, U_MULTICHAR_CONSTANT32('1','3','\r','\n'));
u_put_unalignedp64(pwbuffer+20, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(pwbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','t','e'));
u_put_unalignedp64(pwbuffer+36, U_MULTICHAR_CONSTANT64('x','t','/','p','l','a','i','n'));
u_put_unalignedp32(pwbuffer+44, U_MULTICHAR_CONSTANT32('\r','\n','\r','\n'));
UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 13\r\nContent-Type: text/plain\r\n\r\n") + 13);
u_put_unalignedp64(pwbuffer+48, U_MULTICHAR_CONSTANT64('H','e','l','l','o',',',' ','W'));
u_put_unalignedp64(pwbuffer+56, U_MULTICHAR_CONSTANT64('o','r','l','d','!','\0','\0','\0'));
-->

View File

@ -5,6 +5,7 @@ TechEmpower Web Framework Benchmarks
<!--#declaration <!--#declaration
#include "world.h" #include "world.h"
static void usp_init_query() { World::handlerInitSql(); }
static void usp_fork_query() { World::handlerForkSql(); } static void usp_fork_query() { World::handlerForkSql(); }
--> -->
<!--#header <!--#header
@ -29,7 +30,7 @@ if (World::pdrv)
randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0); randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
World::handlerResult(World::rnumber[i], ntohl(*(uint32_t*)randomNumber)); World::handlerResult(i, ntohl(*(uint32_t*)randomNumber));
U_SYSCALL_VOID(PQclear, "%p", res); U_SYSCALL_VOID(PQclear, "%p", res);
} }
@ -43,7 +44,7 @@ for (; i < num_queries; ++i)
World::pstmt_query->execute(); World::pstmt_query->execute();
World::handlerResultSql(i); World::handlerResult(i, World::pworld_query->randomNumber);
} }
} }

View File

@ -10,6 +10,7 @@ static char query[8192];
#endif #endif
static UOrmStatement* pstmt_update; static UOrmStatement* pstmt_update;
static void usp_init_update() { World::handlerInitSql(); }
static void usp_fork_update() static void usp_fork_update()
{ {
U_TRACE(5, "::usp_fork_update()") U_TRACE(5, "::usp_fork_update()")
@ -63,7 +64,7 @@ if (World::pdrv)
u_put_unalignedp16(pquery, U_MULTICHAR_CONSTANT16(')',',')); u_put_unalignedp16(pquery, U_MULTICHAR_CONSTANT16(')',','));
pquery += 2; pquery += 2;
World::handlerResult(World::rnumber[i], World::rnum); World::handlerResult(i, World::rnum);
U_SYSCALL_VOID(PQclear, "%p", res); U_SYSCALL_VOID(PQclear, "%p", res);
} }
@ -92,7 +93,7 @@ for (; i < num_queries; ++i)
pstmt_update->execute(); pstmt_update->execute();
World::handlerResultSql(i); World::handlerResult(i, World::pworld_query->randomNumber);
} }
World::endResult(); World::endResult();

View File

@ -10,11 +10,19 @@
#include <ulib/net/server/client_image.h> #include <ulib/net/server/client_image.h>
#ifdef U_STATIC_ORM_DRIVER_PGSQL #ifdef U_STATIC_ORM_DRIVER_PGSQL
# include <ulib/event/event_db.h>
# include <ulib/orm/driver/orm_driver_pgsql.h> # include <ulib/orm/driver/orm_driver_pgsql.h>
#endif #endif
class World { class U_EXPORT World {
public: public:
// Check for memory error
U_MEMORY_TEST
// Allocator e Deallocator
U_MEMORY_ALLOCATOR
U_MEMORY_DEALLOCATOR
uint32_t id, randomNumber; uint32_t id, randomNumber;
World() World()
@ -104,9 +112,10 @@ public:
# endif # endif
} }
static char* ptr;
static char* pwbuffer; static char* pwbuffer;
static char wbuffer[18000]; static char wbuffer[18000];
static uint32_t rnum, rnumber[500]; static uint32_t rnum, rnumber[501];
static World* pworld_query; static World* pworld_query;
static UOrmSession* psql_query; static UOrmSession* psql_query;
@ -118,21 +127,6 @@ public:
static UPgSqlStatement* pstmt; static UPgSqlStatement* pstmt;
static char num2str[sizeof(unsigned int)]; static char num2str[sizeof(unsigned int)];
static bool initPipeline()
{
U_TRACE(5, "World::initPipeline()")
if (pdrv)
{
(void) U_SYSCALL(PQsetnonblocking, "%p,%u", conn, 1);
(void) U_SYSCALL(PQenterBatchMode, "%p", conn);
U_RETURN(true);
}
U_RETURN(false);
}
static PGresult* execPrepared() static PGresult* execPrepared()
{ {
U_TRACE_NO_PARAM(5, "World::execPrepared()") U_TRACE_NO_PARAM(5, "World::execPrepared()")
@ -159,6 +153,17 @@ public:
U_RETURN_POINTER(res, PGresult); U_RETURN_POINTER(res, PGresult);
} }
static void sendQueryPrepared()
{
U_TRACE_NO_PARAM(5, "World::sendQueryPrepared()")
U_INTERNAL_ASSERT_MAJOR(rnumber[0], 0)
*(unsigned int*)num2str = htonl(rnumber[0]);
(void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1);
}
static void sendQueryPrepared(uint32_t i) static void sendQueryPrepared(uint32_t i)
{ {
U_TRACE(5, "World::sendQueryPrepared(%u)", i) U_TRACE(5, "World::sendQueryPrepared(%u)", i)
@ -167,46 +172,25 @@ public:
*(unsigned int*)num2str = htonl(rnumber[i]); *(unsigned int*)num2str = htonl(rnumber[i]);
# ifdef DEBUG
if (U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1) == 0)
{
pdrv->printError(__PRETTY_FUNCTION__);
}
# else
(void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1); (void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1);
# endif
} }
#endif #endif
static void initResult()
{
U_TRACE(5, "World::initResult()")
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
u_put_unalignedp64(wbuffer+16, U_MULTICHAR_CONSTANT64('1','3','3','3','1','\r','\n','C'));
u_put_unalignedp64(wbuffer+24, U_MULTICHAR_CONSTANT64('o','n','t','e','n','t','-','T'));
u_put_unalignedp64(wbuffer+32, U_MULTICHAR_CONSTANT64('y','p','e',':',' ','a','p','p'));
u_put_unalignedp64(wbuffer+40, U_MULTICHAR_CONSTANT64('l','i','c','a','t','i','o','n'));
u_put_unalignedp64(wbuffer+48, U_MULTICHAR_CONSTANT64('/','j','s','o','n','\r','\n','\r'));
u_put_unalignedp16(wbuffer+56, U_MULTICHAR_CONSTANT16('\n','['));
pwbuffer = wbuffer + U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n[");
}
static void endResult()
{
U_TRACE_NO_PARAM(5, "World::endResult()")
*(pwbuffer-1) = ']';
uint32_t len = pwbuffer-wbuffer,
body_len = len - U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n");
pwbuffer = u_num2str32(body_len, wbuffer + U_CONSTANT_SIZE("Content-Length: "));
while (*pwbuffer != '\r') *pwbuffer++ = ' ';
UClientImage_Base::wbuffer->setConstant(wbuffer, len);
}
static void initOneResult() static void initOneResult()
{ {
U_TRACE(5, "World::initOneResult()") U_TRACE_NO_PARAM(5, "World::initOneResult()")
U_INTERNAL_DUMP("wbuffer = %#.10S", wbuffer)
if (*wbuffer == '\0')
{
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')); u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' ')); u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
u_put_unalignedp32(wbuffer+16, U_MULTICHAR_CONSTANT32('3','1','\r','\n')); u_put_unalignedp32(wbuffer+16, U_MULTICHAR_CONSTANT32('3','1','\r','\n'));
@ -214,75 +198,120 @@ public:
u_put_unalignedp64(wbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','a','p')); u_put_unalignedp64(wbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','a','p'));
u_put_unalignedp64(wbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','i','o')); u_put_unalignedp64(wbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','i','o'));
u_put_unalignedp64(wbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n')); u_put_unalignedp64(wbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
u_put_unalignedp32(wbuffer+52, U_MULTICHAR_CONSTANT32('\r','\n','{','\0')); u_put_unalignedp64(wbuffer+52, U_MULTICHAR_CONSTANT64('\r','\n','{','"','i','d','"',':'));
pwbuffer = wbuffer + U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n{"); pwbuffer = u_num2str32(rnumber[0], wbuffer + U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n{\"id\":"));
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
}
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer+52), U_MULTICHAR_CONSTANT64('\r','\n','{','"','i','d','"',':'))
} }
static void endOneResult() static void endOneResult()
{ {
U_TRACE_NO_PARAM(5, "World::endOneResult()") U_TRACE_NO_PARAM(5, "World::endOneResult()")
*pwbuffer = '}'; *ptr = '}';
uint32_t len = pwbuffer-wbuffer+1, uint32_t len = ptr-wbuffer+1,
body_len = len - U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n"); body_len = len - U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n");
(void) u_num2str32(body_len, wbuffer+U_CONSTANT_SIZE("Content-Length: ")); U_NUM2STR16(wbuffer+U_CONSTANT_SIZE("Content-Length: "), body_len);
UClientImage_Base::wbuffer->setConstant(wbuffer, len); UClientImage_Base::wbuffer->setConstant(wbuffer, len);
} }
static void handlerOneResult(uint32_t uid, uint32_t random) static void handlerOneResult(uint32_t random)
{ {
U_TRACE(5, "World::handlerOneResult(%u,%u)", uid, random) U_TRACE(5, "World::handlerOneResult(%u)", random)
u_put_unalignedp32(pwbuffer, U_MULTICHAR_CONSTANT32('"','i','d','"')); initOneResult();
pwbuffer[4] = ':'; ptr = u_num2str32(random, pwbuffer+16);
pwbuffer = u_num2str32(uid, pwbuffer+5); endOneResult();
}
static void initResult()
{
U_TRACE_NO_PARAM(5, "World::initResult()")
U_INTERNAL_DUMP("wbuffer = %#.10S", wbuffer)
if (*wbuffer == '\0')
{
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
u_put_unalignedp64(wbuffer+16, U_MULTICHAR_CONSTANT64('1','3','3','3','1','\r','\n','C'));
u_put_unalignedp64(wbuffer+24, U_MULTICHAR_CONSTANT64('o','n','t','e','n','t','-','T'));
u_put_unalignedp64(wbuffer+32, U_MULTICHAR_CONSTANT64('y','p','e',':',' ','a','p','p'));
u_put_unalignedp64(wbuffer+40, U_MULTICHAR_CONSTANT64('l','i','c','a','t','i','o','n'));
u_put_unalignedp64(wbuffer+48, U_MULTICHAR_CONSTANT64('/','j','s','o','n','\r','\n','\r'));
u_put_unalignedp64(wbuffer+56, U_MULTICHAR_CONSTANT64('\n','[','{','"','i','d','"',':'));
pwbuffer = u_num2str32(rnumber[0], wbuffer + U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n[{\"id\":"));
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m')); u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':')); u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
pwbuffer = u_num2str32(random, pwbuffer+16);
} }
static void handlerResult(uint32_t uid, uint32_t random) U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
{ U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer+56), U_MULTICHAR_CONSTANT64('\n','[','{','"','i','d','"',':'))
U_TRACE(5, "World::handlerResult(%u,%u)", uid, random)
u_put_unalignedp32(pwbuffer, U_MULTICHAR_CONSTANT32('{','"','i','d')); ptr = pwbuffer;
u_put_unalignedp16(pwbuffer+4, U_MULTICHAR_CONSTANT16('"',':'));
pwbuffer = u_num2str32(uid, pwbuffer+6);
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
pwbuffer = u_num2str32(random, pwbuffer+16);
u_put_unalignedp16(pwbuffer, U_MULTICHAR_CONSTANT16('}',','));
pwbuffer += 2;
} }
static void handlerResult(uint32_t i) static void endResult()
{ {
U_TRACE(5, "World::handlerResult(%u)", i) U_TRACE_NO_PARAM(5, "World::endResult()")
U_INTERNAL_ASSERT_POINTER(pworld_query) *(ptr-1) = ']';
U_INTERNAL_DUMP("pworld_query->randomNumber = %u", pworld_query->randomNumber) uint32_t len = ptr-wbuffer,
body_len = len - U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n");
ptr = u_num2str32(body_len, wbuffer + U_CONSTANT_SIZE("Content-Length: "));
while (*ptr != '\r') *ptr++ = ' ';
UClientImage_Base::wbuffer->setConstant(wbuffer, len);
} }
static void handlerResultSql(uint32_t i) static void addResult(uint32_t i)
{ {
U_TRACE(5, "World::handlerResultSql(%u)", i) U_TRACE(5, "World::addResult(%u)", i)
U_INTERNAL_ASSERT_POINTER(pworld_query) U_INTERNAL_ASSERT_MAJOR(i, 0)
handlerResult(rnumber[i], pworld_query->randomNumber); u_put_unalignedp32(ptr, U_MULTICHAR_CONSTANT32('{','"','i','d'));
u_put_unalignedp16(ptr+4, U_MULTICHAR_CONSTANT16('"',':'));
ptr = u_num2str32(rnumber[i], ptr+6);
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
}
static void addRandom(uint32_t random)
{
U_TRACE(5, "World::addRandom(%u)", random)
ptr = u_num2str32(random, ptr+16);
u_put_unalignedp16(ptr, U_MULTICHAR_CONSTANT16('}',','));
ptr += 2;
}
static void handlerResult(uint32_t i, uint32_t random)
{
U_TRACE(5, "World::handlerResult(%u,%u)", i, random)
if (i) addResult(i);
addRandom(random);
} }
static void doUpdateNoSql(vPFu handlerUpdateNoSql) static void doUpdateNoSql(vPFu handlerUpdateNoSql)
@ -295,17 +324,31 @@ public:
{ {
handlerUpdateNoSql(i); handlerUpdateNoSql(i);
handlerResult(rnumber[i], rnum); handlerResult(i, rnum);
} }
endResult(); endResult();
} }
static void handlerInitSql()
{
U_TRACE_NO_PARAM(5, "World::handlerInitSql()")
# ifdef U_STATIC_ORM_DRIVER_PGSQL
U_INTERNAL_DUMP("UServer_Base::handler_db1 = %p", UServer_Base::handler_db1)
if (UServer_Base::handler_db1 == U_NULLPTR)
{
U_NEW_WITHOUT_CHECK_MEMORY(UEventDB, UServer_Base::handler_db1, UEventDB);
}
# endif
}
static void handlerFork() static void handlerFork()
{ {
U_TRACE_NO_PARAM(5, "World::handlerFork()") U_TRACE_NO_PARAM(5, "World::handlerFork()")
if (rnumber[0] == 0) for (uint32_t i = 0; i < 500; ++i) rnumber[i] = u_get_num_random_range1(10000); if (rnumber[0] == 0) for (uint32_t i = 0; i <= 500; ++i) rnumber[i] = u_get_num_random_range1(10000);
} }
static void handlerForkSql() static void handlerForkSql()
@ -344,6 +387,8 @@ public:
pstmt->paramValues[0] = num2str; pstmt->paramValues[0] = num2str;
pstmt->paramLengths[0] = sizeof(unsigned int); pstmt->paramLengths[0] = sizeof(unsigned int);
((UEventDB*)UServer_Base::handler_db1)->setConnection(conn);
} }
# endif # endif
@ -351,6 +396,21 @@ public:
} }
} }
#ifdef DEBUG
static void handlerEndSql()
{
U_TRACE_NO_PARAM(5, "World::handlerEndSql()")
if (pstmt_query)
{
U_DELETE( pstmt_query)
U_DELETE(pworld_query)
U_DELETE( psql_query)
pstmt_query = U_NULLPTR;
}
}
const char* dump(bool breset) const; const char* dump(bool breset) const;
#endif #endif

View File

@ -12,74 +12,48 @@
# include <ulib/net/client/mongodb.h> # include <ulib/net/client/mongodb.h>
#endif #endif
class WorldNoSql { class U_EXPORT WorldNoSql {
public: public:
static UString* str_rnumber; static UString* str_rnumber;
static void handlerOneResult(uint32_t uid)
{
U_TRACE(5, "WorldNoSql::handlerOneResult(%u)", uid)
U_INTERNAL_ASSERT_POINTER(str_rnumber)
U_INTERNAL_ASSERT_POINTER(World::pwbuffer)
u_put_unalignedp32(World::pwbuffer, U_MULTICHAR_CONSTANT32('"','i','d','"'));
World::pwbuffer[4] = ':';
World::pwbuffer = u_num2str32(uid, World::pwbuffer+5);
u_put_unalignedp64(World::pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
u_put_unalignedp64(World::pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
World::pwbuffer += 16;
uint32_t sz = str_rnumber->size();
(void) memcpy(World::pwbuffer, str_rnumber->data(), sz);
World::pwbuffer += sz;
str_rnumber->clear();
}
static void handlerResult(uint32_t uid)
{
U_TRACE(5, "WorldNoSql::handlerResult(%u)", uid)
U_INTERNAL_ASSERT_POINTER(str_rnumber)
U_INTERNAL_ASSERT_POINTER(World::pwbuffer)
u_put_unalignedp32(World::pwbuffer, U_MULTICHAR_CONSTANT32('{','"','i','d'));
u_put_unalignedp16(World::pwbuffer+4, U_MULTICHAR_CONSTANT16('"',':'));
World::pwbuffer = u_num2str32(uid, World::pwbuffer+6);
u_put_unalignedp64(World::pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
u_put_unalignedp64(World::pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
World::pwbuffer += 16;
uint32_t sz = str_rnumber->size();
(void) memcpy(World::pwbuffer, str_rnumber->data(), sz);
World::pwbuffer += sz;
str_rnumber->clear();
u_put_unalignedp16(World::pwbuffer, U_MULTICHAR_CONSTANT16('}',','));
World::pwbuffer += 2;
}
static void doOneQuery(vPFu handlerQuery) static void doOneQuery(vPFu handlerQuery)
{ {
U_TRACE(5, "WorldNoSql::doOneQuery(%p)", handlerQuery) U_TRACE(5, "WorldNoSql::doOneQuery(%p)", handlerQuery)
World::initOneResult();
handlerQuery(World::rnumber[0]); handlerQuery(World::rnumber[0]);
handlerOneResult(World::rnumber[0]); uint32_t sz = str_rnumber->size();
World::initOneResult();
(void) memcpy(World::pwbuffer+16, str_rnumber->data(), sz);
World::ptr = World::pwbuffer+16+sz;
World::endOneResult(); World::endOneResult();
str_rnumber->clear();
}
static void handlerResult(uint32_t i)
{
U_TRACE(5, "WorldNoSql::handlerResult(%u)", i)
U_INTERNAL_ASSERT_POINTER(str_rnumber)
U_INTERNAL_ASSERT_POINTER(World::pwbuffer)
if (i) World::addResult(i);
uint32_t sz = str_rnumber->size();
(void) memcpy(World::ptr+16, str_rnumber->data(), sz);
World::ptr += 16+ sz;
u_put_unalignedp16(World::ptr, U_MULTICHAR_CONSTANT16('}',','));
World::ptr += 2;
str_rnumber->clear();
} }
static void doQuery(vPFu handlerQuery) static void doQuery(vPFu handlerQuery)
@ -92,7 +66,7 @@ public:
{ {
handlerQuery(World::rnumber[i]); handlerQuery(World::rnumber[i]);
handlerResult(World::rnumber[i]); handlerResult(i);
} }
World::endResult(); World::endResult();
@ -290,6 +264,66 @@ public:
} }
} }
#ifdef DEBUG
static void handlerEnd()
{
U_TRACE_NO_PARAM(5, "WorldNoSql::handlerEnd()")
if (str_rnumber)
{
U_DELETE(str_rnumber)
str_rnumber = U_NULLPTR;
}
}
static void handlerEndMongoDB()
{
U_TRACE_NO_PARAM(5, "WorldNoSql::handlerEndMongoDB()")
# ifdef USE_MONGODB
if (query)
{
U_DELETE(mc)
U_SYSCALL_VOID(bson_destroy, "%p", query);
query = U_NULLPTR;
handlerEnd();
}
# endif
}
static void handlerEndREDIS()
{
U_TRACE_NO_PARAM(5, "WorldNoSql::handlerEndREDIS()")
if (rc)
{
U_DELETE(rc)
rc = U_NULLPTR;
handlerEnd();
}
}
static void handlerEndElasticSearch()
{
U_TRACE_NO_PARAM(5, "WorldNoSql::handlerEndElasticSearch()")
if (es)
{
U_DELETE(es)
es = U_NULLPTR;
handlerEnd();
}
}
#endif
private: private:
U_DISALLOW_ASSIGN(WorldNoSql) U_DISALLOW_ASSIGN(WorldNoSql)
}; };

View File

@ -2,12 +2,12 @@ userver {
PORT 8080 PORT 8080
PREFORK_CHILD 4 PREFORK_CHILD 4
TCP_LINGER_SET 0 TCP_LINGER_SET -2
LISTEN_BACKLOG 256 LISTEN_BACKLOG 256
DOCUMENT_ROOT benchmark/FrameworkBenchmarks/ULib/www DOCUMENT_ROOT benchmark/FrameworkBenchmarks/ULib/www
PID_FILE ../userver_tcp.pid PID_FILE ../userver_tcp.pid
ORM_DRIVER "sqlite" ORM_DRIVER "sqlite mysql pgsql"
# LOG_FILE ../../benchmark.log # LOG_FILE ../../benchmark.log
# LOG_FILE_SZ 50M # LOG_FILE_SZ 50M