Cache session/[{cursor, config}] for reuse and spawn threads when needed. #9
4 changed files with 43 additions and 11 deletions
|
@ -11,9 +11,9 @@ unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as w
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
WT_REPO=http://github.com/wiredtiger/wiredtiger.git
|
WT_REPO=http://github.com/wiredtiger/wiredtiger.git
|
||||||
WT_BRANCH=develop
|
WT_BRANCH=
|
||||||
WT_VSN=""
|
WT_REF="tags/1.6.2"
|
||||||
WT_DIR=wiredtiger-$WT_BRANCH
|
WT_DIR=wiredtiger-`basename $WT_REF`
|
||||||
|
|
||||||
SNAPPY_VSN="1.0.4"
|
SNAPPY_VSN="1.0.4"
|
||||||
SNAPPY_DIR=snappy-$SNAPPY_VSN
|
SNAPPY_DIR=snappy-$SNAPPY_VSN
|
||||||
|
@ -35,9 +35,9 @@ get_wt ()
|
||||||
if [ -d $BASEDIR/$WT_DIR/.git ]; then
|
if [ -d $BASEDIR/$WT_DIR/.git ]; then
|
||||||
(cd $BASEDIR/$WT_DIR && git pull -u) || exit 1
|
(cd $BASEDIR/$WT_DIR && git pull -u) || exit 1
|
||||||
else
|
else
|
||||||
if [ "X$WT_VSN" != "X" ]; then
|
if [ "X$WT_REF" != "X" ]; then
|
||||||
git clone ${WT_REPO} && \
|
git clone ${WT_REPO} && \
|
||||||
(cd $BASEDIR/wiredtiger && git checkout $WT_VSN || exit 1)
|
(cd $BASEDIR/wiredtiger && git checkout refs/$WT_REF || exit 1)
|
||||||
else
|
else
|
||||||
git clone ${WT_REPO} && \
|
git clone ${WT_REPO} && \
|
||||||
(cd $BASEDIR/wiredtiger && git checkout -b $WT_BRANCH origin/$WT_BRANCH || exit 1)
|
(cd $BASEDIR/wiredtiger && git checkout -b $WT_BRANCH origin/$WT_BRANCH || exit 1)
|
||||||
|
|
|
@ -127,7 +127,7 @@ __str_hash(uint32_t in, const char *p, size_t len)
|
||||||
{
|
{
|
||||||
uint32_t h = in;
|
uint32_t h = in;
|
||||||
for (++p ; len > 0; ++p, --len)
|
for (++p ; len > 0; ++p, --len)
|
||||||
h = (h << 5) - h + (uint32_t)*p;
|
h += (h << 5) + (h >> 27) + *p;
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,8 @@ nif_stub_error(Line) ->
|
||||||
-spec init() -> ok | {error, any()}.
|
-spec init() -> ok | {error, any()}.
|
||||||
init() ->
|
init() ->
|
||||||
erlang:load_nif(filename:join([priv_dir(), atom_to_list(?MODULE)]),
|
erlang:load_nif(filename:join([priv_dir(), atom_to_list(?MODULE)]),
|
||||||
[{wterl_vsn, "b2c0b65"},
|
[{wterl_vsn, "53307e8"},
|
||||||
{wiredtiger_vsn, "1.6.1-87-gbe6742a"}]).
|
{wiredtiger_vsn, "1.6.2-0-g07cb0a5"}]).
|
||||||
|
|
||||||
-spec connection_open(string(), config_list()) -> {ok, connection()} | {error, term()}.
|
-spec connection_open(string(), config_list()) -> {ok, connection()} | {error, term()}.
|
||||||
-spec connection_open(string(), config_list(), config_list()) -> {ok, connection()} | {error, term()}.
|
-spec connection_open(string(), config_list(), config_list()) -> {ok, connection()} | {error, term()}.
|
||||||
|
@ -586,6 +586,39 @@ insert_delete_test() ->
|
||||||
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
||||||
ok = connection_close(ConnRef).
|
ok = connection_close(ConnRef).
|
||||||
|
|
||||||
|
many_open_tables_test_() ->
|
||||||
|
{timeout, 60,
|
||||||
|
fun() ->
|
||||||
|
ConnOpts = [{create,true},{cache_size,"100MB"},{session_max, 8192}],
|
||||||
|
DataDir = ?TEST_DATA_DIR,
|
||||||
|
KeyGen =
|
||||||
|
fun(X) ->
|
||||||
|
crypto:sha(<<X>>)
|
||||||
|
end,
|
||||||
|
ValGen =
|
||||||
|
fun() ->
|
||||||
|
crypto:rand_bytes(crypto:rand_uniform(128, 4096))
|
||||||
|
end,
|
||||||
|
TableNameGen =
|
||||||
|
fun(X) ->
|
||||||
|
"lsm:" ++ integer_to_list(X)
|
||||||
|
end,
|
||||||
|
N = 1000,
|
||||||
|
ConnRef = open_test_conn(DataDir, ConnOpts),
|
||||||
|
Parent = self(),
|
||||||
|
[wterl:create(ConnRef, TableNameGen(X), [{checksum, "uncompressed"}]) || X <- lists:seq(0, 128)],
|
||||||
|
[spawn(fun() ->
|
||||||
|
TableName = TableNameGen(X),
|
||||||
|
[wterl:put(ConnRef, TableName, KeyGen(P), ValGen()) || P <- lists:seq(1, N)],
|
||||||
|
[wterl:get(ConnRef, TableName, KeyGen(P)) || P <- lists:seq(1, N)],
|
||||||
|
[wterl:delete(ConnRef, TableName, KeyGen(P)) || P <- lists:seq(1, N)],
|
||||||
|
Parent ! done
|
||||||
|
end) || X <- lists:seq(0, 128)],
|
||||||
|
[wterl:drop(ConnRef, TableNameGen(X)) || X <- lists:seq(0, 128)],
|
||||||
|
[receive done -> ok end || _ <- lists:seq(0, 128)],
|
||||||
|
ok = wterl:connection_close(ConnRef)
|
||||||
|
end}.
|
||||||
|
|
||||||
init_test_table() ->
|
init_test_table() ->
|
||||||
ConnRef = open_test_conn(?TEST_DATA_DIR),
|
ConnRef = open_test_conn(?TEST_DATA_DIR),
|
||||||
ConnRef = open_test_table(ConnRef),
|
ConnRef = open_test_table(ConnRef),
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
# Note: also, remember to update version numbers in rpath specs so that shared libs can be found at runtime!!!
|
# Note: also, remember to update version numbers in rpath specs so that shared libs can be found at runtime!!!
|
||||||
|
|
||||||
wterl=`git log -n 1 --pretty=format:"%H"`
|
wterl=`git describe --always --long --tags`
|
||||||
wiredtiger0=`(cd c_src/wiredtiger-develop && git log -n 1 --pretty=format:"%H")`
|
wiredtiger0=`(cd c_src/wiredtiger-[0-9.]* && git describe --always --long --tags)`
|
||||||
wiredtiger=`echo $wiredtiger0 | awk '{print $2}'`
|
wiredtiger=`echo $wiredtiger0 | awk '{print $2}'`
|
||||||
|
|
||||||
echo $wterl
|
echo $wterl
|
||||||
echo $wiredtiger
|
echo $wiredtiger
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue