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 2017-06-03 16:08:49 +02:00
parent 49751c50b0
commit cdc9ce5674
22 changed files with 277 additions and 287 deletions

46
configure vendored
View File

@ -7744,6 +7744,12 @@ $as_echo_n "checking for the kernel version... " >&6; }
kernel=`uname -r`
case "$kernel" in
6.*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 5 family ($kernel)" >&5
$as_echo "5 family ($kernel)" >&6; }
# AC_DEFINE([KERNEL_6], 1, [Define to 1 if you're using Linux 6.x])
;;
5.*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 5 family ($kernel)" >&5
$as_echo "5 family ($kernel)" >&6; }
@ -20029,15 +20035,6 @@ $as_echo "#define U_STATIC_ONLY 1" >>confdefs.h
if test -z "$enable_stdcpp"; then
enable_stdcpp="no"
fi
if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno -a "$target_os" != "netbsd"; then
if test "$enable_stdcpp" != "yes"; then
ULIB_LIBS="$ULIB_LIBS -lgcc"
else
gcc_lib=`gcc -print-libgcc-file-name`
gcc_dir=`dirname $gcc_lib`
ULIB_LIBS="$ULIB_LIBS $gcc_dir/libstdc++.a $gcc_lib"
fi
fi
else
if false; then
STATIC_ONLY_TRUE=
@ -32776,7 +32773,7 @@ if test -n "$posix4_lib"; then
ULIB_LIBS="$ULIB_LIBS $posix4_lib";
fi
if test -n "$plib"; then
ULIB_LIBS="$ULIB_LIBS $plib";
ULIB_LIBS="$ULIB_LIBS -Wl,--no-as-needed $plib";
fi
if test "$enable_coverage" = "yes"; then
ULIB_LIBS="$ULIB_LIBS -lgcov"
@ -32854,26 +32851,37 @@ if test "x$ac_cv_crc32_intrinsics" = xyes; then
fi
if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libgcc" >&5
if test "$enable_static" = "yes" -a "$enable_shared" = "no" -a "$enable_stdcpp" = "yes"; then
gcc_lib=`gcc -print-libgcc-file-name`
gcc_dir=`dirname $gcc_lib`
if test -f "$gcc_dir/libstdc++.a"; then
ULIB_LIBS="$ULIB_LIBS $gcc_dir/libstdc++.a $gcc_lib"
else
ULIB_LIBS="$ULIB_LIBS -lstdc++ -lgcc"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libgcc" >&5
$as_echo_n "checking whether to use libgcc... " >&6; }
# Check whether --enable-libgcc was given.
# Check whether --enable-libgcc was given.
if test "${enable_libgcc+set}" = set; then :
enableval=$enable_libgcc; case "$enableval" in
yes)
ULIB_LIBS="$ULIB_LIBS -lgcc"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
yes)
ULIB_LIBS="$ULIB_LIBS -lgcc"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
;;
*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
;;
*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
;;
esac
;;
esac
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
fi
##########################

View File

@ -275,6 +275,11 @@ case "$target_os" in
kernel=`uname -r`
case "$kernel" in
6.*)
AC_MSG_RESULT([5 family ($kernel)])
# AC_DEFINE([KERNEL_6], 1, [Define to 1 if you're using Linux 6.x])
;;
5.*)
AC_MSG_RESULT([5 family ($kernel)])
# AC_DEFINE([KERNEL_5], 1, [Define to 1 if you're using Linux 5.x])
@ -594,15 +599,6 @@ if test "$enable_static" = "yes" -a "$enable_shared" = "no"; then
if test -z "$enable_stdcpp"; then
enable_stdcpp="no"
fi
if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno -a "$target_os" != "netbsd"; then
if test "$enable_stdcpp" != "yes"; then
ULIB_LIBS="$ULIB_LIBS -lgcc"
else
gcc_lib=`gcc -print-libgcc-file-name`
gcc_dir=`dirname $gcc_lib`
ULIB_LIBS="$ULIB_LIBS $gcc_dir/libstdc++.a $gcc_lib"
fi
fi
else
AM_CONDITIONAL(STATIC_ONLY, false)
fi
@ -2508,7 +2504,7 @@ if test -n "$posix4_lib"; then
ULIB_LIBS="$ULIB_LIBS $posix4_lib";
fi
if test -n "$plib"; then
ULIB_LIBS="$ULIB_LIBS $plib";
ULIB_LIBS="$ULIB_LIBS -Wl,--no-as-needed $plib";
fi
if test "$enable_coverage" = "yes"; then
ULIB_LIBS="$ULIB_LIBS -lgcov"
@ -2547,19 +2543,30 @@ if test "x$ac_cv_crc32_intrinsics" = xyes; then
fi
if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno; then
AC_MSG_CHECKING([whether to use libgcc])
AC_ARG_ENABLE(libgcc,
AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
[ case "$enableval" in
yes)
ULIB_LIBS="$ULIB_LIBS -lgcc"
AC_MSG_RESULT(yes)
;;
*) AC_MSG_RESULT(no)
;;
esac ],
AC_MSG_RESULT(no)
)
if test "$enable_static" = "yes" -a "$enable_shared" = "no" -a "$enable_stdcpp" = "yes"; then
gcc_lib=`gcc -print-libgcc-file-name`
gcc_dir=`dirname $gcc_lib`
if test -f "$gcc_dir/libstdc++.a"; then
ULIB_LIBS="$ULIB_LIBS $gcc_dir/libstdc++.a $gcc_lib"
else
ULIB_LIBS="$ULIB_LIBS -lstdc++ -lgcc"
fi
else
AC_MSG_CHECKING([whether to use libgcc])
AC_ARG_ENABLE(libgcc,
AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
[ case "$enableval" in
yes)
ULIB_LIBS="$ULIB_LIBS -lgcc"
AC_MSG_RESULT(yes)
;;
*) AC_MSG_RESULT(no)
;;
esac ],
AC_MSG_RESULT(no)
)
fi
fi
##########################

View File

@ -44,12 +44,21 @@ static void GenStat(Stat& stat, const union UValue::jval val)
{
stat.arrayCount++;
# if defined(U_STDCPP_ENABLE) && defined(HAVE_CXX11)
for (auto const& i : val)
{
stat.elementCount++;
GenStat(stat, i.getValue());
}
# else
for (UValue* i = UValue::toNode(val.ival); i; i = i->next)
{
stat.elementCount++;
GenStat(stat, i->getValue());
}
# endif
}
break;
@ -57,6 +66,7 @@ static void GenStat(Stat& stat, const union UValue::jval val)
{
stat.objectCount++;
# if defined(U_STDCPP_ENABLE) && defined(HAVE_CXX11)
for (auto const& i : val)
{
stat.memberCount++;
@ -65,6 +75,16 @@ static void GenStat(Stat& stat, const union UValue::jval val)
GenStat(stat, i.getValue());
}
# else
for (UValue* i = UValue::toNode(val.ival); i; i = i->next)
{
stat.memberCount++;
stat.stringCount++; // Key
stat.stringLength += UValue::getStringSize(i->getKey());
GenStat(stat, i->getValue());
}
# endif
}
break;
}

View File

@ -241,7 +241,7 @@ void ULib::init(const char* mempool, char** argv)
U_INTERNAL_ASSERT_EQUALS(sizeof(UStringRep), sizeof(ustringrep))
#if defined(U_STATIC_ONLY)
if (UStringRep::string_rep_null == 0)
if (UStringRep::string_rep_null == U_NULLPTR)
{
UString::string_null = uustringnull.p2;
UStringRep::string_rep_null = uustringrepnull.p2;

View File

@ -5,10 +5,8 @@ TechEmpower Web Framework Benchmarks
<!--#declaration
#include "world.h"
static UCache* cache;
static World* pworld_query;
static UOrmSession* psql_query;
static UOrmStatement* pstmt_query;
static UCache* cache;
static World* pworld_query;
#ifndef AS_cpoll_cppsp_DO
static UVector<World*>* pvworld_query;
@ -18,47 +16,37 @@ static void usp_init_cached_worlds()
{
U_TRACE(5, "::usp_init_cached_worlds()")
U_NEW(UOrmSession, psql_query, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
UOrmSession sql_query(U_CONSTANT_TO_PARAM("hello_world"));
if (psql_query->isReady())
if (sql_query.isReady() == false)
{
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_WARNING("usp_init_cached_worlds(): we cound't connect to db");
if (pstmt_query == U_NULLPTR)
{
U_WARNING("usp_init_cached_worlds(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_query << "BEGIN TRANSACTION";
U_NEW(World, pworld_query, World);
pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);
// creat and fill the cache
U_NEW(UCache, cache, UCache);
(void) cache->open(U_STRING_FROM_CONSTANT("/tmp/ULib_cached_worlds.cache"), 10000 * 64, U_NULLPTR, true);
for (uint32_t i = 1; i < 10000-1; ++i)
{
pworld_query->id = i;
pstmt_query->execute();
cache->add(pworld_query->id, pworld_query->randomNumber);
}
delete pstmt_query;
# ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
# endif
return;
}
U_NEW(World, pworld_query, World);
UOrmStatement stmt_query(sql_query, U_CONSTANT_TO_PARAM("SELECT * FROM World"));
stmt_query.into(*pworld_query);
stmt_query.execute();
// creat and fill the cache
U_NEW(UCache, cache, UCache);
(void) cache->open(U_STRING_FROM_CONSTANT("/tmp/ULib_cached_worlds.cache"), 10000 * 64, U_NULLPTR, true);
do {
cache->add(pworld_query->id, pworld_query->randomNumber);
}
while (stmt_query.nextRow());
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
#endif
}
#ifdef DEBUG
@ -66,9 +54,7 @@ static void usp_end_cached_worlds()
{
U_TRACE(5, "::usp_end_cached_worlds()")
delete psql_query;
if (pstmt_query)
if (cache)
{
delete cache;
delete pworld_query;

View File

@ -15,22 +15,19 @@ static void usp_fork_db()
U_NEW(UOrmSession, psql_db, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
if (psql_db->isReady())
if (psql_db->isReady() == false)
{
U_NEW(UOrmStatement, pstmt_db, UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_WARNING("usp_fork_db(): we cound't connect to db");
if (pstmt_db == U_NULLPTR)
{
U_WARNING("usp_fork_db(): we cound't connect to db");
return;
}
U_NEW(World, pworld_db, World);
pstmt_db->use( pworld_db->id);
pstmt_db->into(pworld_db->randomNumber);
return;
}
U_NEW(UOrmStatement, pstmt_db, UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_NEW(World, pworld_db, World);
pstmt_db->use( pworld_db->id);
pstmt_db->into(pworld_db->randomNumber);
}
#ifdef DEBUG

View File

@ -23,7 +23,7 @@ static void usp_fork_edb()
return;
}
U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN);
U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN);
}
#ifdef DEBUG

View File

@ -27,7 +27,7 @@ static void usp_fork_equery()
return;
}
U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN);
U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN);
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));

View File

@ -20,27 +20,24 @@ static void usp_fork_fortune()
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
if (psql_fortune->isReady())
if (psql_fortune->isReady() == false)
{
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
U_WARNING("usp_fork_fortune(): we cound't connect to db");
if (pstmt_fortune == U_NULLPTR)
{
U_WARNING("usp_fork_fortune(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
U_NEW(Fortune, pfortune, Fortune);
pstmt_fortune->into(*pfortune);
U_NEW(UString, pencoded, UString(100U));
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
return;
}
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
U_NEW(Fortune, pfortune, Fortune);
pstmt_fortune->into(*pfortune);
U_NEW(UString, pencoded, UString(100U));
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
}
#ifdef DEBUG

View File

@ -19,28 +19,25 @@ static void usp_fork_query()
U_NEW(UOrmSession, psql_query, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
if (psql_query->isReady())
if (psql_query->isReady() == false)
{
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_WARNING("usp_fork_query(): we cound't connect to db");
if (pstmt_query == U_NULLPTR)
{
U_WARNING("usp_fork_query(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_query << "BEGIN TRANSACTION";
U_NEW(World, pworld_query, World);
pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);
# ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
# endif
return;
}
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
if (UOrmDriver::isPGSQL()) *psql_query << "BEGIN TRANSACTION";
U_NEW(World, pworld_query, World);
pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
#endif
}
#ifdef DEBUG

View File

@ -20,31 +20,27 @@ static void usp_fork_update()
U_NEW(UOrmSession, psql_update, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
if (psql_update->isReady())
if (psql_update->isReady() == false)
{
U_NEW(UOrmStatement, pstmt1, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_NEW(UOrmStatement, pstmt2, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
U_WARNING("usp_fork_update(): we cound't connect to db");
if (pstmt1 == U_NULLPTR ||
pstmt2 == U_NULLPTR)
{
U_WARNING("usp_fork_update(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_update << "SET synchronous_commit TO OFF";
U_NEW(World, pworld_update, World);
pstmt1->use( pworld_update->id);
pstmt1->into(pworld_update->randomNumber);
pstmt2->use( pworld_update->randomNumber, pworld_update->id);
# ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
# endif
return;
}
U_NEW(UOrmStatement, pstmt1, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_NEW(UOrmStatement, pstmt2, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
if (UOrmDriver::isPGSQL()) *psql_update << "SET synchronous_commit TO OFF";
U_NEW(World, pworld_update, World);
pstmt1->use( pworld_update->id);
pstmt1->into(pworld_update->randomNumber);
pstmt2->use( pworld_update->randomNumber, pworld_update->id);
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
#endif
}
#ifdef DEBUG

View File

@ -8,9 +8,16 @@ libdir=@libdir@
includedir=@includedir@
exec_prefix=@exec_prefix@
if [ -z "$1" ]; then
exit 1
fi
dirn=`dirname $1`
basen=`basename $1`
#if [ -n "$dirn" ]; then
#fi
libsuffix=$2
test "$libsuffix" || libsuffix=so
@ -19,8 +26,8 @@ export PATH="/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin"
${prefix}/bin/usp_translator $1.usp &&
${prefix}/bin/usp_libtool.sh --silent --tag=CXX --mode=compile \
@CXX@ -I${includedir} -DHAVE_CONFIG_H @CPPFLAGS@ @CXXFLAGS@ @USP_FLAGS@ -MT $1.lo -MD -MP -c -o $1.lo $1.cpp &&
@CXX@ -I${includedir} -DHAVE_CONFIG_H @CPPFLAGS@ @CXXFLAGS@ @USP_FLAGS@ -MT $basen.lo -MD -MP -c -o $basen.lo $basen.cpp &&
${prefix}/bin/usp_libtool.sh --silent --tag=CXX --mode=link \
@CXX@ @CPPFLAGS@ @LDFLAGS@ @USP_LDFLAGS@ -o $1.la -rpath ${prefix}/libexec/ulib/usp \
-module -export-dynamic -avoid-version -no-undefined $1.lo @USP_LIBS@ -l@ULIB@ @ULIB_LIBS@ &&
mv $1.usp ${dirn}/.libs; rm -rf $1.d $1.la $1.lo $1.o $1.cpp; mv ${dirn}/.libs/${basen}.usp ${dirn}/.libs/${basen}.$libsuffix ${dirn}; rm -rf ${dirn}/.libs
@CXX@ @CPPFLAGS@ @LDFLAGS@ @USP_LDFLAGS@ -o $basen.la -rpath ${prefix}/libexec/ulib/usp \
-module -export-dynamic -avoid-version -no-undefined $basen.lo @USP_LIBS@ -l@ULIB@ @ULIB_LIBS@ &&
mv $1.usp .libs; rm -rf $basen.d $basen.la $basen.lo $basen.o $basen.cpp; mv .libs/${basen}.usp .libs/${basen}.$libsuffix ${dirn}; rm -rf .libs

View File

@ -109,6 +109,7 @@ UOrmSession::~UOrmSession()
pdrv->handlerDisConnect();
if (UOrmDriver::vdriver->find(pdrv) == U_NOT_FOUND) delete pdrv;
else pdrv->vopt.clear();
}
#endif
}
@ -156,9 +157,9 @@ bool UOrmSession::query(const char* stmt, uint32_t len)
U_INTERNAL_ASSERT_POINTER(pdrv)
bool result = pdrv->handlerQuery(stmt, len);
if (pdrv->handlerQuery(stmt, len)) U_RETURN(true);
U_RETURN(result);
U_RETURN(false);
}
// This function returns the number of database rows that were changed

View File

@ -85,7 +85,7 @@ Content-Type: application/json
[{"id":6851,"randomNumber":7598},{"id":3968,"randomNumber":7325},{"id":8159,"randomNumber":348},{"id":9560,"randomNumber":7333},{"id":9938,"randomNumber":9080},{"id":1598,"randomNumber":1623},{"id":3280,"randomNumber":8707},{"id":4521,"randomNumber":6063},{"id":8173,"randomNumber":3690},{"id":3648,"randomNumber":8803}]
```
[/cached_worlds?count=10](http://www.techempower.com/benchmarks/#section=cached_worlds)
[/cached_worlds?queries=10](http://www.techempower.com/benchmarks/#section=caching)
-------------------
```
HTTP/1.1 200 OK

View File

@ -101,7 +101,7 @@
"query_url": "/query?queries=",
"fortune_url": "/fortune",
"update_url": "/update?queries=",
"cached_query_url": "/cached-worlds?queries=",
"cached_query_url": "/cached_worlds?queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",

View File

@ -17,3 +17,4 @@
./src/rfortune.usp
./src/mfortune.usp
./src/plaintext.usp
./src/cached_worlds.usp

View File

@ -5,10 +5,8 @@ TechEmpower Web Framework Benchmarks
<!--#declaration
#include "world.h"
static UCache* cache;
static World* pworld_query;
static UOrmSession* psql_query;
static UOrmStatement* pstmt_query;
static UCache* cache;
static World* pworld_query;
#ifndef AS_cpoll_cppsp_DO
static UVector<World*>* pvworld_query;
@ -18,47 +16,37 @@ static void usp_init_cached_worlds()
{
U_TRACE(5, "::usp_init_cached_worlds()")
U_NEW(UOrmSession, psql_query, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
UOrmSession sql_query(U_CONSTANT_TO_PARAM("hello_world"));
if (psql_query->isReady())
if (sql_query.isReady() == false)
{
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_WARNING("usp_init_cached_worlds(): we cound't connect to db");
if (pstmt_query == U_NULLPTR)
{
U_WARNING("usp_init_cached_worlds(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_query << "BEGIN TRANSACTION";
U_NEW(World, pworld_query, World);
pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);
// creat and fill the cache
U_NEW(UCache, cache, UCache);
(void) cache->open(U_STRING_FROM_CONSTANT("/tmp/ULib_cached_worlds.cache"), 10000 * 64, U_NULLPTR, true);
for (uint32_t i = 1; i < 10000-1; ++i)
{
pworld_query->id = i;
pstmt_query->execute();
cache->add(pworld_query->id, pworld_query->randomNumber);
}
delete pstmt_query;
# ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
# endif
return;
}
U_NEW(World, pworld_query, World);
UOrmStatement stmt_query(sql_query, U_CONSTANT_TO_PARAM("SELECT * FROM World"));
stmt_query.into(*pworld_query);
stmt_query.execute();
// creat and fill the cache
U_NEW(UCache, cache, UCache);
(void) cache->open(U_STRING_FROM_CONSTANT("/tmp/ULib_cached_worlds.cache"), 10000 * 64, U_NULLPTR, true);
do {
cache->add(pworld_query->id, pworld_query->randomNumber);
}
while (stmt_query.nextRow());
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
#endif
}
#ifdef DEBUG
@ -66,9 +54,7 @@ static void usp_end_cached_worlds()
{
U_TRACE(5, "::usp_end_cached_worlds()")
delete psql_query;
if (pstmt_query)
if (cache)
{
delete cache;
delete pworld_query;

View File

@ -15,22 +15,19 @@ static void usp_fork_db()
U_NEW(UOrmSession, psql_db, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
if (psql_db->isReady())
if (psql_db->isReady() == false)
{
U_NEW(UOrmStatement, pstmt_db, UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_WARNING("usp_fork_db(): we cound't connect to db");
if (pstmt_db == U_NULLPTR)
{
U_WARNING("usp_fork_db(): we cound't connect to db");
return;
}
U_NEW(World, pworld_db, World);
pstmt_db->use( pworld_db->id);
pstmt_db->into(pworld_db->randomNumber);
return;
}
U_NEW(UOrmStatement, pstmt_db, UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_NEW(World, pworld_db, World);
pstmt_db->use( pworld_db->id);
pstmt_db->into(pworld_db->randomNumber);
}
#ifdef DEBUG

View File

@ -20,27 +20,24 @@ static void usp_fork_fortune()
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
if (psql_fortune->isReady())
if (psql_fortune->isReady() == false)
{
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
U_WARNING("usp_fork_fortune(): we cound't connect to db");
if (pstmt_fortune == U_NULLPTR)
{
U_WARNING("usp_fork_fortune(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
U_NEW(Fortune, pfortune, Fortune);
pstmt_fortune->into(*pfortune);
U_NEW(UString, pencoded, UString(100U));
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
return;
}
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
U_NEW(Fortune, pfortune, Fortune);
pstmt_fortune->into(*pfortune);
U_NEW(UString, pencoded, UString(100U));
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
}
#ifdef DEBUG

View File

@ -19,28 +19,25 @@ static void usp_fork_query()
U_NEW(UOrmSession, psql_query, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
if (psql_query->isReady())
if (psql_query->isReady() == false)
{
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_WARNING("usp_fork_query(): we cound't connect to db");
if (pstmt_query == U_NULLPTR)
{
U_WARNING("usp_fork_query(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_query << "BEGIN TRANSACTION";
U_NEW(World, pworld_query, World);
pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);
# ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
# endif
return;
}
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
if (UOrmDriver::isPGSQL()) *psql_query << "BEGIN TRANSACTION";
U_NEW(World, pworld_query, World);
pstmt_query->use( pworld_query->id);
pstmt_query->into(pworld_query->randomNumber);
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
#endif
}
#ifdef DEBUG

View File

@ -20,31 +20,27 @@ static void usp_fork_update()
U_NEW(UOrmSession, psql_update, UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
if (psql_update->isReady())
if (psql_update->isReady() == false)
{
U_NEW(UOrmStatement, pstmt1, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_NEW(UOrmStatement, pstmt2, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
U_WARNING("usp_fork_update(): we cound't connect to db");
if (pstmt1 == U_NULLPTR ||
pstmt2 == U_NULLPTR)
{
U_WARNING("usp_fork_update(): we cound't connect to db");
return;
}
if (UOrmDriver::isPGSQL()) *psql_update << "SET synchronous_commit TO OFF";
U_NEW(World, pworld_update, World);
pstmt1->use( pworld_update->id);
pstmt1->into(pworld_update->randomNumber);
pstmt2->use( pworld_update->randomNumber, pworld_update->id);
# ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
# endif
return;
}
U_NEW(UOrmStatement, pstmt1, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
U_NEW(UOrmStatement, pstmt2, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
if (UOrmDriver::isPGSQL()) *psql_update << "SET synchronous_commit TO OFF";
U_NEW(World, pworld_update, World);
pstmt1->use( pworld_update->id);
pstmt1->into(pworld_update->randomNumber);
pstmt2->use( pworld_update->randomNumber, pworld_update->id);
#ifndef AS_cpoll_cppsp_DO
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
#endif
}
#ifdef DEBUG

View File

@ -13,8 +13,8 @@ rm -f tmp/usp_compile.sh.err /tmp/*.hpack.* \
trace.*userver_*.[0-9]* object.*userver_*.[0-9]* stack.*userver_*.[0-9]* mempool.*userver_*.[0-9]* \
$DOC_ROOT/trace.*userver_*.[0-9]* $DOC_ROOT/object.*userver_*.[0-9]* $DOC_ROOT/stack.*userver_*.[0-9]* $DOC_ROOT/mempool.*userver_*.[0-9]*
UTRACE="0 20M -1"
UTRACE_SIGNAL="0 20M -1"
UTRACE="0 50M -1"
UTRACE_SIGNAL="0 50M -1"
#UOBJDUMP="0 10M 100"
#USIMERR="error.sim"
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL