Commit Graph

24 Commits

Author SHA1 Message Date
Paweł Dziepak
703509a1c7 utils/managed_bytes: add memory_usage()
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-07-07 12:17:25 +01: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
ca08db504b managed_bytes: Make operator[] work for large blobs as well
Fixes assertion in mutation_test:

mutation_test: ./utils/managed_bytes.hh:349: blob_storage::char_type* managed_bytes::data(): Assertion `!_u.ptr->next'

Introduced in ea7c2dd085

Message-Id: <1458648786-9127-1-git-send-email-tgrabiec@scylladb.com>
2016-03-22 14:43:52 +02:00
Tomasz Grabiec
184e2831e7 managed_bytes: Mark move-assignment noexcept 2016-03-21 18:41:27 +01:00
Tomasz Grabiec
92d4cfc3ab managed_bytes: Make copy assignment exception-safe 2016-03-21 18:41:27 +01:00
Tomasz Grabiec
22d193ba9f managed_bytes: Make linearization_context::forget() noexcept
It is needed for noexcept destruction, which we need for exception
safety in higher layers.

According to [1], erase() only throws if key comparison throws, and in
our case it doesn't.

[1] http://en.cppreference.com/w/cpp/container/unordered_map/erase
2016-03-21 18:41:27 +01:00
Calle Wilund
e79ca557ed managed_bytes: Change init of small object to silence error on gcc5
Fixes #865

(Some) gcc 5 (5.3.0 for me) on ubuntu will generate errors on
compilation of this code (compiling logalloc_test). The memcpy
to inline storage seems to confuse the compiler.
Simply change to std::copy, which shuts the compiler up.
Any decent stl should convert primitive std::copy to memcpy
anyway, but since it is also the inline (small storage),
it should not matter which way.

Message-Id: <1456931988-5876-4-git-send-email-calle@scylladb.com>
2016-03-02 18:21:51 +02:00
Amnon Heiman
1e4d227b20 managed_bytes: don't return auto from non-member function
gcc 4.9 does not allow non-static data member declared auto.

This patch replace the auto decleration with std::result_of_t

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <1455652166-16860-1-git-send-email-amnon@scylladb.com>
2016-02-16 21:50:55 +02:00
Avi Kivity
13144ea9eb managed_bytes: get rid of explicit linearize/scatter
Now that everything is in a linarization context, we don't need to explicitly
gather data.
2016-02-16 14:37:46 +02:00
Avi Kivity
af8ef54d5a managed_bytes: introduce with_linearized_managed_bytes()
A large managed_bytes blob can be scattered in lsa memory.  Usually this is
fine, but someone we want to examine it in place without copying it out, but
using contiguous iterators for efficiency.

For this use case, introduce with_linearized_managed_bytes(Func),
which runs a function in a "linearization context".  Within the linearization
context, reads of managed_bytes object will see temporarily linearized copies
instead of scattered data.
2016-02-09 19:55:13 +02:00
Avi Kivity
e5b72aedf1 managed_bytes: don't copy data during hashing 2016-02-08 12:43:05 +02:00
Avi Kivity
5d958db869 managed_bytes: fix operator== for fragmented blobs
Must compare fragment by fragment.
2016-02-08 12:43:05 +02:00
Paweł Dziepak
ec453c5037 managed_bytes: fix potentially unaligned accesses
blob_storage defined with attribute packed which makes its alignment
requirement equal 1. This means that its members may be unaligned.
GCC is obviously aware of that and will generate appropriate code
(and not generate ubsan checks). However, there are few places where
members of blob_storage are accessed via pointers, these have to be
wrapped by unaligned_cast<> to let the compiler know that the location
pointed to may be not aligned properly.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-10 11:59:54 +02:00
Paweł Dziepak
8ba66bb75d managed_bytes: fix copy size in move constructor
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-09 10:38:28 +02:00
Avi Kivity
13324607e6 managed_bytes: conform to allocation_strategy's max_preferred_allocation_size
Instead of allocating a single blob_storage, chain multiple blob_storage
objects in a list, each limited not to exceed the allocation_strategy's
max_preferred_allocation_size.  This allows lsa to allocate each blob_storage
object as an lsa managed object that can be migrated in memory.

Also provide linearize()/scatter() methods that can be used to temporarily
consolidate the storage into a single blob_storage.  This makes the data
contiguous, so we can use a regular bytes_view to examine it.
2015-12-08 15:17:08 +02:00
Avi Kivity
36994a5d08 managed_bytes: add a constructor from std::initializer_list<>
Not actually used in the patchset now, but nice.
2015-11-13 17:13:07 +02:00
Avi Kivity
16006949d0 logalloc: make migrator an object, not a function pointer
The migrator tells lsa how to move an object when it is compacted.
Currently it is a function pointer, which means we must know how to move
the object at compile time.  Making it an object allows us to build the
migration function at runtime, making it suitable for runtime-defined types
(such as tuples and user-defined types).

In the future, we may also store the size there for fixed-size types,
reducing lsa overhead.

C++ variable templates would have made this patch smaller, but unfortunately
they are only supported on gcc 5+.
2015-10-21 11:24:56 +02: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
Paweł Dziepak
8d0419b621 managed_bytes: simplify empty()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-31 17:29:16 +02:00
Paweł Dziepak
0343fddeb0 managed_bytes: simplify default constructor
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-31 17:29:16 +02:00
Avi Kivity
5252d5ec9b managed_bytes: fix self-assignment 2015-08-19 11:18:07 +03:00
Avi Kivity
00f39c4e1a managed_bytes: add small string optimization 2015-08-19 11:18:07 +03:00
Tomasz Grabiec
e9322b9803 utils: Introduce managed_bytes<> class
It's a bytes container which can be used with LSA.
2015-08-06 14:05:16 +02:00