Commit Graph

170 Commits

Author SHA1 Message Date
Avi Kivity
9b39bd410e Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-03-08 15:02:24 +02:00
Tomasz Grabiec
7502f2a3a3 tests: Add test for returning bare values from callbacks 2015-03-06 11:35:56 +01:00
Raphael S. Carvalho
41846256d8 tests: fix fileiotest
engine() cannot be called before the local_engine was constructed because it
dereferences the pointer local_engine to create a reference.
Consequently, the following error can be seen while running fileiotest:
./core/reactor.hh:854:13: runtime error: reference binding to null pointer of
type 'struct reactor' ASAN:SIGSEGV

Let's switch the test to use app_template.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-06 10:06:16 +02:00
Tomasz Grabiec
3db3207b85 Merge branch seastar-dev.git 'collections'
Collections support from Avi.
2015-03-05 20:25:48 +01:00
Avi Kivity
6126670078 mutation_test: test maps 2015-03-05 20:03:57 +02:00
Calle Wilund
054f9ed082 Initial commit log support.
Implements a cassandra-file-compatible segmented log
of "mutations". Handles "batch" and "periodic" mode like
stock version. Also includes "dirty" management for the
interaction log/memtable.

Supports:
* add
* sync/flush
* clear dirty bits (thus discarding segments)

Many more estoric stock functions not yet implemented.

Missing: Storage management. Does not deal with total
size on disk of segments yet. Nor does it have any provisions
for dealing with active buffer bloat should async writes stall.

[avi: adjust for future<>::rescue() removal]
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-03-05 11:06:09 +02:00
Avi Kivity
5902243dc5 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Global adjustment due to the removal of future<>::rescue().
2015-03-05 11:00:11 +02:00
Tomasz Grabiec
83963b23d3 Replace rescue() usages with then_wrapped()
They are pretty much the same. This change removes rescue().
2015-03-04 17:34:59 +01:00
Raphael S. Carvalho
89ec1f8f6a slab: Add reclaimer functionality
Basic explanation of the reclaimer algorithm:
- Each slab page has a descriptor containing information about it, such as
refcnt, vector of free objects, link into LRU, etc.
- The LRU list will only contain slab pages which items are unused, so as
to make the reclaiming process faster and easier. Maintaining the LRU of slab
pages has a performance penalty of ~1.3%. Shlomi suggested an approach where
LRU would no longer exist and timestamp would be used instead to keep track of
recency. Reclaimer would then iterate through all slab pages checking for an
unused slab page with the lowest timestamp.
- Reclaimer will get the least-recently-used slab page from the LRU list,
do all the management stuff required, and iterate through the page erasing any
of the items there contained. Once reclaimer was called, it's likely that slab
memory usage is calibrated, thus slab pages shouldn't be allocated anymore.
- Reclaimer is enabled by default but can be disabled by specifying the slab
size using the application parameter --max-slab-size.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-04 17:40:58 +02:00
Avi Kivity
a49330095a db: wrap bytes in atomic_cell format
We use bytes for many different things, and it is easy to get confused as
to what format the data is actually in.

Fix that for atomic_cell by proving wrappers.  atomic_cell::one corresponds
to a bytes object holding exactly one atomic cell, and atomic_cell::view is
a bytes_view to an atomic_cell.  The static functions of atomic_cell itself
are privatized to prevent the unwashed masses from using them on the wrong
objects.

Since a row entry can hold either a an atomic cell, or a collection,
depending on the schema, also introduce a variant type
atomic_cell_or_collection and allow the user to pick the type explicitly.
Internally both are stored as bytes object.
2015-03-04 15:49:35 +02:00
Pekka Enberg
d6b5caa1f3 tests: Convert cql_query_test to use Boost.Test
Use Boost.Test so that we can easily specify multiple test cases.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-04 13:16:17 +01:00
Pekka Enberg
99a09020e8 types: Fix bytes_type_impl string conversion
Tomek points out that:

  Origin calls org.apache.cassandra.utils.Hex#hexToBytes here, which is
  not what to_bytes() does. BytesType.getSerializer().toString() calls
  ByteBufferUtil.bytesToHex(value), so you should call to_hex() here.

Fix that up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-02 10:38:27 +01:00
Tomasz Grabiec
74295a9759 db: Use opaque bytes for cell values instead of boost::any
Storing cells as boost::any objects makes us use expensive
boost::any_cast to access the data. This change replaces boost::any
with bytes object which holds the value in serialized form (the same
as will be used for on-wire format).

If the cell type is atomic, you use fields accessors defined in
atomic_cell class, eg like this:

if (column.type.is_atomic()) {
   if (atomic_cell::is_live(c) {
      auto timestamp = atomic_cell::timestamp(c);
      ...
   }
}

Eventually we could switch to a more officient semi-serialized form
with native byte order but I don't want to introduce it just yet for
simplicity.
2015-02-27 10:59:43 +01:00
Tomasz Grabiec
a61d9ee18e schema: Add static columns to schema 2015-02-27 10:48:56 +01:00
Tomasz Grabiec
f21d85cfc5 tests: Stop distributed db when test ends
Fixes:

cql_query_test: ./core/distributed.hh:150: distributed<Service>::~distributed() [with Service = database]: Assertion `_instances.empty()' failed.
2015-02-27 10:48:55 +01:00
Glauber Costa
8015b1c1bb sstable: unit tests
This tests the sstable parsing code. The tables provided as exemple are real
tables, that I was using to test my code manually.

The corrupt tables, however, are corrupted by hand.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 12:14:20 -05:00
Avi Kivity
d39c844ea3 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	configure.py
	database.cc (added missing include)
	utils/serialize.hh (added missing inlines)
2015-02-26 17:57:18 +02:00
Glauber Costa
6b77cf7d08 linecount: change rw to ro
Avi says it is enough.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 17:30:02 +02:00
Glauber Costa
9861bfca01 open_file_dma: allow the specification of open flags
It is sometimes frustrating to use open_file_dma, because it has the hardcoded
behavior of always assuming O_CREAT. Sometimes this is not desirable, and it
would be nice to have the option not to do so.

Note that, by design, I am only including in the open_flags enum things that we
want the user of the API to control. Stuff like O_DIRECT should not be
optional, and therefore is not included in the visible interface.

Because of that I am changing the function signature to include a paramater
that specifies whether or not we should create the file if it does not exist.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 17:30:02 +02:00
Pekka Enberg
a3b2a70f65 tests/perf: CQL statement parser performance test
Add a performance test case for CQL statement parsing to better
understand its performance impact. We also include ANTLR tokenizer and
parser setup as that's what we do in query_processor for each request.

Running the test on my Haswell machine yields the following results:

  [penberg@nero urchin]$ build/release/tests/perf/perf_cql_parser
  Timing CQL statement parsing...
  108090.10 tps
  125366.11 tps
  124400.64 tps
  124274.75 tps
  124850.85 tps

That means that CQL parsing alone sets an upper limit of 120k requests
per second for Urchin for a single core.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-26 14:14:53 +01:00
Tomasz Grabiec
cd7a05660e tests: Simplify schema object construction 2015-02-26 10:03:19 +02:00
Raphael S. Carvalho
67560bec48 test: Add slab allocator testcase
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-25 19:32:57 -03:00
Tomasz Grabiec
e0bff0c28e tests: Add test exploiting dynamic_pointer_cast bug 2015-02-25 11:56:07 +02:00
Avi Kivity
2720ba34bf db: shard data
Add database::shard_of() to compute the shard hosting the partition
(with a simplistic algorithm, but perhaps not too bad).

Convert non-metadata invoke_on_all() and local calls on the database
to use shard_of().
2015-02-23 11:37:12 +02:00
Avi Kivity
83430355c2 Merge branch 'master' of github.com:cloudius-systems/seastar into db
LICENSE moved to LICENSE.seastar, since (at least for now) urchin is
not open source.

Conflicts:
	apps/seastar/main.cc
2015-02-22 16:23:59 +02:00
Avi Kivity
70381a6da5 db: distribute database object
s/database/distributed<database>/ everywhere.

Use simple distribution rules: writes are broadcast, reads are local.
This causes tremendous data duplication, but will change soon.
2015-02-19 17:53:13 +02:00
Avi Kivity
7f8d88371a Add LICENSE, NOTICE, and copyright headers to all source files.
The two files imported from the OSv project retain their original licenses.
2015-02-19 16:52:34 +02:00
Avi Kivity
07bb7cceb1 tests: fix mutation_test debug build 2015-02-18 20:09:41 +02:00
Tomasz Grabiec
f943555571 service: Convert client_state constructors 2015-02-16 12:15:08 +01:00
Avi Kivity
39596a0334 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	configure.py
2015-02-15 09:58:29 +02:00
Tomasz Grabiec
6a998e2d78 tests: Add test for parsing and execution of CQL3 queries 2015-02-12 19:40:59 +01:00
Avi Kivity
ebc2ebbf12 Upgrade http_client to an application, not a test
and rename it to 'seawreck', after wrk.
2015-02-12 14:21:44 +02:00
Asias He
51adb20bda tests: Add http_client
It is based on tcp_client and works with our httpd server.

1) timer based, to run the test for 10 seconds
$ http_client --server 192.168.66.100:10000 --conn 100  --duration 10 --smp 2
========== http_client ============
Server: 192.168.66.100:10000
Connections: 100
Requests/connection: dynamic (timer based)
Requests on cpu 0: 33400
Requests on cpu 1: 33368
Total cpus: 2
Total requests: 66768
Total time: 10.011478
Requests/sec: 6669.145442
========== done ============

2) nr of reqs per connection based, to run the test with 100 connections
each has to run 1000 reqs
$ http_client --server 192.168.66.100:10000 --conn 100 --reqs 1000 --smp 2
========== http_client ============
Server: 192.168.66.100:10000
Connections: 100
Requests/connection: 1000
Requests on cpu 0: 50000
Requests on cpu 1: 50000
Total cpus: 2
Total requests: 100000
Total time: 15.002731
Requests/sec: 6665.453192
========== done ============

This patch is based on Shlomi's initial version.

Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
Signed-off-by: Asias He <asias@cloudius-systems.com>
2015-02-12 10:02:48 +02:00
Avi Kivity
64930bc610 tests: add linecount tests
Demonstrates and tests file_input_stream.
2015-02-11 15:38:51 +02:00
Tomasz Grabiec
10e58e0cda tests: Make test runner catch and forward exceptions thrown directly from task 2015-02-10 14:47:42 +02:00
Tomasz Grabiec
85c67001dd tests: Add test for exceptions thrown from do_until() 2015-02-10 14:47:42 +02:00
Tomasz Grabiec
fb6941bbee tests: Add test for row tombstones 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
138ed6faac tests: Add test for tuple_type::is_prefix_of() 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
543cc40d1a tests: Add performance test for in-memory row mutation
It shows that our serialization code, which is using ostringstream
under the hood, is really dragging us down. In the perf profile we can
see dynamic casts high called from iostream classes, called from
abstract_type::decompose()

$ taskset -c 0 build/release/tests/perf/perf_mutation
Timing mutation of single column within once row
83536.54 tps
115157.06 tps
85059.52 tps
60443.80 tps
112878.47 tps

$ perf report
-  11,66%    perf_mutation  libstdc++.so.6.0.20         [.] __cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1:▒
   + __cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__c◆
   - __dynamic_cast                                                                                                                                                    ▒
      - 43,58% std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_get<char, std::istreambuf_iterator<char, std▒
           std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&)                                                                          ▒
         - std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)                                                   ▒
              92,70% std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::basic_istringstream(std::string const&, std::_Ios_Openmode)        ▒
            + 7,30% abstract_type::decompose(boost::any const&)                                                                                                        ▒
      - 27,36% bool std::has_facet<std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
           std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&)                                                                          ▒
         - std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)                                                   ▒
              93,14% std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::basic_istringstream(std::string const&, std::_Ios_Openmode)        ▒
            + 6,86% abstract_type::decompose(boost::any const&)                                                                                                        ▒
      + 14,54% bool std::has_facet<std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
      + 14,52% std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_put<char, std::ostreambuf_iterator<char, std▒
-   9,97%    perf_mutation  libstdc++.so.6.0.20         [.] __dynamic_cast                                                                                             ▒
   - __dynamic_cast                                                                                                                                                    ▒
      + 19,67% std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_get<char, std::istreambuf_iterator<char, std▒
      + 18,66% std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_put<char, std::ostreambuf_iterator<char, std▒
      + 16,72% bool std::has_facet<std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
      + 15,16% bool std::has_facet<std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
      + 15,04% bool std::has_facet<std::ctype<char> >(std::locale const&)                                                                                              ▒
      + 14,74% std::ctype<char> const& std::use_facet<std::ctype<char> >(std::locale const&)                                                                           ▒
-   7,98%    perf_mutation  libstdc++.so.6.0.20         [.] __cxxabiv1::__vmi_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1▒
   - __cxxabiv1::__vmi_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__▒
   - __dynamic_cast                                                                                                                                                    ▒
      - 77,13% std::ctype<char> const& std::use_facet<std::ctype<char> >(std::locale const&)                                                                           ▒
           std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&)                                                                          ▒
         + std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)                                                   ▒
      + 22,87% bool std::has_facet<std::ctype<char> >(std::locale const&)                                                                                              ▒
+   6,45%    perf_mutation  libstdc++.so.6.0.20         [.] std::locale::locale()                                                                                      ▒
+   6,40%    perf_mutation  libstdc++.so.6.0.20         [.] std::locale::~locale()                                                                                     ▒
+   5,02%    perf_mutation  libstdc++.so.6.0.20         [.] std::locale::operator=(std::locale const&)                                                                 ▒
+   4,18%    perf_mutation  libc-2.19.so                [.] __GI___strcmp_ssse3                                                                                        ▒
2015-02-09 10:28:45 +01:00
Tomasz Grabiec
2244eab6c1 db: Steal data from mutations when applying
Taking mutations by r-value reference allows us to avoid copies.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
28915bf673 tests: Add test for applying mutations 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
ee10d9b437 tests: Add test for int32_type string conversions 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
5049ed8ae6 Merge branch 'master' of github.com:cloudius-systems/seastar 2015-01-30 09:34:58 +01:00
Avi Kivity
94e01e6d0e tests: exit after timertest ends 2015-01-29 12:24:03 +02:00
Avi Kivity
070eb7d496 tests: serialize timer tests
Otherwise the output gets interspersed.
2015-01-29 12:20:39 +02:00
Tomasz Grabiec
661bb3d478 tests: Use test_runner to run boost tests 2015-01-29 10:30:14 +02:00
Tomasz Grabiec
a1fecad8cb tests: Introduce test_runner class
It uses app_template to launch seastar framework and can be used from
outside threads to inject tasks.
2015-01-29 10:30:14 +02:00
Tomasz Grabiec
8ad50d6614 core: Add exchanger class 2015-01-29 10:30:13 +02:00
Takuya ASADA
9de86ed651 tests: Support tcp_server tests(ping,txtx,rxrx) on tcp_client
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-28 16:26:46 +02:00
Avi Kivity
d5540bf3da Merge branch 'master' into db 2015-01-27 15:09:31 +02:00