Commit graph

125 commits

Author SHA1 Message Date
Gregory Burd
8fe9dc9bad This is a different approach from async2, instead of a single queue
and many workers this has a queue per scheduler and a few workers per
queue.
2013-04-14 08:44:54 -04:00
Gregory Burd
456129e7f3 Reusing closed cursors is bad for your health (SEGV), don't do that.
Also a bit of paranoia, bzero after all enif_alloc calls.
2013-04-12 16:59:10 -04:00
Gregory Burd
b0ca1e4098 WIP -- 41 tests pass, 3 fail = progress! Right now I have the connection
dtor commented out, otherwise it would SEGV on GC.  Some of the truncate
tests fail (race?) but don't SEGV, so that's not so bad.  Fixed numerous
issues and also removed a mutex and queue of idle worker threads because
it isn't used so why bother with it?
2013-04-12 15:25:56 -04:00
Gregory Burd
5a73264307 WIP -- Most tests passing, truncate and drop failing due to EBUSY,
also not sure why there is a segv when exiting but not in gdb.
Unlock mutex before returning error codes.  Alloc/free copies of some
strings allocated on the stack.
2013-04-11 11:57:41 -04:00
Gregory Burd
5c0295624d WIP -- most tests running, a few commented out, sometimes a segv on exit 2013-04-08 17:21:48 -04:00
Gregory Burd
07061ed6e8 WIP -- more tests passing, plenty left to fix 2013-04-07 22:16:44 -04:00
Gregory Burd
3b41805a71 WIP -- continue to fix tests in wterl 2013-04-07 10:07:19 -04:00
Gregory Burd
5ac006630e WIP -- tests failing -- WIP
Fixed numerous bugs.  Pushed config_to_bin down to just before
calling the _nif() function, everywhere else config is a proplist.
2013-04-07 09:21:47 -04:00
Gregory Burd
2675aa501a Opening a connection now involves passing in both a configuration
string for the connection and for any sessions.  Don't convert
configuration proplists into strings (Erlang binaries) until calling
into the NIF layer.
2013-04-06 17:19:59 -04:00
Gregory Burd
07592f20fb Use non-cursor ops for get/put/delete because under the covers they
are reusing sessions and cursors in the NIF layer.  Keep two cursors
open for just the house keeping tasks, is_empty and stats.
2013-04-06 17:17:50 -04:00
Gregory Burd
19268b7c77 WIP-- Not Yet Compiling or Functional -- WIP
* No longer expose WT_SESSION into Erlang at all as WT's model is to
maintain one WT_SESSION per-thread and we don't know anything about
threads in Erlang.

* async_nif worker threads don't pull both mutexes on every loop
when processing requests, only one

* async_nif provides a worker_id (int, 0 - MAX_WORKERS) within the
work block scope which we use to find our per-worker WT_SESSIONs

* async_nif maintained a number of globals which I'm moving into
the NIF's priv_data so that on upgrade/reload we have a fighting
chance to "Do the Right Thing(TM)".

* NIF Upgrades/Reloads started to plumb this in.

* Use a khash to manage the cache of URI->WT_CURSORs per WT_SESSION.

* Added start/stop positions into truncate call to allow for truncating
sub-ranges data.

* Lots of other details I'm sure I've forgotten and more left undone.
Search for "TODO:" or try to compile to see what's left, and then
there is a need for a lot more tests given all this new complexity.
2013-04-05 18:09:54 -04:00
Gregory Burd
254891e776 Bumping reductions manually will not be supported in future releases of the
BEAM and has dubious value anyway.  Remove that and ignore queue depth for
now.
2013-04-02 09:37:49 -04:00
Gregory Burd
609676917d Rename function to match new API. 2013-04-02 09:36:34 -04:00
Gregory Burd
6aa51437cc Merge remote-tracking branch 'origin/master' into gsb-async-nifs2
Conflicts:
	c_src/wterl.c
	src/riak_kv_wterl_backend.erl
	src/wterl.erl
2013-04-02 09:33:41 -04:00
Gregory Burd
95a6f52a1d Whitespace 2013-04-01 14:00:06 -04:00
Gregory Burd
1595ce3096 Automatically load all WiredTiger extension shared libraries found in the priv dir at load time. 2013-03-28 10:45:24 -04:00
Gregory Burd
3ef48e0ac0 Change from static linking to dynamic. Enable snappy and bzip2 compression. 2013-03-28 10:24:26 -04:00
Gregory Burd
77e0dacdb5 Use a set of {Session, Cursor} pairs ("passes") for calls into WiredTiger
to avoid a) opening a large number of Sessions or Cursors and b) avoid
reusing a Session/Cursor pair in more than one thread.  Each operation,
except folds, use the Session/Cursor pair corresponding to the scheduler
id (roughly "core") they are running on.  Each vnode instance will have
(count(schedulers) + count(active folds)) Session/Cursor pairs in use so
be sure to set session_max large enough when opening the connection to
WiredTiger.  This method will cause problems with scheduler threads going
to "sleep" so be sure to run schedmon to wake them up.
2013-03-26 14:17:21 -04:00
Gregory Burd
9f4e08ca6e Queue and execute work from scheduler threads on other threads to prevent schedulers from sleeping. 2013-03-24 21:00:48 -04:00
Gregory Burd
85b84a5343 Folds need a separate cursor, but not a separate session, so use
the shared connection and session.
2013-03-21 21:39:47 -04:00
Gregory Burd
9834f54991 Cover a few more corner cases when encoding cache size and other
values to config strings.
2013-03-21 21:05:01 -04:00
Gregory Burd
9302def7cc Lower cache size guess from 1/3 to 1/4 of available memory. Finally correct lsm_bloom_new/oldest config. 2013-03-21 18:56:01 -04:00
Gregory Burd
0203b06a61 Cursor delete operation only requires cursor handle and key (no need for a value) 2013-03-21 18:44:13 -04:00
Gregory Burd
a844dc5846 Whitespace 2013-03-21 14:37:37 -04:00
Gregory Burd
e02eb8ef9f Don't log the cache size guess. 2013-03-21 14:37:24 -04:00
Gregory Burd
50d44ecedf Move LSM config to the table open options where they belong. 2013-03-21 14:35:53 -04:00
Gregory Burd
6225f9fde1 Share cursors managed stored in the module's ets table. 2013-03-21 14:34:54 -04:00
Gregory Burd
9ab363adfe Indention 2013-03-21 14:12:03 -04:00
Gregory Burd
b905cce833 Add lsm_bloom_{newest,oldest}=true to set of defaults. 2013-03-19 15:29:13 -04:00
Gregory Burd
f9fcf305ae Revert list change. 2013-03-19 14:51:22 -04:00
Gregory Burd
8ed1c4000e Additional LSM Tree config parameters. 2013-03-19 14:34:01 -04:00
Gregory Burd
33e66ec4e5 Minor change to array construction. 2013-03-19 14:33:38 -04:00
Gregory Burd
39fb4ff710 Pass config into connection:open() rather than ignoring it and do a
better job of integrating config options from the app environment as
well as config file while we're at it.
2013-03-18 15:32:03 -04:00
Gregory Burd
24527cf453 Break out connection and session startup into functions. 2013-03-17 14:04:31 -04:00
Gregory Burd
ce79d22659 Revert shared cursor changes for now. 2013-03-17 08:15:33 -04:00
Gregory Burd
1129241fe0 Only open a session/cursor when first needed. There is still a race
between vnodes during startup, ideally wterl_conn would only be opened
once.
2013-03-16 23:28:13 -04:00
Gregory Burd
22d42f5076 Fixed issue reusing cursors. 2013-03-16 16:42:43 -04:00
Gregory Burd
3543b42df8 Whitespace fixes (s/tab/space/g) and added two new configuration settings
from the 1.5.0 release.  Checkpoint every second, dump stats every 30 sec.
2013-03-14 15:26:28 -04:00
Gregory Burd
1d6dfee192 Cache sizing is critical for performance. This change guesses at a
reasonable setting for the WiredTiger cache size at runtime.  This cache
is shared across all vnodes regarless of how many are active at any
given time.  The algorithm is: max(1GB, 1/3 (RAM - Beam RSS size)). We don't
enable direct_io on purpose and data will be double buffered in WiredTiger's
cache and the filesystem buffer cache.  This turns out to be faster than
direct I/O despite wasting a bit of RAM.
2013-03-14 13:27:59 -04:00
Gregory Burd
e4b3acbd11 Share per-table cursors for get/put/delete operations. 2013-03-13 17:27:00 -04:00
Steve Vinoski
f94336f3eb base WiredTiger max session config setting on ring size 2013-03-12 18:24:06 -04:00
Gregory Burd
789c44b133 Change the config to use a lsm tree rather than btree for tables.
Stop using direct_io as it forces operations to sync more often, slowing
things down, at the expense of double-buffering (this will use more RAM).
2013-03-12 17:16:15 -04:00
Gregory Burd
c6eac27ea7 Start with a more rational default configuration. (Before you ask... the
answer is 'no').  So far there has been no effort to validate that these
settings are in fact the best for Riak/KV or CS data access patterns.  These
particular settings are, at best, an educated guess based on past experience,
the docs and reading about the benchmark the WiredTiger team published here:

https://github.com/wiredtiger/wiredtiger/wiki/YCSB-Mapkeeper-benchmark
2013-03-12 17:16:15 -04:00
Steve Vinoski
99b096caf3 check return value of wterl:session_create
Versions of WiredTiger prior to 1.3.3 had trouble handling riak restarts,
returning errors from wterl:session_create that would prevent riak from
restarting if it was not cleanly shut down on the previous run. We
previously avoided checking the return value of wterl:session_create to
avoid this problem. WT 1.3.3 fixes this, so reinstate the check of the
wterl:session_create return value.
2012-10-14 13:43:21 -04:00
Steve Vinoski
d7127b03e2 update to WiredTiger 1.3.3 2012-10-11 13:33:37 -04:00
Steve Vinoski
b2807e2c14 upgrade to WiredTiger version 1.3.0
Since 1.3.0 folded the session sync function into the session checkpoint
function, the wterl:sync/(2,3) functions are now renamed
wterl:checkpoint/(1,2). See
http://source.wiredtiger.com/1.3.0/upgrading.html for details.
2012-09-17 10:58:48 -04:00
Steve Vinoski
36d6c3bbad fix tests to use temp_riak_kv_backend module 2012-04-16 19:55:41 -04:00
Steve Vinoski
793c5c7338 allow WiredTiger config to be set in application env
WiredTiger connection options can be set in the wterl application
environment. If not set, appropriate defaults are used instead.
2012-04-09 16:50:01 -04:00
Steve Vinoski
509cc92cfc fix copyright dates 2012-04-09 16:49:26 -04:00
Steve Vinoski
145810d5b0 add wterl_ets to hold ets table for wterl_conn 2012-04-05 16:10:50 -04:00
Steve Vinoski
2618ba24e7 wterl:session_create still fails, keep ignoring return value 2012-04-04 15:57:38 -04:00
Steve Vinoski
fbc6f9b440 update to WiredTiger 1.1.3
Update to WiredTiger 1.1.3 and also reinstate checking that
wterl:session_create returns ok.
2012-04-04 15:20:08 -04:00
Steve Vinoski
6945ab230b add QuickCheck tests for wterl
Borrow QuickCheck tests from eleveldb and adapt them for WiredTiger.
2012-04-02 16:24:46 -04:00
Steve Vinoski
29acf9df7a make riak_kv_wterl_backend start the wterl app 2012-03-30 21:01:24 -04:00
Steve Vinoski
ae10343179 change riak_kv_wterl_backend unit tests
Make the unit tests call riak_kv_backend:standard_test like other
backends do for their unit tests. This is a little awkward at the
moment because riak_kv_backend.erl doesn't live in this repository, so
it requires temporarily copying it into src to run "rebar eunit".
2012-03-15 19:27:36 -04:00
Steve Vinoski
9c9075e70d add fold/3 to wterl.erl and fix dialyzer warnings
The backend fold_objects was failing because it was trying to use
wterl:fold_keys/3, which doesn't fold over values. Add fold/3 to
wterl.erl to fix this.

Also clean up a few dialyzer warnings.
2012-03-15 19:26:02 -04:00
Steve Vinoski
91a6acc2a4 add type specs 2012-03-11 20:18:59 -04:00
Steve Vinoski
7219281b31 increase session count and ignore table creation errors
WiredTiger session count defaults to 50, but we need at least one per
vnode, so for now hard-code it to 100. Also ignore table creation
results in the kv backend because WiredTiger is currently producing a
strange error if the table already exists.
2012-03-11 11:48:22 -04:00
Steve Vinoski
99a51980eb store session as kv backend state
In order to reduce the number of wiredtiger session open/close calls,
open a session at startup and keep it in the kv backend state. This is
safe as far as using these sessions on scheduler threads goes because
the riak_kv_vnode fsm serializes all calls through the backend, so
we'll never have a case of multiple scheduler threads concurrently
trying to use the same session.
2012-03-10 13:02:52 -05:00
Steve Vinoski
dc01981be8 add temp copy of riak_kv_backend
Add a temporary copy of riak_kv_backend, renamed to
temp_riak_kv_backend, to allow wterl to build on its own. This file
must be deleted when riak_kv_wterl_backend is moved to its proper
place in riak_kv.
2012-02-28 13:16:57 -05:00
Steve Vinoski
869efc46df add unit tests to wterl_conn 2012-02-27 22:01:27 -05:00
Steve Vinoski
8dcbe6c396 remove experimental test for now 2012-02-27 22:01:27 -05:00
Steve Vinoski
9177bd5c10 initial version of riak_kv_wterl_backend
The riak_kv_wterl_backend really belongs in riak_kv, but we're putting
it here for now to keep it private.
2012-02-27 22:01:27 -05:00
Steve Vinoski
6c0f14da6e add fold_keys, and funs for getting keys and values via cursors
Change cursor_{next,prev} to return {ok, Key, Value}. Add
cursor_{next,prev}_{key,value} functions to allow cursor movement
followed by fetch of either key or value. Add fold_keys function. Add
unit tests for these changes. Also specify "inorder" on the unit test
generator functions, since the tests they specified are intended to be
run that way.
2012-02-19 20:20:38 -05:00
Steve Vinoski
085e703a32 revised wterl tests to take advantage of eunit
Break the single wterl unit test into a series of tests separated by
function. Use eunit assert macros and add test setup and teardown
functions. Add descriptive messages for the tests for display under
"rebar -v eunit".
2012-02-17 23:16:00 -05:00
Steve Vinoski
7e6d947765 make wterl an app, cache the WT connection
Add app, supervisor, and worker to open and cache the database
connection. Revert to using binaries for WT config in order to allow
wterl callers to use proplists for configuration. Change {error,
not_found} to not_found return values from wterl.
2012-02-17 00:42:22 -05:00
Keith Bostic
212a735339 Implement the rest of the interesting cursor operations (insert, update, remove). 2012-02-16 19:06:56 -05:00
Keith Bostic
33b8ea60cf Implement the rest of the session methods.
Format pass, naming pass.
2012-02-16 18:44:28 -05:00
Keith Bostic
7a19859ede Rename table_{create,drop} session_{create,drop}, they operate on things
other than tables, and we no longer hardcode the object type.
2012-02-16 15:07:44 -05:00
Keith Bostic
6f0357b4c5 Fix cursor.{open,close}, it now works.
Add support for cursor.{next,prev,search,search_near,reset}.

Change table_create to no longer pass back the table name, WiredTiger's
model is that you pass in the object name each time (and the current
model means we can't drop the table before we run the tests).

Upgrade to the WiredTiger 1.0 release, there's a bug where static
libraries aren't created correctly, for now create shared libraries
for wterl.
2012-02-16 14:57:28 -05:00
Keith Bostic
5a7936bf1c Change the cursor open/close code to match other resources (RESOURCE structure that holds the
WiredTiger resource).

Change names to be consistent, open/XXX/close.

Add cursor next call.
2012-02-16 13:22:03 -05:00
Keith Bostic
33b25e6a2b Change the cache_size type to a string (it's usually something like 100MB,
not a pure integer).

Remove "exclusive" from the list of options, it's not in the 1.0 release.

Set the cache_size for the test, just to prove it works.
2012-02-16 10:54:21 -05:00
Gregory Burd
816e916658 Add cursor create/close functions. 2012-02-15 14:31:40 -05:00
Steve Vinoski
b93946a5e0 more WiredTiger prototyping
A number of changes:

* Added exported functions to close connections and sessions.

* Added exported functions to create and drop tables. Currently not
  happy with the shape of these functions, though, as they treat
  tables in Erlang just as strings, and they force users of sessions
  to have to pass both sessions and tables into get/put/delete
  operations. It might be better to take a table identifier as part of
  the session creation function and store that identifier with the
  session resource.

* Added implementations for key-value get, put, and delete.

* Added very minimal unit tests for the changes above.
2012-02-08 17:31:16 -05:00
Dave Smith
dcb4270f9d Basics of conn/session instantiation working 2011-12-21 21:46:35 -07:00