Commit Graph

22 Commits

Author SHA1 Message Date
Avi Kivity
ad54edb047 tests: use memtable instead of column_family where appropriate
Requires less configuration.
2015-05-17 10:31:22 +03:00
Tomasz Grabiec
b1e45e4401 db: Store ttl in atomic_cell
Origin does that, so should we. Both ttl and expiry time are stored in
sstables. The value of ttl seems to be used to calculate the read
digest (expiry is not used for that).

The API for creating atomic_cells changed a bit.

To create a non-expiring cell:

  atomic_cell::make_live(timestamp, value);

To create an expiring cell:

  atomic_cell::make_live(timestamp, value, expiry, ttl);

or:

  // Expiry is calculated based on current clock reading
  atomic_cell::make_live(timestamp, value, ttl_optional);
2015-05-06 19:42:38 +02:00
Tomasz Grabiec
5ba1486ae7 db: Rename "ttl" to "expiry" when it's used as time point
To avoid confusion with "ttl" the duration.
2015-05-06 17:27:22 +02:00
Tomasz Grabiec
46e72cbc64 tests: Introduce perf_hash.cc, hashing benchmark
Output on my laptop:

$ build/release/tests/perf/perf_hash
Timing fixed hash...
28671657.15 tps
28720930.45 tps
28622017.20 tps
28677088.01 tps
29223543.70 tps
Timing iterator hash...
22023042.57 tps
21953352.04 tps
21393787.05 tps
21613837.10 tps
21563284.57 tps
2015-04-30 11:16:53 +02:00
Tomasz Grabiec
06f198b10c schema: Add id field
It uniquely identifies column_family globally. Will be used for
column_family lookups.
2015-04-15 20:33:48 +02:00
Tomasz Grabiec
64579026e6 tests: Rework perf_simple_query to be more parametrizable
It also now supports testing of the write path.
2015-04-15 20:33:47 +02:00
Avi Kivity
30b40bf7b1 db: make bytes even more distinct from sstring
bytes and sstring are distinct types, since their internal buffers are of
different length, but bytes_view is an alias of sstring_view, which makes
it possible of objects of different types to leak across the abstraction
boundary.

Fix this by making bytes a basic_sstring<int8_t, ...> instead of using char.
int8_t is a 'signed char', which is a distinct type from char, so now
bytes_view is a distinct type from sstring_view.

uint8_t would have been an even better choice, but that diverges from Origin
and would have required an audit.
2015-04-07 10:56:19 +03:00
Tomasz Grabiec
d21966ecbc Revert "tests: Use lowres_clock in time_it()"
This reverts commit e605a0368a.

lowres_clock is not updated when reactor is not running and this
variant of time_it() is not meant to be run in a rector.
2015-03-30 18:38:26 +02:00
Tomasz Grabiec
121fa4ff46 test: Introduce test for in-memory CQL query performance
The schema and queries resemble that used by cassandra-stress.

Results on my laptop:

$ build/release/tests/perf/perf_simple_query -c1
Concurrency = 100 x 1
Creating 1000 partitions...
Timing single key selects...
452146.50 tps
449365.24 tps
457650.58 tps
460334.78 tps
458281.51 tps
Timing random key selects...
439181.03 tps
449899.67 tps
405146.90 tps
440228.84 tps
440889.50 tps

$ build/release/tests/perf/perf_simple_query -c3
Concurrency = 100 x 3
Creating 1000 partitions...
Timing single key selects...
302615.08 tps
301471.02 tps
303040.67 tps
302114.77 tps
302465.13 tps
Timing random key selects...
627516.46 tps
628978.04 tps
623664.15 tps
624098.48 tps
614549.85 tps
2015-03-25 12:59:25 +01:00
Tomasz Grabiec
8f73f7df47 tests: Add time_parallel() utility 2015-03-25 12:59:25 +01:00
Tomasz Grabiec
b829062985 tests: Make time_it() template static 2015-03-25 10:36:19 +01:00
Tomasz Grabiec
e605a0368a tests: Use lowres_clock in time_it() 2015-03-25 10:36:19 +01:00
Tomasz Grabiec
e3422525c0 Use column_definition via const reference 2015-03-24 12:03:00 +01:00
Tomasz Grabiec
bdbd5547e3 db: Cleanup key names
clustering_key::one -> clustering_key
clustering_key::prefix::one -> clustering_key_prefix
partition_key::one -> partition_key
clustering_prefix -> exploded_clustering_prefix
2015-03-20 18:59:29 +01:00
Tomasz Grabiec
90298af614 db: Cleanup atomic_cell naming
atomic_cell -> atomic_cell_type
atomic_cell::one -> atomic_cell
atomic_cell::view -> atomic_cell_view
2015-03-20 18:59:29 +01:00
Tomasz Grabiec
1b1af8cdfd db: Introduce types to hold keys
Holding keys and their prefixes as "bytes" is error prone. It's easy
to mix them up (or use wrong types). This change adds wrappers for
keys with accessors which are meant to make misuses as difficult as
possible.

Prefix and full keys are now distinguished. Places which assumed that
the representation is the same (it currently is) were changed not to
do so. This will allow us to introduce more compact storage for non-prefix
keys.
2015-03-17 15:56:29 +01: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
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
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
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