Improved ring buffer read-ahead
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
* Fixed setting `HostConfig.ApiUser` via `set_value_by_name`
|
* Fixed setting `HostConfig.ApiUser` via `set_value_by_name`
|
||||||
* Fixed setting `HostConfig.Path` via `set_value_by_name`
|
* Fixed setting `HostConfig.Path` via `set_value_by_name`
|
||||||
* Fixed setting `HostConfig.Protocol` via `set_value_by_name`
|
* Fixed setting `HostConfig.Protocol` via `set_value_by_name`
|
||||||
|
* Improved ring buffer read-ahead
|
||||||
* Integrated `renterd` version 2.0.0
|
* Integrated `renterd` version 2.0.0
|
||||||
* Prefer using local cache file when opening files
|
* Prefer using local cache file when opening files
|
||||||
* Refactored `app_config` unit tests
|
* Refactored `app_config` unit tests
|
||||||
|
@@ -98,8 +98,8 @@ auto ring_buffer_base::close() -> bool {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_base::download_chunk(std::size_t chunk,
|
auto ring_buffer_base::download_chunk(std::size_t chunk, bool skip_active)
|
||||||
bool skip_active) -> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
@@ -225,6 +225,8 @@ auto ring_buffer_base::read(std::size_t read_size, std::uint64_t read_offset,
|
|||||||
forward(chunk - ring_pos_);
|
forward(chunk - ring_pos_);
|
||||||
} else if (chunk < ring_pos_) {
|
} else if (chunk < ring_pos_) {
|
||||||
reverse(ring_pos_ - chunk);
|
reverse(ring_pos_ - chunk);
|
||||||
|
} else {
|
||||||
|
ring_pos_ = chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = download_chunk(chunk, false);
|
res = download_chunk(chunk, false);
|
||||||
@@ -264,15 +266,26 @@ void ring_buffer_base::reader_thread() {
|
|||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
auto next_chunk{ring_pos_};
|
auto last_pos = ring_pos_;
|
||||||
|
auto next_chunk = ring_pos_;
|
||||||
chunk_notify_.notify_all();
|
chunk_notify_.notify_all();
|
||||||
chunk_lock.unlock();
|
chunk_lock.unlock();
|
||||||
|
|
||||||
while (not get_stop_requested()) {
|
while (not get_stop_requested()) {
|
||||||
chunk_lock.lock();
|
chunk_lock.lock();
|
||||||
|
|
||||||
next_chunk = next_chunk + 1U > ring_end_ ? ring_begin_ : next_chunk + 1U;
|
if (last_pos == ring_pos_) {
|
||||||
const auto check_and_wait = [this, &chunk_lock, &next_chunk]() {
|
++next_chunk;
|
||||||
|
} else {
|
||||||
|
next_chunk = ring_pos_ + 1U;
|
||||||
|
last_pos = ring_pos_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next_chunk > ring_end_) {
|
||||||
|
next_chunk = ring_begin_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto check_and_wait = [this, &chunk_lock, &last_pos, &next_chunk]() {
|
||||||
if (get_stop_requested()) {
|
if (get_stop_requested()) {
|
||||||
chunk_notify_.notify_all();
|
chunk_notify_.notify_all();
|
||||||
chunk_lock.unlock();
|
chunk_lock.unlock();
|
||||||
@@ -281,6 +294,7 @@ void ring_buffer_base::reader_thread() {
|
|||||||
|
|
||||||
if (get_read_state().all()) {
|
if (get_read_state().all()) {
|
||||||
chunk_notify_.wait(chunk_lock);
|
chunk_notify_.wait(chunk_lock);
|
||||||
|
last_pos = ring_pos_;
|
||||||
next_chunk = ring_pos_;
|
next_chunk = ring_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user