Commit Graph

47 Commits

Author SHA1 Message Date
Paweł Dziepak
b6f78a8e2f sstable: make sstable reads return streamed_mutation
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-06-20 21:29:50 +01:00
Duarte Nunes
dc8319ed91 keys: Remove schema argument from make_empty
An empty key is independent of the schema.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-06-02 16:21:36 +02:00
Pekka Enberg
4e04805352 cql3: Make lexer and parser error messages compatible with Cassandra
The default recognition error messages in antlr C++ backend are
different from Java backend which makes Scylla's CQL error messages
incompatible with Cassandra. This makes it very hard to write CQL level
test cases which are portable between Scylla and Cassandra.

To fix the issue, override the most common lexer and parser error
messages to follow the convention set by the antlr Java backend. This
unlocks various test cases in AlterTest, for example.
Message-Id: <1460032883-14422-1-git-send-email-penberg@scylladb.com>
2016-04-11 12:35:53 +03:00
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Tomasz Grabiec
341b509f68 cql_test_env: Make initialization exception-safe
Currently start() is not prepared to handle exceptions thrown from
service initialization. It's easy to trigger such exceprion by
starting two tests at the same time, which will result in socket bind
error.

Exception thrown from start() typically results in assertion failures
like this one:

  seastar::sharded<Service>::~sharded() [with Service = database]: Assertion `_instances.empty()' failed.

This patch fixes the problem by combining start() and stop() in a
single do_with() and using RAII for stopping services.

Now exceptions thrown from service initialization should stop services
in proper order and let the original exception to pass
through. Example result:

  fatal error in "test_new_schema_with_no_structural_change_is_propagated": std::runtime_error: bind: Address already in use
Message-Id: <1458768018-27662-1-git-send-email-tgrabiec@scylladb.com>
2016-03-24 11:20:01 +02:00
Tomasz Grabiec
6e73c3f3dc perf_simple_query: Make duration configurable 2016-03-21 21:49:53 +01:00
Benoît Canet
1fb9a48ac5 exception: Optionally shutdown communication on I/O errors.
I/O errors cannot be fixed by Scylla the only solution
is to shutdown the database communications.

Signed-off-by: Benoît Canet <benoit@scylladb.com>
Message-Id: <1458154098-9977-1-git-send-email-benoit@scylladb.com>
2016-03-17 15:02:52 +02:00
Vlad Zolotarov
0f8090d6c7 tests: use steady_clock where monotinic clock is required
Use steady_clock instead of high_resolution_clock where monotonic
clock is required. high_resolution_clock is essentially a
system_clock (Wall Clock) therefore may not to be assumed monotonic
since Wall Clock may move backwards due to time/date adjustments.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-12-27 18:08:15 +02:00
Glauber Costa
3c988e8240 perf_sstable: use current scylla default directory
When this tool was written, we were still using /var/lib/cassandra as a default
location. We should update it.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2015-12-09 17:46:31 +02:00
Avi Kivity
2c3591cbd9 data_value de-any-fication
We use boost::any to convert to and from database values (stored in
serlialized form) and native C++ values.  boost::any captures information
about the data type (how to copy/move/delete etc.) and stores it inside
the boost::any instance.  We later retrieve the real value using
boost::any_cast.

However, data_value (which has a boost::any member) already has type
information as a data_type instance.  By teaching data_type intances about
the corresponding native type, we can elimiante the use of boost::any.

While boost::any is evil and eliminating it improves efficiency somewhat,
the real goal is growing native type support in data_type.  We will use that
later to store native types in the cache, enabling O(log n) access to
collections, O(1) access to tuples, and more efficient large blob support.
2015-10-30 17:38:51 +01:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Avi Kivity
987294a412 Add missing copyrights 2015-09-20 10:16:11 +03:00
Tomasz Grabiec
10453c71d2 tests: perf: Make iterations between clock readings in time_it() configurable 2015-09-07 09:41:36 +02:00
Paweł Dziepak
4b9791230a tests/perf/simple_query: fix write mode
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-31 17:25:32 +02:00
Avi Kivity
c734ef2b72 Merge seastar upstream
* seastar 10e09b0...2e041c2 (7):
  > Merge "Change app_template::run() to terminate when callback is done" from Tomasz
  > resource: Fix compilation for hwloc version 1.8.0
  > memory: Fix infinite recursion when throwing std::bad_alloc
  > core/reactor: Throw the right error code when connect() fails
  > future: improve exception safety
  > xen: add missing virtual destructors
  > circular_buffer: do not destroy uninitialized object

app_template::run() users updated to call app_template::run_depracated().
2015-08-28 23:52:49 +03:00
Glauber Costa
bd272fe6aa perf_sstable: test sequential reads from an sstable.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-27 09:02:11 -05:00
Glauber Costa
b194509a6d perf_write: test for full writes
it writes 5 columns (configurable) per row. This will exercise other paths
aside from the index.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-27 09:02:11 -05:00
Glauber Costa
dcd312a982 perf_sstable: more than just the index
My plan was originally to have two separate sets of tests: one for the index,
and one for the data. With most of the code having ended up in the .hh file anyway,
this distinction became a bit pointless.

Let's put it everything here.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-27 09:02:11 -05:00
Glauber Costa
b3b0aff85e perf_sstable_index: add test for index_read
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-27 09:02:11 -05:00
Glauber Costa
873cf17cf4 sstable tests: allow for the creation of sstables of non-default buffer size.
This can now be used in the sstable_index_write performance test.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-25 18:31:50 -05:00
Glauber Costa
f4d8310d88 perf_sstable_index: calculate time spent before the map reduce operation.
Not doing that will include the smp communication costs in the total cost of
the operation. This will not very significant when comparing one run against
the other when the results clearly differ, but the proposed way yields error
figures that are much lower. So results are generally better.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-25 18:31:49 -05:00
Glauber Costa
19d25130af perf_sstable_index: make parallelism an explicit option
As we have discussed recently, the sstable writer can't even handle intra-core
parallelism - it has only one writer thread per core, and for reads, it affects
the final throughput a lot.

We don't want to get rid of it, because in real scenarios intra-core
parallelism will be there, specially for reads. So let's make it a tunable so we
can easily test its effect on the final result.

The iterations are now all sequential, and we will run x parallel invocation at
each of them.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-25 18:31:49 -05:00
Avi Kivity
e7272d27cc tests: perf_mutation: convert to app_template
Won't work with lsa without it, due to too small default memory size.
2015-08-19 11:18:07 +03:00
Glauber Costa
4ddef06ba6 perf tests: test sstables index reads and writes
This is a test that allow us to query the performance of our sstable index
reads and writes (currently only writes implemented). A lot of potentially
common code is put into a header, which will make writing new tests easier if
needed.

We don't want to take shortcuts for this, so all reading and writing is done
through public sstable interfaces.

For writing, there is no way to write the index without writing the datafile.
But because we are only writing the primary key, the datafile will not contain
anything else. This is the closest we can get to an index testing with the
public interfaces.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-12 09:18:37 -05:00
Avi Kivity
c720cddc5c tests: mv tests/urchin/* -> tests/
Now that seastar is in a separate repository, we can use the tests/
directory.
2015-08-05 14:16:52 +03:00
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