Commit Graph

40 Commits

Author SHA1 Message Date
Benny Halevy
68bd748af2 repair: row_level: clear_gently: clear_gently each repair_row
Rows might be large so free them gently by:
- add bytes_ostream.clear_gently that may yield in the chunk
  freeing loop.
- use that in frozen_mutation_fragment, contained in repair_row.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2021-07-01 19:16:11 +03:00
Avi Kivity
a55b434a2b treewide: extent copyright statements to present day 2021-06-06 19:18:49 +03:00
Avi Kivity
74df67776b bytes_ostream: convert write_placeholder from enable_if to concepts
Concepts are easier to read and result in better error messages.

This change also tightens the constraint from "std::is_fundamental" to
"std::integral". The differences are floating point values, nullptr_t,
and void. The latter two are illegal/useless to write, and nobody uses
floating point values for list lengths, so everything still compiles.

Closes #8326
2021-03-22 12:00:07 +01:00
Michał Chojnowski
5c3385730b treewide: get rid of unaligned_cast
unaligned_cast violates strict aliasing rules. Replace it with
safe equivalents.
2021-03-17 17:00:41 +01:00
Benny Halevy
ff5b42a0fa bytes_ostream: max_chunk_size: account for chunk header
Currently, if the data_size is greater than
max_chunk_size - sizeof(chunk), we end up
allocating up to max_chunk_size + sizeof(chunk) bytes,
exceeding buf.max_chunk_size().

This may lead to allocation failures, as seen in
https://github.com/scylladb/scylla/issues/7950,
where we couldn't allocate 131088 (= 128K + 16) bytes.

This change adjusted the expose max_chunk_size()
to be max_alloc_size (128KB) - sizeof(chunk)
so that the allocated chunks would normally be allocated
in 128KB chunks in the write() path.

Added a unit test - test_large_placeholder that
stresses the chunk allocation path from the
write_place_holder(size) entry point to make
sure it handles large chunk allocations correctly.

Refs #7950
Refs #8081

Test: unit(release), bytes_ostream_test(debug)
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Message-Id: <20210303143413.902968-1-bhalevy@scylladb.com>
2021-03-10 19:54:12 +02:00
Piotr Jastrzebski
0605d9e8ed bytes_ostream: Remove std::iterator from fragment_iterator
std::iterator is deprecated since C++17 so define all the required
iterator_traits directly.

Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2020-11-17 16:53:20 +01:00
Botond Dénes
875314fc4b bytes_ostream: make it a FragmentRange
The presence of `const_iterator` seems to be a requirement as well
although it is not part of the concept. But perhaps it is just an
assumption made by code using it.
2019-12-02 10:10:31 +02:00
Botond Dénes
07007edab9 bytes_ostream: add output_iterator
To allow it being used for serialization code, which works in terms of
output iterators.
2019-12-02 10:10:31 +02:00
Tomasz Grabiec
f206ef0038 bytes_ostream: Optimize writing of fixed-size types
Inlining write() allows the writing code to be optimized for
fixed-size types. In particular, memcpy() calls and loops will be
eliminated.

Saw 4% improvement in throughput in perf_fast_forward for tiny rows.
2018-12-10 20:08:16 +01:00
Tomasz Grabiec
a1fb441df8 bytes_ostream: Implement clear() 2018-12-10 20:07:43 +01:00
Tomasz Grabiec
7cf5de3d9c bytes_ostream: Make initial chunk size configurable 2018-12-10 20:07:43 +01:00
Paweł Dziepak
91793c0a43 bytes_ostream: drop appending_hash specialisation
appending_hash is used for computing hashes that become part of the
binary interface. They cannot change between Scylla version and the same
data needs to always result in the same hash.

At the moment, appending_hash<bytes_ostream> doesn't fulfil those
requirements since it leaks information how the underlying buffer is
fragmented. Fortunately, it has no users so it doesn't casue any
compatibility issues.

Moreover, bytes_ostream is usually used as an output of some
serialisation routine (e.g. frozen_mutation_fragment or CQL response).
Those serialisation formats do not guarantee that there is a single
representation of a given data and therefore are not fit to be hashed by
appending_hash. Removing appending_hash<bytes_ostream> may help
preventing such incorrect uses.
Message-Id: <20181122163823.12759-1-pdziepak@scylladb.com>
2018-11-22 23:53:54 +00:00
Avi Kivity
775b7e41f4 Update seastar submodule
* seastar d59fcef...b924495 (2):
  > build: Fix protobuf generation rules
  > Merge "Restructure files" from Jesse

Includes fixup patch from Jesse:

"
Update Seastar `#include`s to reflect restructure

All Seastar header files are now prefixed with "seastar" and the
configure script reflects the new locations of files.

Signed-off-by: Jesse Haber-Kucharsky <jhaberku@scylladb.com>
Message-Id: <5d22d964a7735696fb6bb7606ed88f35dde31413.1542731639.git.jhaberku@scylladb.com>
"
2018-11-21 00:01:44 +02:00
Paweł Dziepak
00a63663d6 bytes_ostream: increase max chunk size to 128 kB
128 kB is the size of the LSA segment and therefore the default size of
any kind of chunks, fragments and buffers.

Message-Id: <20180709155615.22500-1-pdziepak@scylladb.com>
2018-07-09 19:59:51 +03:00
Paweł Dziepak
fe8dc1fa5c bytes_ostream: add remove_suffix() 2018-06-25 09:21:47 +01:00
Paweł Dziepak
a85197a7b5 bytes_ostream: make fragment_iterator default constructible 2018-06-25 09:21:47 +01:00
Avi Kivity
65c27ccf21 bytes_ostream: make max_chunk_size() an inline function
Fixes debug build looking for a variable definition and not finding it.
2016-10-17 11:49:33 +03:00
Avi Kivity
c0a1ad0b77 bytes_ostream: use larger allocations
A 1MB response will require 2000 allocations with the current 512-byte
chunk size.  Increase it exponentially to reduce allocation count for
larger responses (still respecting the upper limit).
Message-Id: <1476369152-1245-1-git-send-email-avi@scylladb.com>
2016-10-16 10:05:48 +01:00
Gleb Natapov
32989d1e66 Merge seastar upstream
* seastar 2b55789...5b7252d (3):
  > Merge "rpc: serialize large messages into fragmented memory" from Gleb
  > Merge "Print backtrace on SIGSEGV and SIGABRT" from Tomasz
  > test_runner: avoid nested optionals

Includes patch from Gleb to adapt to seastar changes.
2016-09-28 17:34:16 +03:00
Paweł Dziepak
387434a76c bytes_ostream: add reduce_chunk_count()
Deserialization code has now two variants. The faster one can be used
only when the source buffer is not fragmented. reduce_chunk_count() aims
to increase number of cases when the fast path can be used.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-08-22 09:31:33 +01:00
Paweł Dziepak
7d4b7fd5fc bytes_ostream: add equality operator
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-08-22 09:31:33 +01:00
Paweł Dziepak
222bde7e6f bytes_ostream: introduce upper bound on chunk size
This patch makes append() and write() limit the maximum size of a single
allocation to bytes_ostream::max_chunk_size.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-08-22 09:31:33 +01:00
Avi Kivity
1d1f61ac65 bytes_ostream: fix assignment operators
Protect against self-assignment, and provide the strong exception guarantees
for copying assignment.

Fixes #1499.
Message-Id: <1469466156-11114-1-git-send-email-avi@scylladb.com>
2016-07-25 19:06:42 +02: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
2abd62b5cb bytes_ostream: Drop methods which serialize integers
This will make bytes_ostream completely agnostic to serialization
format, which should be determined by layer above it.

Message-Id: <1457004221-8345-2-git-send-email-tgrabiec@scylladb.com>
2016-03-03 13:27:27 +02:00
Tomasz Grabiec
0c8db777b1 bytes_ostream: Avoid recursion when freeing chunks
When there is a lot of chunks we may get stack overflow.

This seems to fix issue #906, a memory corruption during schema
merge. I suspect that what causes corruption there is overflowing of
the stack allocated for the seastar thread. Those stacks don't have
red zones which would catch overflow.

Message-Id: <1456056288-3983-1-git-send-email-tgrabiec@scylladb.com>
2016-02-21 14:18:49 +02:00
Amnon Heiman
ca72d637f9 bytes_ostream: Allow place holder return a stream
Reader and writer can use the bytes_ostream as a raw bytes stream,
handling the bytes encoding and streaming on their own.

To fully support this functionality, place holder should support it as
well.

This patch adds a get_stream method that return a simple_output_stream
writer can use it using their own serialization function.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2016-02-17 18:42:04 +02:00
Tomasz Grabiec
c971544e83 bytes_ostream: Adapt to Output concept used in serializer.hh
Message-Id: <1453888242-2086-1-git-send-email-tgrabiec@scylladb.com>
2016-01-27 12:13:34 +02:00
Tomasz Grabiec
eb1b21eb4b Introduce hashing helpers 2016-01-08 21:10:25 +01:00
Avi Kivity
098136f4ab Merge "Convert serialization of query::result to use db::serializer<>" from Tomasz
Reviewed-by: Nadav Har'El <nyh@scylladb.com>
2015-12-07 16:53:34 +02:00
Tomasz Grabiec
657841922a Mark move constructors noexcept when possible 2015-12-07 09:50:27 +01:00
Tomasz Grabiec
d4d3a5b620 bytes_ostream: Make size_type and value_type public 2015-12-03 09:19:11 +01:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Pekka Enberg
5164932f1e bytes_ostream: Fix current_space_left()
We also allocate chunks larger than "usable_chunk_size" in alloc(). Fix
up the calculation in current_space_left().

Spotted by ASan.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 13:00:31 +03:00
Tomasz Grabiec
c742529e52 bytes_ostream: Introduce retract()
Useful for optimistic writers, where it's easier/cheaper to retract
later than to calculate the decision up front.
2015-07-09 19:55:00 +02:00
Tomasz Grabiec
c3f7856853 bytes_ostream: Introduce fragment iterator 2015-07-09 18:53:03 +02:00
Tomasz Grabiec
72a6f80ce5 bytes_ostream: Introduce write_place_holder() for arbitrary size 2015-07-04 13:46:31 +02:00
Pekka Enberg
3afceeea09 bytes_ostream.hh: bytes_ostream::empty()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-04-28 15:49:34 +03:00
Tomasz Grabiec
c88e17c9e1 bytes_ostream: fix alloc-dealloc mismatch
Caught by ASAN, reported by Pekka.
2015-04-20 20:03:38 +03:00
Tomasz Grabiec
0f99570555 Introduce bytes_ostream 2015-04-15 20:33:49 +02:00