Commit Graph

107 Commits

Author SHA1 Message Date
Avi Kivity
0617aecb62 lsa: downgrade "no compactible pool" warning to trace
It's a fairly standard condition.
2015-08-24 17:26:48 +02:00
Avi Kivity
77b3212c88 lsa: provide a fallback during normal allocation
Instead of failing normal allocations when the seastar allocator cannot
allocate a segment, provide a generous reserve.  An allocation failure
will now be satisified from the reserve, but it will still trigger a
reclaim.  This allows hiding low-memory conditions from the user.
2015-08-23 16:38:04 +03:00
Avi Kivity
1bb840bb72 sstables: use large_bitset in bloom filter
Avoids allocation failures due to multi-megabyte filters.
2015-08-23 12:22:49 +03:00
Avi Kivity
e928bcaf19 utils: introduce large_bitset
Like boost::dynamic_bitset, but less capable.  On the other hand it avoids
very large allocations, which are incurred by the bloom filter's bitset
on even moderately sized sstables.
2015-08-23 12:22:49 +03:00
Raphael S. Carvalho
c6ea25c5fb compaction_manager: fix compaction_manager::stop
For stopping a task of compaction manager, we first close the gate
used by compaction then bust semaphore via semaphore::broken().

The problem is that semaphore::broken() only signals waiters, and so
subsequent semaphore::wait() calls would succeed and the task would
remain alive forever.
The fix is to signal semaphore, forcing the task to exit via gate
exception, so we will no longer rely on semaphore::broken() for
finishing the task. That's possible because we try to access the
gate right after we waited on semaphore.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-08-22 20:38:12 +03:00
Avi Kivity
f531f36a44 lsa: fix types in logs 2015-08-20 15:29:08 +03:00
Avi Kivity
9012f991bf logalloc: really allow dipping into the emergency pool during reclaim
The RAII wrapper for the emergency pool was invoked without an object,
and so had no effect.
2015-08-20 12:10:03 +03:00
Avi Kivity
9ed2bbb25c lsa: introduce region_group
A region_group is a nestable group of regions, for cumulative statistics
purposes.
2015-08-19 19:36:40 +03:00
Avi Kivity
71aad57ca8 lsa: make region::impl a top-level class
Makes using forward declarations possible.
2015-08-19 14:43:17 +03: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
Raphael S. Carvalho
820ba6f4d2 adapt compaction manager for column family removal
We need a way to remove a column family from the compaction manager
because when dropping a column family we need to make sure that the
compaction manager doesn't hold a reference to it anymore.

So compaction manager queue is now of column_family, allowing us
to cancel requests pertaining to a column family being dropped.
There may be an ongoing compaction for the column family being
dropped, so we also need to wait for its termination.

Testcase for compaction manager was also adapted and improved.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-08-18 11:38:06 +03:00
Avi Kivity
608c0b8460 Merge "initial work on compaction manager API" from Rapahel 2015-08-17 17:24:13 +03:00
Avi Kivity
932ddc328c logalloc: optimize current_allocation_strategy()
This heavily used function shows up in many places in the profile (as part
of other functions), so it's worth optimizing by eliminating the special
case for the standard allocator.  Use a statically allocated object instead.

(a non-thread-local object is fine since it has no data members).
2015-08-17 16:51:10 +03:00
Avi Kivity
5a061fe66e lsa: increase segment size
While #152 is still open, we need to allow for moderately sized allocations
to succeed.  Extend the segment size to 256k, which allows for threads to
be allocated.

Fixes #151.
2015-08-16 19:26:59 +03:00
Avi Kivity
eb09eddee5 Merge "Adding sampled histogram" from Amnon
"Histograms are used to collect latency information, in Origin, many of the
operations are timed, this is a potential performance issue. This series adds
an option to sample the operations, where small amount will be timed and the
most will only be counted.

This will give an estimation for the statistics, while keeping an accurate
count of the total events and have neglectible performance impact.

The first to use the modified histogram are the column family for their read
and write."

Conflicts:
	database.hh
2015-08-16 17:15:24 +03:00
Raphael S. Carvalho
74415f2772 compaction_manager: add stats for API
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-08-12 15:10:24 -03:00
Avi Kivity
ecc3ccc716 lsa: emergency segment reserve for compaction
To free memory, we need to allocate memory.  In lsa compaction, we convert
N segments with average occupancy of (N-1)/N into N-1 new segments.  However,
to do that, we need to allocate segments, which we may not be able to do
due to the low memory condition which caused us to compact anyway.

Fix by introducing a segment reserve, which we normally try to ensure is
full.  During low memory conditions, we temporarily allow allocating from
the emergency reserve.
2015-08-12 11:29:09 +03:00
Raphael S. Carvalho
9823164c89 db: introduce compaction manager
Currently, each column family creates a fiber to handle compaction requests
in parallel to the system. If there are N column families, N compactions
could be running in parallel, which is definitely horrible.

To solve that problem, a per-database compaction manager is introduced here.

Compaction manager is a feature used to service compaction requests from N
column families. Parallelism is made available by creating more than one
fiber to service the requests. That being said, N compaction requests will
be served by M fibers.

A compaction request being submitted will go to a job queue shared between
all fibers, and the fiber with the lowest amount of pending jobs will be
signalled.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-08-11 17:25:46 +03:00
Amnon Heiman
bd9a758b80 Utils: Support sample based histogram
The histogrm object is used both as a general counter for the number of
events and for statistics and sampling.

This chanage the histogram implementation, so it would support spares
sampling while keeping the total number of event accurate.

The implementation includes the following:
Remove the template nature of the histogram, as it is used only for
timer and use the name ihistogram instead.

If in the future we'll need a histogram for other types, we can use the
histogrma name for it.

a total counter was added that count the number of events that are part
of the statistic calculation.

A helper methods where added to the ihistogram to handle the latency
counter object.

According to the sample mask it would mark the latency object as start
if the counter and the mask are non zero and it would accept the latency
object in its mark method, in which if the latency was not start, it
will not be added and only the 'count' counter that counts the total
number of events will be incremented.

This should reduce the impact of latency calculation to a neglectable
effect.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-08-11 10:00:53 +03:00
Amnon Heiman
af2ec7c7e8 Utils add an is start method to latency_counter
When doing a spares latency check, it is required to know if a latency
object was started.

This returns true if the start timer was set.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-08-11 09:05:11 +03:00
Avi Kivity
d6351ecca7 utils: add crc32 class
C++ interface to the crc32 x86 instruction.
2015-08-09 00:05:33 +03:00
Tomasz Grabiec
ef549ae5a5 lsa: Reclaim space from evictable regions incrementally
When LSA reclaimer cannot reclaim more space by compaction, it
will reclaim data by evicting from evictable regions.

Currently the only evictable region is the one owned by the row cache.
2015-08-08 09:59:24 +02:00
Tomasz Grabiec
a095b39091 lsa: Don't leak empty _active segment in merge() 2015-08-08 09:59:24 +02:00
Tomasz Grabiec
5b5c0038e6 lsa: Don't allocate aligned segments
Requiring alignment means that there must be 64K of contiguous space
to allocate each 32K segment. When memory is fragmented, we may fail
to allocate such segment, even though there's plenty of free space.

This especially hurts forward progress of compaction, which frees
segments randomly and relies on the fact that freeing a segment will
make it available to the next segment request.
2015-08-07 22:13:17 +02:00
Tomasz Grabiec
64bd4bee94 lsa: Log segment closing and releasing on trace level 2015-08-07 22:06:15 +02:00
Tomasz Grabiec
02ff31b815 lsa: Reduce amount of calls to descriptor() in free() 2015-08-07 22:05:53 +02:00
Tomasz Grabiec
5dc58a7cd4 allocation_strategy: Leak the standard strategy
Some code may attempt to use it during finalization after "instance"
was destroyed.

Reported by Pekka:

/usr/include/c++/4.9.2/bits/unique_ptr.h:291:14: runtime error:
reference binding to null pointer of type 'struct
standard_allocation_strategy'
./utils/allocation_strategy.hh:105:13: runtime error: reference
binding to null pointer of type 'struct standard_allocation_strategy'
./utils/allocation_strategy.hh:118:35: runtime error: reference
binding to null pointer of type 'struct allocation_strategy'
./utils/managed_bytes.hh:59:45: runtime error: member call on null
pointer of type 'struct allocation_strategy'
./utils/allocation_strategy.hh:82:9: runtime error: member access
within null pointer of type 'struct allocation_strategy'
2015-08-07 18:35:20 +03:00
Tomasz Grabiec
7b7b6dd301 lsa: Don't initialize segments 2015-08-06 18:56:48 +02:00
Tomasz Grabiec
d60c04542a lsa: Consistently use segment::at() to access data 2015-08-06 18:56:48 +02:00
Tomasz Grabiec
112385455e lsa: Drop unnecessary use of __int128_t in reclaim() 2015-08-06 18:56:48 +02:00
Tomasz Grabiec
6ae0747fe5 lsa: Use size_t for sizes 2015-08-06 18:40:06 +02:00
Tomasz Grabiec
f5fdaa61a2 lsa: Avoid overflow in reclaim() 2015-08-06 16:50:15 +02:00
Tomasz Grabiec
4389bc748e lsa: Fix target calculation in reclaim() 2015-08-06 16:19:48 +02: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
Tomasz Grabiec
5508d9ff17 utils: Introduce managed_ref<> 2015-08-06 14:05:16 +02:00
Tomasz Grabiec
df6f0c35df utils: lsa: Add reclaimer hook which compacts regions 2015-08-06 14:05:15 +02:00
Tomasz Grabiec
5a9e296803 utils: lsa: Introduce log-structured allocator 2015-08-06 14:05:15 +02:00
Tomasz Grabiec
581eceea41 utils: Introduce allocation_strategy 2015-08-06 12:52:43 +02:00
Pekka Enberg
a520f6499f utils/UUID: Add inequality operator overloading
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-03 13:41:16 +03:00
Raphael S. Carvalho
f71932f37f utils: add exponential_backoff_retry
This is a retry mechanism that exponentially increases sleep time
between retries.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-07-28 17:49:45 -03:00
Amnon Heiman
b2c5e2a7cc utils: adding the latency object
The latency object is used to simplify calculating latencies. It uses a
start and stop time_point so the latency can be queried multiple time.

The start need to be done explicitely and not in the constructor to
allow reuse of the object.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-26 10:57:32 +03:00
Amnon Heiman
2b584ec2ec Adding the histogram object
The histogram object is equivalent to the Histogram used in Origin. It
collect multiple values about the data:
Count, Min, Max, Sum, variance and the sum of square that are used for
std calculation.

It also contain a sample of the last n elements, that are stored in a
circular buffer.

The histogram is used by the API to report histogram statistics.

As the API does not support unsigned integer, the count is signed.

Typically the base type of the histogram is int64_t, so ihistogram was
defined as such.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-26 10:55:14 +03:00
Pekka Enberg
55858137e0 utils: Clean up runtime::get_uptime() API
Return a std::chrono::steady_clock::duration and switch the caller in
migration manager to also use proper C++ durations.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-22 14:56:52 +03:00
Pekka Enberg
e361f2a436 utils/runtime: Add uptime helpers
The functionality is similar to RuntimeMBean.getUptime() that's needed
in schema pulling logic.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-22 13:02:43 +03:00
Asias He
fa2aee57ac utils: Move util/serialization.hh to utils/serialization.hh
Now we will not have the ugly utils and util directories, only utils.
2015-07-21 16:12:54 +08:00
Vlad Zolotarov
6017d7f6bc sequenced_set: add a non-const version of get_vector()
This is meant to allow std::moving the returned object when needed.
Otherwise std::move(s.get_vector()) will be degraded to copying.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-07-17 10:24:57 +02:00
Pekka Enberg
c003f89484 utils/UUID_gen: Add bytes_view variant of get_name_UUID()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-16 14:53:30 +03:00
Avi Kivity
99a15de9e5 logger: de-thread_local-ize logger
The logger class constructor registers itself with the logger registry,
in order to enable dynamically setting log levels.  However, since
thread_local variables may be (and are) initialized at the time of first
use, when the program starts up no loggers are registered.

Fix by making loggers global, not thread_local.  This requires that the
registry use locking to prevent registration happening on different threads
from corrupting the registry.

Note that technically global variables can also be initialized at the
point of first use, and there is no portable way for classes to self-register.
However this is the best we can do.
2015-07-14 17:18:11 +03:00
Calle Wilund
8a8694cbbf Add naive rate limiter object
This is mostly a placeholder, since the "limiting" is rather coarse
and stuttering
2015-07-08 10:50:46 +02:00