diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 8d9c0a92..09016958 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1 +1 @@ -filter=-legal/copyright,-whitespace/braces,-whitespace/newline,-build/c++11,-whitespace/line_length,-whitespace/indent,-runtime/references,-whitespace/comments,-runtime/int,-build/header_guard,-whitespace/operators,-readability/braces,-readability/casting,-readability/todo +filter=-legal/copyright,-whitespace/braces,-whitespace/newline,-whitespace/parens,-build/c++11,-whitespace/line_length,-whitespace/indent,-runtime/references,-whitespace/comments,-runtime/int,-build/header_guard,-whitespace/operators,-readability/braces,-readability/casting,-readability/todo diff --git a/foxxll/common/aligned_alloc.hpp b/foxxll/common/aligned_alloc.hpp index e70d3844..e99e2a62 100644 --- a/foxxll/common/aligned_alloc.hpp +++ b/foxxll/common/aligned_alloc.hpp @@ -78,7 +78,7 @@ inline void * aligned_alloc(size_t size, size_t meta_info_size = 0) #endif char* reserve_buffer = buffer + sizeof(char*) + meta_info_size; char* result = reserve_buffer + Alignment - - (reinterpret_cast(reserve_buffer) % Alignment) - meta_info_size; + (reinterpret_cast(reserve_buffer) % Alignment) - meta_info_size; LOGC(debug_aligned_alloc) << "foxxll::aligned_alloc<" << Alignment << ">() address " << static_cast(result) << " lost " << (result - buffer) << " bytes"; //-tb: check that there is space for one char* before the "result" pointer @@ -104,12 +104,12 @@ inline void * aligned_alloc(size_t size, size_t meta_info_size = 0) *(reinterpret_cast(result) - 1) = buffer; LOGC(debug_aligned_alloc) << "foxxll::aligned_alloc<" << Alignment << ">(), allocated at " << - static_cast(buffer) << " returning " << static_cast(result); + static_cast(buffer) << " returning " << static_cast(result); LOGC(debug_aligned_alloc) << "foxxll::aligned_alloc<" << Alignment << - ">(size = " << size << ", meta info size = " << meta_info_size << - ") => buffer = " << static_cast(buffer) << ", ptr = " << static_cast(result); + ">(size = " << size << ", meta info size = " << meta_info_size << + ") => buffer = " << static_cast(buffer) << ", ptr = " << static_cast(result); return result; } diff --git a/foxxll/common/die_with_message.hpp b/foxxll/common/die_with_message.hpp index 53590d79..9ee41e90 100644 --- a/foxxll/common/die_with_message.hpp +++ b/foxxll/common/die_with_message.hpp @@ -19,22 +19,24 @@ //! Check condition X and die miserably if false. Same as die_if() //! except user additionally pass message -#define die_with_message_if(X, msg) \ - do { \ - if ((X)) { \ - die_with_sstream( \ - "DIE: Assertion \"" #X "\" succeeded!\n " << msg << "\n"); \ - } \ +#define die_with_message_if(X, msg) \ + do { \ + if ((X)) { \ + die_with_sstream( \ + "DIE: Assertion \"" #X "\" succeeded!\n " << msg << "\n" \ + ); \ + } \ } while (false) //! Check condition X and die miserably if false. Same as die_unless() //! except user additionally pass message -#define die_with_message_unless(X, msg) \ - do { \ - if (!(X)) { \ - die_with_sstream( \ - "DIE: Assertion \"" #X "\" failed!\n " << msg << "\n"); \ - } \ +#define die_with_message_unless(X, msg) \ + do { \ + if (!(X)) { \ + die_with_sstream( \ + "DIE: Assertion \"" #X "\" failed!\n " << msg << "\n" \ + ); \ + } \ } while (false) #endif // !FOXXLL_COMMON_DIE_WITH_MESSAGE_HEADER diff --git a/foxxll/common/error_handling.hpp b/foxxll/common/error_handling.hpp index 4ffdfa24..8a60b0ef 100644 --- a/foxxll/common/error_handling.hpp +++ b/foxxll/common/error_handling.hpp @@ -45,15 +45,19 @@ namespace foxxll { //! Throws exception_type with "Error in [function] : [error_message]" #define FOXXLL_THROW(exception_type, error_message) \ - FOXXLL_THROW2(exception_type, \ - FOXXLL_PRETTY_FUNCTION_NAME, \ - error_message) + FOXXLL_THROW2( \ + exception_type, \ + FOXXLL_PRETTY_FUNCTION_NAME, \ + error_message \ + ) //! Throws exception_type with "Error in [function] : [error_message] : [errno_value message]" #define FOXXLL_THROW_ERRNO2(exception_type, error_message, errno_value) \ - FOXXLL_THROW2(exception_type, \ - FOXXLL_PRETTY_FUNCTION_NAME, \ - error_message << " : " << strerror(errno_value)) + FOXXLL_THROW2( \ + exception_type, \ + FOXXLL_PRETTY_FUNCTION_NAME, \ + error_message << " : " << strerror(errno_value) \ + ) //! Throws exception_type with "Error in [function] : [error_message] : [errno message]" #define FOXXLL_THROW_ERRNO(exception_type, error_message) \ @@ -61,9 +65,11 @@ namespace foxxll { //! Throws std::invalid_argument with "Error in [function] : [error_message]" #define FOXXLL_THROW_INVALID_ARGUMENT(error_message) \ - FOXXLL_THROW2(std::invalid_argument, \ - FOXXLL_PRETTY_FUNCTION_NAME, \ - error_message) + FOXXLL_THROW2( \ + std::invalid_argument, \ + FOXXLL_PRETTY_FUNCTION_NAME, \ + error_message \ + ) //! Throws exception_type if (expr) with "Error in [function] : [error_message]" #define FOXXLL_THROW_IF(expr, exception_type, error_message) \ @@ -97,7 +103,8 @@ namespace foxxll { nullptr, dw, \ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \ (LPTSTR)&lpMsgBuf, \ - 0, nullptr); \ + 0, nullptr \ + ); \ std::ostringstream msg; \ msg << "Error in " << FOXXLL_PRETTY_FUNCTION_NAME \ << " : " << error_message \ diff --git a/foxxll/common/timer.hpp b/foxxll/common/timer.hpp index c8c81b1a..c2f9f01b 100644 --- a/foxxll/common/timer.hpp +++ b/foxxll/common/timer.hpp @@ -37,7 +37,8 @@ static inline double timestamp() { return static_cast( std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()).count()) / 1e6; + std::chrono::steady_clock::now().time_since_epoch() + ).count()) / 1e6; } /*! @@ -257,7 +258,7 @@ class scoped_print_timer << m_message << " after " << m_timer.seconds() << " seconds. " << "Processed " << tlx::format_iec_units(m_bytes) << "B" - << " @ " << tlx::format_iec_units(static_cast(bps)) << "B/s"; + << " @ " << tlx::format_iec_units(static_cast(bps)) << "B/s"; } } diff --git a/foxxll/common/tmeta.hpp b/foxxll/common/tmeta.hpp index df9fb2d5..08e76a28 100644 --- a/foxxll/common/tmeta.hpp +++ b/foxxll/common/tmeta.hpp @@ -49,7 +49,7 @@ class SWITCH using type = typename std::conditional::type - >::type; + >::type; }; template diff --git a/foxxll/common/uint_types.hpp b/foxxll/common/uint_types.hpp index 2a877d35..8709f9fd 100644 --- a/foxxll/common/uint_types.hpp +++ b/foxxll/common/uint_types.hpp @@ -91,14 +91,20 @@ class uint_pair uint_pair() { // compile-time assertions about size of low_type - static_assert(8 * sizeof(low_type) == 32, - "8 * sizeof(low_type) == 32"); + static_assert( + 8 * sizeof(low_type) == 32, + "8 * sizeof(low_type) == 32" + ); // compile-time assertions about size of our data structure, this tests // packing of structures by the compiler - static_assert(sizeof(uint_pair) == bytes, - "sizeof(uint_pair) == bytes"); - static_assert(sizeof(uint_pair) == digits / 8, - "sizeof(uint_pair) == digits / 8"); + static_assert( + sizeof(uint_pair) == bytes, + "sizeof(uint_pair) == bytes" + ); + static_assert( + sizeof(uint_pair) == digits / 8, + "sizeof(uint_pair) == digits / 8" + ); static_assert(digits / 8 == bytes, "digits / 8 == bytes"); } @@ -223,15 +229,19 @@ class uint_pair //! return an uint_pair instance containing the smallest value possible static uint_pair min() { - return uint_pair(std::numeric_limits::min(), - std::numeric_limits::min()); + return uint_pair( + std::numeric_limits::min(), + std::numeric_limits::min() + ); } //! return an uint_pair instance containing the largest value possible static uint_pair max() { - return uint_pair(std::numeric_limits::max(), - std::numeric_limits::max()); + return uint_pair( + std::numeric_limits::max(), + std::numeric_limits::max() + ); } } #if FOXXLL_MSVC diff --git a/foxxll/io/create_file.cpp b/foxxll/io/create_file.cpp index 2afa6910..4803bbc2 100644 --- a/foxxll/io/create_file.cpp +++ b/foxxll/io/create_file.cpp @@ -75,14 +75,17 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr result = tlx::make_counting( - cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id); + cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); // if marked as device but file is not -> throw! if (cfg.raw_device && !result->is_device()) { - FOXXLL_THROW(io_error, "Disk " << cfg.path << " was expected to be " - "a raw block device, but it is a normal file!"); + FOXXLL_THROW( + io_error, "Disk " << cfg.path << " was expected to be " + "a raw block device, but it is a normal file!" + ); } // if is raw_device -> get size and remove some flags. @@ -102,7 +105,8 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr > result = tlx::make_counting >( - cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id); + cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); return result; } @@ -110,7 +114,8 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr result = tlx::make_counting( - cfg.queue, disk_allocator_id, cfg.device_id); + cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); return result; } @@ -124,15 +129,18 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) tlx::counting_ptr result = tlx::make_counting( cfg.path, mode, cfg.queue, disk_allocator_id, - cfg.device_id, cfg.queue_length); + cfg.device_id, cfg.queue_length + ); result->lock(); // if marked as device but file is not -> throw! if (cfg.raw_device && !result->is_device()) { - FOXXLL_THROW(io_error, "Disk " << cfg.path << " was expected to be " - "a raw block device, but it is a normal file!"); + FOXXLL_THROW( + io_error, "Disk " << cfg.path << " was expected to be " + "a raw block device, but it is a normal file!" + ); } // if is raw_device -> get size and remove some flags. @@ -154,7 +162,8 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr result = tlx::make_counting( - cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id); + cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); if (cfg.unlink_on_open) @@ -166,7 +175,8 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr > result = tlx::make_counting >( - cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id); + cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); return result; } @@ -176,7 +186,8 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr result = tlx::make_counting( - cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id); + cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); return result; } @@ -184,14 +195,17 @@ file_ptr create_file(disk_config& cfg, int mode, int disk_allocator_id) { tlx::counting_ptr > result = tlx::make_counting >( - cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id); + cfg.path, mode, cfg.queue, disk_allocator_id, cfg.device_id + ); result->lock(); return result; } #endif - FOXXLL_THROW(std::runtime_error, - "Unsupported disk I/O implementation '" << cfg.io_impl << "'."); + FOXXLL_THROW( + std::runtime_error, + "Unsupported disk I/O implementation '" << cfg.io_impl << "'." + ); } } // namespace foxxll diff --git a/foxxll/io/disk_queued_file.cpp b/foxxll/io/disk_queued_file.cpp index 2be94058..81b15aad 100644 --- a/foxxll/io/disk_queued_file.cpp +++ b/foxxll/io/disk_queued_file.cpp @@ -25,7 +25,8 @@ request_ptr disk_queued_file::aread( const completion_handler& on_complete) { request_ptr req = tlx::make_counting( - on_complete, this, buffer, offset, bytes, request::READ); + on_complete, this, buffer, offset, bytes, request::READ + ); disk_queues::get_instance()->add_request(req, get_queue_id()); @@ -37,7 +38,8 @@ request_ptr disk_queued_file::awrite( const completion_handler& on_complete) { request_ptr req = tlx::make_counting( - on_complete, this, buffer, offset, bytes, request::WRITE); + on_complete, this, buffer, offset, bytes, request::WRITE + ); disk_queues::get_instance()->add_request(req, get_queue_id()); diff --git a/foxxll/io/disk_queues.cpp b/foxxll/io/disk_queues.cpp index b5f78974..e6d5224f 100644 --- a/foxxll/io/disk_queues.cpp +++ b/foxxll/io/disk_queues.cpp @@ -72,7 +72,8 @@ void disk_queues::add_request(request_ptr& req, disk_id_type disk) #if FOXXLL_HAVE_LINUXAIO_FILE if (dynamic_cast(req.get())) q = queues_[disk] = new linuxaio_queue( - dynamic_cast(req->get_file())->get_desired_queue_length()); + dynamic_cast(req->get_file())->get_desired_queue_length() + ); else #endif q = queues_[disk] = new request_queue_impl_qwqr(); diff --git a/foxxll/io/fileperblock_file.cpp b/foxxll/io/fileperblock_file.cpp index 769cc039..31349ecf 100644 --- a/foxxll/io/fileperblock_file.cpp +++ b/foxxll/io/fileperblock_file.cpp @@ -84,7 +84,8 @@ void fileperblock_file::lock() if (!lock_file_) { lock_file_ = tlx::make_counting( - filename_prefix_ + "_fpb_lock", mode_, get_queue_id()); + filename_prefix_ + "_fpb_lock", mode_, get_queue_id() + ); //create lock file and fill it with one page, an empty file cannot be locked const int page_size = BlockAlignment; diff --git a/foxxll/io/iostats.cpp b/foxxll/io/iostats.cpp index 6625fa9c..82c65c73 100644 --- a/foxxll/io/iostats.cpp +++ b/foxxll/io/iostats.cpp @@ -152,8 +152,10 @@ void file_stats::read_op_finished(const size_t size, double duration) file_stats_data file_stats_data::operator + (const file_stats_data& a) const { - FOXXLL_THROW_IF(device_id_ != a.device_id_, std::runtime_error, - "foxxll::file_stats_data objects do not belong to the same file/disk"); + FOXXLL_THROW_IF( + device_id_ != a.device_id_, std::runtime_error, + "foxxll::file_stats_data objects do not belong to the same file/disk" + ); file_stats_data fsd; fsd.device_id_ = device_id_; @@ -170,8 +172,10 @@ file_stats_data file_stats_data::operator + (const file_stats_data& a) const file_stats_data file_stats_data::operator - (const file_stats_data& a) const { - FOXXLL_THROW_IF(device_id_ != a.device_id_, std::runtime_error, - "foxxll::file_stats_data objects do not belong to the same file/disk"); + FOXXLL_THROW_IF( + device_id_ != a.device_id_, std::runtime_error, + "foxxll::file_stats_data objects do not belong to the same file/disk" + ); file_stats_data fsd; fsd.device_id_ = device_id_; @@ -347,10 +351,11 @@ file_stats* stats::create_file_stats(unsigned int device_id) { std::unique_lock lock(list_mutex_); auto it = std::lower_bound( - file_stats_list_.begin(), file_stats_list_.end(), - device_id, [](const file_stats& fs, unsigned id) { - return fs.get_device_id() < id; - }); + file_stats_list_.begin(), file_stats_list_.end(), + device_id, [](const file_stats& fs, unsigned id) { + return fs.get_device_id() < id; + } + ); if (it != file_stats_list_.end() && it->get_device_id()) return &*it; @@ -393,10 +398,12 @@ stats_data::summary::summary( values_per_device.emplace_back(get_value(f), f.get_device_id()); } - std::sort(values_per_device.begin(), values_per_device.end(), - [](std::pair a, std::pair b) { - return a.first < b.first; - }); + std::sort( + values_per_device.begin(), values_per_device.end(), + [](std::pair a, std::pair b) { + return a.first < b.first; + } + ); if (values_per_device.size() != 0) { @@ -409,8 +416,9 @@ stats_data::summary::summary( ? values_per_device[mid].first : (values_per_device[mid - 1].first + values_per_device[mid].first) / 2.0; - total = std::accumulate(values_per_device.cbegin(), values_per_device.cend(), T(0), - [](T sum, const auto& x) { return sum + x.first; }); + total = std::accumulate( + values_per_device.cbegin(), values_per_device.cend(), T(0), + [](T sum, const auto& x) { return sum + x.first; }); average = static_cast(total) / values_per_device.size(); } @@ -425,9 +433,10 @@ stats_data::summary::summary( } struct FileStatsDataCompare { - long long operator () (const file_stats_data& a, const file_stats_data& b) const { + long long operator () (const file_stats_data& a, const file_stats_data& b) const + { return static_cast(a.get_device_id()) - - static_cast(b.get_device_id()); + - static_cast(b.get_device_id()); } }; @@ -442,7 +451,8 @@ stats_data stats_data::operator + (const stats_data& a) const FileStatsDataCompare(), [](const file_stats_data& a, const file_stats_data& b) { return a + b; - }); + } + ); s.p_reads_ = p_reads_ + a.p_reads_; s.p_writes_ = p_writes_ + a.p_writes_; @@ -465,7 +475,8 @@ stats_data stats_data::operator - (const stats_data& a) const FileStatsDataCompare(), [](const file_stats_data& a, const file_stats_data& b) { return a - b; - }); + } + ); s.p_reads_ = p_reads_ - a.p_reads_; s.p_writes_ = p_writes_ - a.p_writes_; diff --git a/foxxll/io/iostats.hpp b/foxxll/io/iostats.hpp index 330490a5..58bec5d6 100644 --- a/foxxll/io/iostats.hpp +++ b/foxxll/io/iostats.hpp @@ -27,8 +27,8 @@ #include #include -#include #include +#include #include #include diff --git a/foxxll/io/linuxaio_file.cpp b/foxxll/io/linuxaio_file.cpp index 06173f9c..d6db3062 100644 --- a/foxxll/io/linuxaio_file.cpp +++ b/foxxll/io/linuxaio_file.cpp @@ -24,7 +24,8 @@ request_ptr linuxaio_file::aread( const completion_handler& on_complete) { request_ptr req = tlx::make_counting( - on_complete, this, buffer, offset, bytes, request::READ); + on_complete, this, buffer, offset, bytes, request::READ + ); disk_queues::get_instance()->add_request(req, get_queue_id()); @@ -36,7 +37,8 @@ request_ptr linuxaio_file::awrite( const completion_handler& on_complete) { request_ptr req = tlx::make_counting( - on_complete, this, buffer, offset, bytes, request::WRITE); + on_complete, this, buffer, offset, bytes, request::WRITE + ); disk_queues::get_instance()->add_request(req, get_queue_id()); diff --git a/foxxll/io/linuxaio_queue.cpp b/foxxll/io/linuxaio_queue.cpp index aa799899..86bc41c3 100644 --- a/foxxll/io/linuxaio_queue.cpp +++ b/foxxll/io/linuxaio_queue.cpp @@ -51,8 +51,10 @@ linuxaio_queue::linuxaio_queue(int desired_queue_length) max_events_ <<= 1; // try with half as many events } if (result != 0) { - FOXXLL_THROW_ERRNO(io_error, "linuxaio_queue::linuxaio_queue" - " io_setup() nr_events=" << max_events_); + FOXXLL_THROW_ERRNO( + io_error, "linuxaio_queue::linuxaio_queue" + " io_setup() nr_events=" << max_events_ + ); } num_free_events_.signal(max_events_); @@ -101,7 +103,8 @@ bool linuxaio_queue::cancel_request(request_ptr& req) std::unique_lock lock(waiting_mtx_); pos = std::find( - waiting_requests_.begin(), waiting_requests_.end(), req); + waiting_requests_.begin(), waiting_requests_.end(), req + ); if (pos != waiting_requests_.end()) { waiting_requests_.erase(pos); @@ -168,10 +171,13 @@ void linuxaio_queue::post_requests() // wait for at least one event to complete, no time limit long num_events = syscall( - SYS_io_getevents, context_, 1, max_events_, events, nullptr); + SYS_io_getevents, context_, 1, max_events_, events, nullptr + ); if (num_events < 0) { - FOXXLL_THROW_ERRNO(io_error, "linuxaio_queue::post_requests" - " io_getevents() nr_events=" << num_events); + FOXXLL_THROW_ERRNO( + io_error, "linuxaio_queue::post_requests" + " io_getevents() nr_events=" << num_events + ); } handle_events(events, num_events, false); @@ -197,7 +203,7 @@ void linuxaio_queue::handle_events(io_event* events, long num_events, bool cance for (int e = 0; e < num_events; ++e) { request* r = reinterpret_cast( - static_cast(events[e].data)); + static_cast(events[e].data)); r->completed(canceled); // release counting_ptr reference, this may delete the request object r->dec_reference(); @@ -226,7 +232,8 @@ void linuxaio_queue::wait_requests() long num_events; while (1) { num_events = syscall( - SYS_io_getevents, context_, 1, max_events_, events, nullptr); + SYS_io_getevents, context_, 1, max_events_, events, nullptr + ); if (num_events < 0) { if (errno == EINTR) { @@ -234,8 +241,10 @@ void linuxaio_queue::wait_requests() continue; } - FOXXLL_THROW_ERRNO(io_error, "linuxaio_queue::wait_requests" - " io_getevents() nr_events=" << max_events_); + FOXXLL_THROW_ERRNO( + io_error, "linuxaio_queue::wait_requests" + " io_getevents() nr_events=" << max_events_ + ); } break; } diff --git a/foxxll/io/linuxaio_request.cpp b/foxxll/io/linuxaio_request.cpp index e36c7c38..9b75b05d 100644 --- a/foxxll/io/linuxaio_request.cpp +++ b/foxxll/io/linuxaio_request.cpp @@ -79,15 +79,17 @@ bool linuxaio_request::post() // time before the call. time_posted_ = timestamp(); linuxaio_queue* queue = dynamic_cast( - disk_queues::get_instance()->get_queue(file_->get_queue_id())); + disk_queues::get_instance()->get_queue(file_->get_queue_id())); long success = syscall(SYS_io_submit, queue->get_io_context(), 1, &cb_pointer); // At this point another thread may have already called complete(), // so consider most values as invalidated! if (success == -1 && errno != EAGAIN) - FOXXLL_THROW_ERRNO(io_error, "linuxaio_request::post" - " io_submit()"); + FOXXLL_THROW_ERRNO( + io_error, "linuxaio_request::post" + " io_submit()" + ); return success == 1; } @@ -103,7 +105,7 @@ bool linuxaio_request::cancel() request_ptr req(this); linuxaio_queue* queue = dynamic_cast( - disk_queues::get_instance()->get_queue(file_->get_queue_id())); + disk_queues::get_instance()->get_queue(file_->get_queue_id())); return queue->cancel_request(req); } diff --git a/foxxll/io/mmap_file.cpp b/foxxll/io/mmap_file.cpp index 6de47b1f..3dc42ce7 100644 --- a/foxxll/io/mmap_file.cpp +++ b/foxxll/io/mmap_file.cpp @@ -38,12 +38,14 @@ void mmap_file::serve(void* buffer, offset_type offset, size_type bytes, if (mem == MAP_FAILED) { - FOXXLL_THROW_ERRNO(io_error, - " mmap() failed." << - " path=" << filename_ << - " bytes=" << bytes << - " Page size: " << sysconf(_SC_PAGESIZE) << - " offset modulo page size " << (offset % sysconf(_SC_PAGESIZE))); + FOXXLL_THROW_ERRNO( + io_error, + " mmap() failed." << + " path=" << filename_ << + " bytes=" << bytes << + " Page size: " << sysconf(_SC_PAGESIZE) << + " offset modulo page size " << (offset % sysconf(_SC_PAGESIZE)) + ); } else if (mem == 0) { @@ -59,8 +61,10 @@ void mmap_file::serve(void* buffer, offset_type offset, size_type bytes, { memcpy(mem, buffer, bytes); } - FOXXLL_THROW_ERRNO_NE_0(munmap(mem, bytes), io_error, - "munmap() failed"); + FOXXLL_THROW_ERRNO_NE_0( + munmap(mem, bytes), io_error, + "munmap() failed" + ); } } diff --git a/foxxll/io/request_queue_impl_1q.cpp b/foxxll/io/request_queue_impl_1q.cpp index 9234839d..01852f95 100644 --- a/foxxll/io/request_queue_impl_1q.cpp +++ b/foxxll/io/request_queue_impl_1q.cpp @@ -71,8 +71,10 @@ void request_queue_impl_1q::add_request(request_ptr& req) #if FOXXLL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION { std::unique_lock lock(queue_mutex_); - if (std::find_if(queue_.begin(), queue_.end(), - bind2nd(file_offset_match(), req)) + if (std::find_if( + queue_.begin(), queue_.end(), + bind2nd(file_offset_match(), req) + ) != queue_.end()) { LOG1 << "request submitted for a BID with a pending request"; diff --git a/foxxll/io/request_queue_impl_qwqr.cpp b/foxxll/io/request_queue_impl_qwqr.cpp index bcfc48c9..8f718fa5 100644 --- a/foxxll/io/request_queue_impl_qwqr.cpp +++ b/foxxll/io/request_queue_impl_qwqr.cpp @@ -72,8 +72,10 @@ void request_queue_impl_qwqr::add_request(request_ptr& req) #if FOXXLL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION { std::unique_lock lock(write_mutex_); - if (std::find_if(write_queue_.begin(), write_queue_.end(), - bind2nd(file_offset_match(), req)) + if (std::find_if( + write_queue_.begin(), write_queue_.end(), + bind2nd(file_offset_match(), req) + ) != write_queue_.end()) { LOG1 << "READ request submitted for a BID with a pending WRITE request"; @@ -88,8 +90,10 @@ void request_queue_impl_qwqr::add_request(request_ptr& req) #if FOXXLL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION { std::unique_lock lock(read_mutex_); - if (std::find_if(read_queue_.begin(), read_queue_.end(), - bind2nd(file_offset_match(), req)) + if (std::find_if( + read_queue_.begin(), read_queue_.end(), + bind2nd(file_offset_match(), req) + ) != read_queue_.end()) { LOG1 << "WRITE request submitted for a BID with a pending READ request"; diff --git a/foxxll/io/request_with_waiters.cpp b/foxxll/io/request_with_waiters.cpp index 22e90a82..f0dc9130 100644 --- a/foxxll/io/request_with_waiters.cpp +++ b/foxxll/io/request_with_waiters.cpp @@ -47,8 +47,10 @@ void request_with_waiters::delete_waiter(onoff_switch* sw) void request_with_waiters::notify_waiters() { std::unique_lock lock(waiters_mutex_); - std::for_each(waiters_.begin(), waiters_.end(), - std::mem_fun(&onoff_switch::on)); + std::for_each( + waiters_.begin(), waiters_.end(), + std::mem_fun(&onoff_switch::on) + ); } size_t request_with_waiters::num_waiters() diff --git a/foxxll/io/syscall_file.cpp b/foxxll/io/syscall_file.cpp index a9032525..f89960c0 100644 --- a/foxxll/io/syscall_file.cpp +++ b/foxxll/io/syscall_file.cpp @@ -41,16 +41,18 @@ void syscall_file::serve(void* buffer, offset_type offset, size_type bytes, if (rc < 0) { FOXXLL_THROW_ERRNO - (io_error, + ( + io_error, " this=" << this << - " call=::lseek(fd,offset,SEEK_SET)" << - " path=" << filename_ << - " fd=" << file_des_ << - " offset=" << offset << - " buffer=" << cbuffer << - " bytes=" << bytes << - " op=" << ((op == request::READ) ? "READ" : "WRITE") << - " rc=" << rc); + " call=::lseek(fd,offset,SEEK_SET)" << + " path=" << filename_ << + " fd=" << file_des_ << + " offset=" << offset << + " buffer=" << cbuffer << + " bytes=" << bytes << + " op=" << ((op == request::READ) ? "READ" : "WRITE") << + " rc=" << rc + ); } if (op == request::READ) @@ -63,16 +65,18 @@ void syscall_file::serve(void* buffer, offset_type offset, size_type bytes, #endif { FOXXLL_THROW_ERRNO - (io_error, + ( + io_error, " this=" << this << - " call=::read(fd,buffer,bytes)" << - " path=" << filename_ << - " fd=" << file_des_ << - " offset=" << offset << - " buffer=" << buffer << - " bytes=" << bytes << - " op=" << "READ" << - " rc=" << rc); + " call=::read(fd,buffer,bytes)" << + " path=" << filename_ << + " fd=" << file_des_ << + " offset=" << offset << + " buffer=" << buffer << + " bytes=" << bytes << + " op=" << "READ" << + " rc=" << rc + ); } bytes = static_cast(bytes - rc); offset += rc; @@ -96,16 +100,18 @@ void syscall_file::serve(void* buffer, offset_type offset, size_type bytes, #endif { FOXXLL_THROW_ERRNO - (io_error, + ( + io_error, " this=" << this << - " call=::write(fd,buffer,bytes)" << - " path=" << filename_ << - " fd=" << file_des_ << - " offset=" << offset << - " buffer=" << buffer << - " bytes=" << bytes << - " op=" << "WRITE" << - " rc=" << rc); + " call=::write(fd,buffer,bytes)" << + " path=" << filename_ << + " fd=" << file_des_ << + " offset=" << offset << + " buffer=" << buffer << + " bytes=" << bytes << + " op=" << "WRITE" << + " rc=" << rc + ); } bytes = static_cast(bytes - rc); offset += rc; diff --git a/foxxll/io/ufs_file_base.cpp b/foxxll/io/ufs_file_base.cpp index c553f4aa..230408be 100644 --- a/foxxll/io/ufs_file_base.cpp +++ b/foxxll/io/ufs_file_base.cpp @@ -119,8 +119,10 @@ ufs_file_base::ufs_file_base(const std::string& filename, int mode) } #endif - FOXXLL_THROW_ERRNO(io_error, "open() rc=" << file_des_ - << " path=" << filename_ << " flags=" << flags); + FOXXLL_THROW_ERRNO( + io_error, "open() rc=" << file_des_ + << " path=" << filename_ << " flags=" << flags + ); } ufs_file_base::~ufs_file_base() @@ -133,21 +135,29 @@ void ufs_file_base::_after_open() // stat file type #if FOXXLL_WINDOWS || defined(__MINGW32__) struct _stat64 st; - FOXXLL_THROW_ERRNO_NE_0(::_fstat64(file_des_, &st), io_error, - "_fstat64() path=" << filename_ << " fd=" << file_des_); + FOXXLL_THROW_ERRNO_NE_0( + ::_fstat64(file_des_, &st), io_error, + "_fstat64() path=" << filename_ << " fd=" << file_des_ + ); #else struct stat st; - FOXXLL_THROW_ERRNO_NE_0(::fstat(file_des_, &st), io_error, - "fstat() path=" << filename_ << " fd=" << file_des_); + FOXXLL_THROW_ERRNO_NE_0( + ::fstat(file_des_, &st), io_error, + "fstat() path=" << filename_ << " fd=" << file_des_ + ); #endif is_device_ = S_ISBLK(st.st_mode) ? true : false; #ifdef __APPLE__ if (mode_ & REQUIRE_DIRECT) { - FOXXLL_THROW_ERRNO_NE_0(fcntl(file_des_, F_NOCACHE, 1), io_error, - "fcntl() path=" << filename_ << " fd=" << file_des_); - FOXXLL_THROW_ERRNO_NE_0(fcntl(file_des_, F_RDAHEAD, 0), io_error, - "fcntl() path=" << filename_ << " fd=" << file_des_); + FOXXLL_THROW_ERRNO_NE_0( + fcntl(file_des_, F_NOCACHE, 1), io_error, + "fcntl() path=" << filename_ << " fd=" << file_des_ + ); + FOXXLL_THROW_ERRNO_NE_0( + fcntl(file_des_, F_RDAHEAD, 0), io_error, + "fcntl() path=" << filename_ << " fd=" << file_des_ + ); } else if (mode_ & DIRECT) { if (fcntl(file_des_, F_NOCACHE, 1) != 0) { @@ -229,31 +239,41 @@ void ufs_file_base::_set_size(offset_type newsize) { #if FOXXLL_WINDOWS || defined(__MINGW32__) HANDLE hfile = (HANDLE)::_get_osfhandle(file_des_); - FOXXLL_THROW_ERRNO_NE_0((hfile == INVALID_HANDLE_VALUE), io_error, - "_get_osfhandle() path=" << filename_ << " fd=" << file_des_); + FOXXLL_THROW_ERRNO_NE_0( + (hfile == INVALID_HANDLE_VALUE), io_error, + "_get_osfhandle() path=" << filename_ << " fd=" << file_des_ + ); LARGE_INTEGER desired_pos; desired_pos.QuadPart = newsize; if (!SetFilePointerEx(hfile, desired_pos, nullptr, FILE_BEGIN)) - FOXXLL_THROW_WIN_LASTERROR(io_error, - "SetFilePointerEx in ufs_file_base::set_size(..) oldsize=" << cur_size << - " newsize=" << newsize << " "); + FOXXLL_THROW_WIN_LASTERROR( + io_error, + "SetFilePointerEx in ufs_file_base::set_size(..) oldsize=" << cur_size << + " newsize=" << newsize << " " + ); if (!SetEndOfFile(hfile)) - FOXXLL_THROW_WIN_LASTERROR(io_error, - "SetEndOfFile oldsize=" << cur_size << - " newsize=" << newsize << " "); + FOXXLL_THROW_WIN_LASTERROR( + io_error, + "SetEndOfFile oldsize=" << cur_size << + " newsize=" << newsize << " " + ); #else - FOXXLL_THROW_ERRNO_NE_0(::ftruncate(file_des_, newsize), io_error, - "ftruncate() path=" << filename_ << " fd=" << file_des_); + FOXXLL_THROW_ERRNO_NE_0( + ::ftruncate(file_des_, newsize), io_error, + "ftruncate() path=" << filename_ << " fd=" << file_des_ + ); #endif } #if !FOXXLL_WINDOWS if (newsize > cur_size) - FOXXLL_THROW_IF(::lseek(file_des_, newsize - 1, SEEK_SET) < 0, io_error, - "lseek() path=" << filename_ << " fd=" << file_des_ << " pos=" << newsize - 1); + FOXXLL_THROW_IF( + ::lseek(file_des_, newsize - 1, SEEK_SET) < 0, io_error, + "lseek() path=" << filename_ << " fd=" << file_des_ << " pos=" << newsize - 1 + ); #endif } diff --git a/foxxll/io/wfs_file_base.cpp b/foxxll/io/wfs_file_base.cpp index d3b55749..575eae1e 100644 --- a/foxxll/io/wfs_file_base.cpp +++ b/foxxll/io/wfs_file_base.cpp @@ -89,8 +89,10 @@ static HANDLE open_file_impl(const std::string& filename, int mode) // ignored } - HANDLE file_des_ = ::CreateFileA(filename.c_str(), dwDesiredAccess, dwShareMode, nullptr, - dwCreationDisposition, dwFlagsAndAttributes, nullptr); + HANDLE file_des_ = ::CreateFileA( + filename.c_str(), dwDesiredAccess, dwShareMode, nullptr, + dwCreationDisposition, dwFlagsAndAttributes, nullptr + ); if (file_des_ != INVALID_HANDLE_VALUE) return file_des_; @@ -102,8 +104,10 @@ static HANDLE open_file_impl(const std::string& filename, int mode) dwFlagsAndAttributes &= ~FILE_FLAG_NO_BUFFERING; - HANDLE file_des2 = ::CreateFileA(filename.c_str(), dwDesiredAccess, dwShareMode, nullptr, - dwCreationDisposition, dwFlagsAndAttributes, nullptr); + HANDLE file_des2 = ::CreateFileA( + filename.c_str(), dwDesiredAccess, dwShareMode, nullptr, + dwCreationDisposition, dwFlagsAndAttributes, nullptr + ); if (file_des2 != INVALID_HANDLE_VALUE) return file_des2; @@ -212,13 +216,17 @@ void wfs_file_base::set_size(offset_type newsize) } if (!SetFilePointerEx(file_des_, desired_pos, nullptr, FILE_BEGIN)) - FOXXLL_THROW_WIN_LASTERROR(io_error, - "SetFilePointerEx() in wfs_file_base::set_size(..) oldsize=" << cur_size << - " newsize=" << newsize << " "); + FOXXLL_THROW_WIN_LASTERROR( + io_error, + "SetFilePointerEx() in wfs_file_base::set_size(..) oldsize=" << cur_size << + " newsize=" << newsize << " " + ); if (!SetEndOfFile(file_des_)) - FOXXLL_THROW_WIN_LASTERROR(io_error, "SetEndOfFile() oldsize=" << cur_size << - " newsize=" << newsize << " "); + FOXXLL_THROW_WIN_LASTERROR( + io_error, "SetEndOfFile() oldsize=" << cur_size << + " newsize=" << newsize << " " + ); if (direct_with_bad_size) { diff --git a/foxxll/io/wfs_file_base.hpp b/foxxll/io/wfs_file_base.hpp index d2ef2d5a..0f0c4a5d 100644 --- a/foxxll/io/wfs_file_base.hpp +++ b/foxxll/io/wfs_file_base.hpp @@ -38,7 +38,7 @@ class wfs_file_base : public virtual file protected: using HANDLE = void*; - std::mutex fd_mutex_; // sequentialize function calls involving file_des_ + std::mutex fd_mutex_; // sequentialize function calls involving file_des_ HANDLE file_des_; // file descriptor int mode_; // open mode const std::string filename_; diff --git a/foxxll/io/wincall_file.cpp b/foxxll/io/wincall_file.cpp index 7fc51366..637b415e 100644 --- a/foxxll/io/wincall_file.cpp +++ b/foxxll/io/wincall_file.cpp @@ -50,7 +50,8 @@ void wincall_file::serve(void* buffer, offset_type offset, size_type bytes, " this=" << this << " buffer=" << buffer << " bytes=" << bytes << - " op=" << ((op == request::READ) ? "READ" : "WRITE")); + " op=" << ((op == request::READ) ? "READ" : "WRITE") + ); } else { @@ -71,7 +72,8 @@ void wincall_file::serve(void* buffer, offset_type offset, size_type bytes, " buffer=" << buffer << " bytes=" << bytes << " op=" << ((op == request::READ) ? "READ" : "WRITE") << - " NumberOfBytesRead= " << NumberOfBytesRead); + " NumberOfBytesRead= " << NumberOfBytesRead + ); } else if (NumberOfBytesRead != bytes) { FOXXLL_THROW_WIN_LASTERROR(io_error, " partial read: missing " << (bytes - NumberOfBytesRead) << " out of " << bytes << " bytes"); @@ -91,7 +93,8 @@ void wincall_file::serve(void* buffer, offset_type offset, size_type bytes, " buffer=" << buffer << " bytes=" << bytes << " op=" << ((op == request::READ) ? "READ" : "WRITE") << - " NumberOfBytesWritten= " << NumberOfBytesWritten); + " NumberOfBytesWritten= " << NumberOfBytesWritten + ); } else if (NumberOfBytesWritten != bytes) { FOXXLL_THROW_WIN_LASTERROR(io_error, " partial write: missing " << (bytes - NumberOfBytesWritten) << " out of " << bytes << " bytes"); diff --git a/foxxll/mng/block_manager.hpp b/foxxll/mng/block_manager.hpp index 1662e42a..a1c32b36 100644 --- a/foxxll/mng/block_manager.hpp +++ b/foxxll/mng/block_manager.hpp @@ -187,7 +187,8 @@ void block_manager::new_blocks( size_t disk_id = functor(alloc_offset + i); if (!block_allocators_[disk_id]->has_available_space( - disk_bytes[disk_id] + bid->size)) + disk_bytes[disk_id] + bid->size + )) { // find disk (cyclically) that has enough free space for block @@ -195,7 +196,8 @@ void block_manager::new_blocks( { size_t try_disk_id = (disk_id + adv) % ndisks_; if (block_allocators_[try_disk_id]->has_available_space( - disk_bytes[try_disk_id] + bid->size)) + disk_bytes[try_disk_id] + bid->size + )) { disk_id = try_disk_id; break; diff --git a/foxxll/mng/block_prefetcher.hpp b/foxxll/mng/block_prefetcher.hpp index 90280a86..fee426ea 100644 --- a/foxxll/mng/block_prefetcher.hpp +++ b/foxxll/mng/block_prefetcher.hpp @@ -145,8 +145,9 @@ class block_prefetcher " @ " << &read_buffers[i] << " @ " << read_bids[i]; read_reqs[i] = read_buffers[i].read( - read_bids[i], - set_switch_handler(*(completed + prefetch_seq[i]), do_after_fetch)); + read_bids[i], + set_switch_handler(*(completed + prefetch_seq[i]), do_after_fetch) + ); pref_buffer[prefetch_seq[i]] = i; } } @@ -190,8 +191,9 @@ class block_prefetcher read_bids[ibuffer] = bid_type(*(consume_seq_begin + next_2_prefetch)); read_reqs[ibuffer] = read_buffers[ibuffer].read( - read_bids[ibuffer], - set_switch_handler(*(completed + next_2_prefetch), do_after_fetch)); + read_bids[ibuffer], + set_switch_handler(*(completed + next_2_prefetch), do_after_fetch) + ); } if (nextconsume >= seq_length) diff --git a/foxxll/mng/block_scheduler.hpp b/foxxll/mng/block_scheduler.hpp index 0c5c3eb7..36069640 100644 --- a/foxxll/mng/block_scheduler.hpp +++ b/foxxll/mng/block_scheduler.hpp @@ -400,7 +400,7 @@ class block_scheduler } } if (int64_t nlost = static_cast(max_internal_blocks - remaining_internal_blocks) - - static_cast(free_internal_blocks.size() + num_freed_internal_blocks)) { + - static_cast(free_internal_blocks.size() + num_freed_internal_blocks)) { LOG1 << nlost << " internal_blocks are lost. They will get deallocated."; } while (! internal_blocks_blocks.empty()) @@ -837,10 +837,12 @@ class block_scheduler_algorithm_simulation : public block_scheduler_algorithmfirst].detach_internal_block(); swappable_blocks[block_to_read->first].attach_internal_block( - swappable_blocks[other_block_to_read->first].detach_internal_block()); + swappable_blocks[other_block_to_read->first].detach_internal_block() + ); swappable_blocks[other_block_to_read->first].attach_internal_block(tmp_iblock); // => this block has its internal_block back, no need to read // reschedule other @@ -1342,7 +1350,8 @@ class block_scheduler_algorithm_offline_lru_prefetching : public block_scheduler internal_block_type* tmp_iblock = swappable_blocks[block_to_read->first].detach_internal_block(); swappable_blocks[block_to_read->first].attach_internal_block( - other_block_to_read->second.reserved_iblock); + other_block_to_read->second.reserved_iblock + ); other_block_to_read->second.reserved_iblock = tmp_iblock; // => this block has its internal_block back, no need to read return; @@ -1531,8 +1540,11 @@ class block_scheduler_algorithm_offline_lru_prefetching : public block_scheduler { // list operation in scheduled_blocks std::pair ins_res = scheduled_blocks.insert( - std::make_pair(next_op_to_schedule->id, - scheduled_block_meta(next_op_to_schedule->op))); + std::make_pair( + next_op_to_schedule->id, + scheduled_block_meta(next_op_to_schedule->op) + ) + ); scheduled_blocks_iterator schedule_meta = ins_res.first; if (! ins_res.second) schedule_meta->second.operations.push_front(next_op_to_schedule->op); @@ -1570,8 +1582,10 @@ class block_scheduler_algorithm_offline_lru_prefetching : public block_scheduler } swappable_block_identifier_type giver = pop_begin(free_evictable_blocks); { - assert(scheduled_blocks.find(giver) == scheduled_blocks.end() || - !shall_keep_internal_block(scheduled_blocks.find(giver), false)); + assert( + scheduled_blocks.find(giver) == scheduled_blocks.end() || + !shall_keep_internal_block(scheduled_blocks.find(giver), false) + ); } write_read_request* wrr = schedule_write(giver); schedule_meta->second.giver.first = (wrr != nullptr); @@ -1687,14 +1701,18 @@ class block_scheduler_algorithm_offline_lru_prefetching : public block_scheduler virtual internal_block_type & acquire(const swappable_block_identifier_type sbid, const bool uninitialized = false) { assert(! prediction_sequence.empty()); - assert(prediction_sequence.front().op == - ((uninitialized) ? block_scheduler_type::op_acquire_uninitialized : block_scheduler_type::op_acquire)); + assert( + prediction_sequence.front().op == + ((uninitialized) ? block_scheduler_type::op_acquire_uninitialized : block_scheduler_type::op_acquire) + ); assert(prediction_sequence.front().id == sbid); prediction_sequence.pop_front(); scheduled_blocks_iterator schedule_meta = scheduled_blocks.find(sbid); assert(schedule_meta != scheduled_blocks.end()); // acquire not scheduled or out of internal_blocks (i.e. not enough internal memory) - assert(schedule_meta->second.operations.back() == - ((uninitialized) ? block_scheduler_type::op_acquire_uninitialized : block_scheduler_type::op_acquire)); // acquire not scheduled or out of internal_blocks (i.e. not enough internal memory) + assert( + schedule_meta->second.operations.back() == + ((uninitialized) ? block_scheduler_type::op_acquire_uninitialized : block_scheduler_type::op_acquire) + ); // acquire not scheduled or out of internal_blocks (i.e. not enough internal memory) SwappableBlockType& sblock = swappable_blocks[sbid]; /* acquired => internal -> increase reference count @@ -1733,14 +1751,18 @@ class block_scheduler_algorithm_offline_lru_prefetching : public block_scheduler virtual void release(swappable_block_identifier_type sbid, const bool dirty) { assert(! prediction_sequence.empty()); - assert(prediction_sequence.front().op == - ((dirty) ? block_scheduler_type::op_release_dirty : block_scheduler_type::op_release)); + assert( + prediction_sequence.front().op == + ((dirty) ? block_scheduler_type::op_release_dirty : block_scheduler_type::op_release) + ); assert(prediction_sequence.front().id == sbid); prediction_sequence.pop_front(); scheduled_blocks_iterator schedule_meta = scheduled_blocks.find(sbid); assert(schedule_meta != scheduled_blocks.end()); - assert(schedule_meta->second.operations.back() == - ((dirty) ? block_scheduler_type::op_release_dirty : block_scheduler_type::op_release)); + assert( + schedule_meta->second.operations.back() == + ((dirty) ? block_scheduler_type::op_release_dirty : block_scheduler_type::op_release) + ); SwappableBlockType& sblock = swappable_blocks[sbid]; sblock.make_dirty_if(dirty); diff --git a/foxxll/mng/buf_istream.hpp b/foxxll/mng/buf_istream.hpp index 27a86475..083f0c4a 100644 --- a/foxxll/mng/buf_istream.hpp +++ b/foxxll/mng/buf_istream.hpp @@ -76,8 +76,10 @@ class buf_istream // optimal schedule nbuffers = std::max(2 * ndisks, size_t(nbuffers - 1)); - compute_prefetch_schedule(begin, end, prefetch_seq, - nbuffers, mdevid); + compute_prefetch_schedule( + begin, end, prefetch_seq, + nbuffers, mdevid + ); prefetcher = new prefetcher_type(begin, end, prefetch_seq, nbuffers); diff --git a/foxxll/mng/buf_istream_reverse.hpp b/foxxll/mng/buf_istream_reverse.hpp index d63055fd..283eccaf 100644 --- a/foxxll/mng/buf_istream_reverse.hpp +++ b/foxxll/mng/buf_istream_reverse.hpp @@ -84,8 +84,10 @@ class buf_istream_reverse // optimal schedule nbuffers = std::max(2 * ndisks, nbuffers - 1); - compute_prefetch_schedule(bids_.begin(), bids_.end(), prefetch_seq, - nbuffers, mdevid); + compute_prefetch_schedule( + bids_.begin(), bids_.end(), prefetch_seq, + nbuffers, mdevid + ); // create stream prefetcher prefetcher = new prefetcher_type(bids_.begin(), bids_.end(), prefetch_seq, nbuffers); diff --git a/foxxll/mng/config.cpp b/foxxll/mng/config.cpp index 9e25d4c1..8c76ca47 100644 --- a/foxxll/mng/config.cpp +++ b/foxxll/mng/config.cpp @@ -182,8 +182,10 @@ void config::load_config_file(const std::string& config_path) disks_list.insert(disks_list.end(), flash_list.begin(), flash_list.end()); if (disks_list.empty()) { - FOXXLL_THROW(std::runtime_error, - "No disks found in '" << config_path << "'."); + FOXXLL_THROW( + std::runtime_error, + "No disks found in '" << config_path << "'." + ); } } @@ -320,8 +322,10 @@ void disk_config::parse_line(const std::string& line) flash = true; } else { - FOXXLL_THROW(std::runtime_error, - "Unknown configuration token " << eqfield[0]); + FOXXLL_THROW( + std::runtime_error, + "Unknown configuration token " << eqfield[0] + ); } // *** Set Default Extra Options *** @@ -357,8 +361,10 @@ void disk_config::parse_line(const std::string& line) // size: (default unit MiB) if (!tlx::parse_si_iec_units(cmfield[1], &size, 'M')) { - FOXXLL_THROW(std::runtime_error, - "Invalid disk size '" << cmfield[1] << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid disk size '" << cmfield[1] << "' in disk configuration file." + ); } if (size == 0) { @@ -412,8 +418,10 @@ void disk_config::parse_fileio() else if (eq[1] == "yes") autogrow = true; else { - FOXXLL_THROW(std::runtime_error, - "Invalid parameter '" << *p << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid parameter '" << *p << "' in disk configuration file." + ); } } else if (*p == "delete" || *p == "delete_on_exit") @@ -434,8 +442,10 @@ void disk_config::parse_fileio() else if (eq[1] == "yes") direct = DIRECT_ON; else { - FOXXLL_THROW(std::runtime_error, - "Invalid parameter '" << *p << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid parameter '" << *p << "' in disk configuration file." + ); } } else if (eq[0] == "queue") @@ -447,23 +457,29 @@ void disk_config::parse_fileio() char* endp; queue = static_cast(strtoul(eq[1].c_str(), &endp, 10)); if (endp && *endp != 0) { - FOXXLL_THROW(std::runtime_error, - "Invalid parameter '" << *p << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid parameter '" << *p << "' in disk configuration file." + ); } } else if (eq[0] == "queue_length") { if (io_impl != "linuxaio") { - FOXXLL_THROW(std::runtime_error, "Parameter '" << *p << "' " - "is only valid for fileio linuxaio " - "in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, "Parameter '" << *p << "' " + "is only valid for fileio linuxaio " + "in disk configuration file." + ); } char* endp; queue_length = static_cast(strtoul(eq[1].c_str(), &endp, 10)); if (endp && *endp != 0) { - FOXXLL_THROW(std::runtime_error, - "Invalid parameter '" << *p << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid parameter '" << *p << "' in disk configuration file." + ); } } else if (eq[0] == "device_id" || eq[0] == "devid") @@ -471,8 +487,10 @@ void disk_config::parse_fileio() char* endp; device_id = static_cast(strtoul(eq[1].c_str(), &endp, 10)); if (endp && *endp != 0) { - FOXXLL_THROW(std::runtime_error, - "Invalid parameter '" << *p << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid parameter '" << *p << "' in disk configuration file." + ); } } else if (*p == "raw_device") @@ -495,8 +513,10 @@ void disk_config::parse_fileio() } else { - FOXXLL_THROW(std::runtime_error, - "Invalid optional parameter '" << *p << "' in disk configuration file."); + FOXXLL_THROW( + std::runtime_error, + "Invalid optional parameter '" << *p << "' in disk configuration file." + ); } } } diff --git a/foxxll/mng/disk_block_allocator.hpp b/foxxll/mng/disk_block_allocator.hpp index 3ef3c6f3..99178ca0 100644 --- a/foxxll/mng/disk_block_allocator.hpp +++ b/foxxll/mng/disk_block_allocator.hpp @@ -176,10 +176,12 @@ void disk_block_allocator::new_blocks(BIDIterator begin, BIDIterator end) if (free_bytes_ < requested_size) { if (!autogrow_) { - FOXXLL_THROW(bad_ext_alloc, - "Out of external memory error: " << requested_size << - " requested, " << free_bytes_ << " bytes free. " - "Maybe enable autogrow_ flags?"); + FOXXLL_THROW( + bad_ext_alloc, + "Out of external memory error: " << requested_size << + " requested, " << free_bytes_ << " bytes free. " + "Maybe enable autogrow_ flags?" + ); } LOG1 << "External memory block allocation error: " << requested_size << @@ -192,10 +194,12 @@ void disk_block_allocator::new_blocks(BIDIterator begin, BIDIterator end) // dump(); space_map_type::iterator space = - std::find_if(free_space_.begin(), free_space_.end(), - [requested_size](const place& entry) { - return (entry.second >= requested_size); - }); + std::find_if( + free_space_.begin(), free_space_.end(), + [requested_size](const place& entry) { + return (entry.second >= requested_size); + } + ); if (space == free_space_.end() && begin + 1 == end) { @@ -210,10 +214,12 @@ void disk_block_allocator::new_blocks(BIDIterator begin, BIDIterator end) grow_file(begin->size); - space = std::find_if(free_space_.begin(), free_space_.end(), - [requested_size](const place& entry) { - return (entry.second >= requested_size); - }); + space = std::find_if( + free_space_.begin(), free_space_.end(), + [requested_size](const place& entry) { + return (entry.second >= requested_size); + } + ); } if (space != free_space_.end()) diff --git a/foxxll/mng/prefetch_pool.hpp b/foxxll/mng/prefetch_pool.hpp index b8fd1bbe..cd1f9379 100644 --- a/foxxll/mng/prefetch_pool.hpp +++ b/foxxll/mng/prefetch_pool.hpp @@ -45,8 +45,8 @@ class prefetch_pool size_t operator () (const bid_type& bid) const { size_t result = size_t(bid.storage) + - size_t(bid.offset & 0xffffffff) + - size_t(bid.offset >> 32); + size_t(bid.offset & 0xffffffff) + + size_t(bid.offset >> 32); return result; } #if FOXXLL_MSVC diff --git a/foxxll/mng/typed_block.hpp b/foxxll/mng/typed_block.hpp index 285f096b..2b132513 100644 --- a/foxxll/mng/typed_block.hpp +++ b/foxxll/mng/typed_block.hpp @@ -227,7 +227,7 @@ class add_filler public: add_filler() { - LOGC(debug_typed_block) << "[" << static_cast(this) << "] add_filler<> is constructed"; + LOGC(debug_typed_block) << "[" << static_cast(this) << "] add_filler<> is constructed"; } }; @@ -278,8 +278,10 @@ class typed_block typed_block() { - static_assert(sizeof(typed_block) == raw_size, - "sizeof(typed_block) == raw_size"); + static_assert( + sizeof(typed_block) == raw_size, + "sizeof(typed_block) == raw_size" + ); LOGC(debug_typed_block) << "[" << static_cast(this) << "] typed_block is constructed"; #if 0 assert(((long)this) % BlockAlignment == 0); @@ -346,7 +348,8 @@ class typed_block LOGC(debug_typed_block) << "typed::block operator new[]: bytes=" << bytes << ", meta_info_size=" << meta_info_size; void* result = aligned_alloc( - bytes - meta_info_size, meta_info_size); + bytes - meta_info_size, meta_info_size + ); #if FOXXLL_WITH_VALGRIND memset(result, 0, bytes); @@ -360,7 +363,8 @@ class typed_block LOGC(debug_typed_block) << "typed::block operator new[]: bytes=" << bytes << ", meta_info_size=" << meta_info_size; void* result = aligned_alloc( - bytes - meta_info_size, meta_info_size); + bytes - meta_info_size, meta_info_size + ); #if FOXXLL_WITH_VALGRIND memset(result, 0, bytes); diff --git a/foxxll/mng/write_pool.hpp b/foxxll/mng/write_pool.hpp index 7487688e..8de93260 100644 --- a/foxxll/mng/write_pool.hpp +++ b/foxxll/mng/write_pool.hpp @@ -91,8 +91,10 @@ class write_pool //! Waits for completion of all ongoing write requests and frees memory. ~write_pool() { - FOXXLL_VERBOSE_WPOOL("::~write_pool free_blocks.size()=" << free_blocks.size() << - " busy_blocks.size()=" << busy_blocks.size()); + FOXXLL_VERBOSE_WPOOL( + "::~write_pool free_blocks.size()=" << free_blocks.size() << + " busy_blocks.size()=" << busy_blocks.size() + ); while (!free_blocks.empty()) { FOXXLL_VERBOSE_WPOOL(" delete free block=" << free_blocks.back()); @@ -244,8 +246,10 @@ class write_pool } ++cur; } - FOXXLL_VERBOSE_WPOOL("::check_all_busy : " << cnt << - " are completed out of " << busy_blocks.size() + cnt << " busy blocks"); + FOXXLL_VERBOSE_WPOOL( + "::check_all_busy : " << cnt << + " are completed out of " << busy_blocks.size() + cnt << " busy blocks" + ); } }; diff --git a/foxxll/singleton.hpp b/foxxll/singleton.hpp index f0505dd2..77c4f72f 100644 --- a/foxxll/singleton.hpp +++ b/foxxll/singleton.hpp @@ -49,7 +49,8 @@ class singleton return instance; } - inline static instance_type& get_ref() { + inline static instance_type & get_ref() + { if (!instance) create_instance(); diff --git a/foxxll/version.hpp b/foxxll/version.hpp index 6d515111..69289bb6 100644 --- a/foxxll/version.hpp +++ b/foxxll/version.hpp @@ -85,9 +85,11 @@ inline void print_library_version_mismatch() { if (foxxll::check_library_version() != 0) { - die("version mismatch between headers" + die( + "version mismatch between headers" " (" << FOXXLL_VERSION_STRING ") and library" - " (" << get_library_version_string() << ")"); + " (" << get_library_version_string() << ")" + ); } } diff --git a/misc/uncrustify.cfg b/misc/uncrustify.cfg index 058810a2..6ffbb515 100644 --- a/misc/uncrustify.cfg +++ b/misc/uncrustify.cfg @@ -227,7 +227,7 @@ indent_paren_nl = false # false/true # 0: Indent to body level # 1: Align under the open paren # 2: Indent to the brace level -indent_paren_close = 0 # number +indent_paren_close = 2 # number # Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren indent_comma_paren = false # false/true @@ -246,7 +246,7 @@ indent_preserve_sql = false # false/true # Align continued statements at the '='. Default=True # If FALSE or the '=' is followed by a newline, the next line is indent one tab. -indent_align_assign = true # false/true +indent_align_assign = false # false/true # Indent OC blocks at brace level instead of usual rules. indent_oc_block = false # false/true @@ -1323,13 +1323,13 @@ nl_func_decl_empty = remove # ignore/add/remove/force nl_func_def_empty = remove # ignore/add/remove/force # Whether to add newline after '(' in a function call if '(' and ')' are in different lines. -nl_func_call_start_multi_line = false # false/true +nl_func_call_start_multi_line = true # false/true # Whether to add newline after each ',' in a function call if '(' and ')' are in different lines. nl_func_call_args_multi_line = false # false/true # Whether to add newline before ')' in a function call if '(' and ')' are in different lines. -nl_func_call_end_multi_line = false # false/true +nl_func_call_end_multi_line = true # false/true # Whether to put each OC message parameter on a separate line # See nl_oc_msg_leave_one_liner diff --git a/tests/io/test_cancel.cpp b/tests/io/test_cancel.cpp index 9863fbea..e17b17ca 100644 --- a/tests/io/test_cancel.cpp +++ b/tests/io/test_cancel.cpp @@ -45,8 +45,9 @@ int main(int argc, char** argv) memset(buffer, 0, size); foxxll::file_ptr file = foxxll::create_file( - argv[1], argv[2], - foxxll::file::CREAT | foxxll::file::RDWR | foxxll::file::DIRECT); + argv[1], argv[2], + foxxll::file::CREAT | foxxll::file::RDWR | foxxll::file::DIRECT + ); file->set_size(kNumBlocks * size); foxxll::request_ptr req[kNumBlocks]; diff --git a/tests/io/test_io.cpp b/tests/io/test_io.cpp index 9080320e..6c322e33 100644 --- a/tests/io/test_io.cpp +++ b/tests/io/test_io.cpp @@ -52,12 +52,14 @@ int main(int argc, char** argv) #if FOXXLL_HAVE_MMAP_FILE foxxll::file_ptr file1 = tlx::make_counting( - tempfilename[0], file::CREAT | file::RDWR | file::DIRECT, 0); + tempfilename[0], file::CREAT | file::RDWR | file::DIRECT, 0 + ); file1->set_size(size * 1024); #endif foxxll::file_ptr file2 = tlx::make_counting( - tempfilename[1], file::CREAT | file::RDWR | file::DIRECT, 1); + tempfilename[1], file::CREAT | file::RDWR | file::DIRECT, 1 + ); foxxll::request_ptr req[16]; unsigned i; diff --git a/tests/io/test_io_sizes.cpp b/tests/io/test_io_sizes.cpp index 6eb223b6..8e43588f 100644 --- a/tests/io/test_io_sizes.cpp +++ b/tests/io/test_io_sizes.cpp @@ -31,8 +31,9 @@ int main(int argc, char** argv) try { foxxll::file_ptr file = foxxll::create_file( - argv[1], argv[2], - foxxll::file::CREAT | foxxll::file::RDWR | foxxll::file::DIRECT); + argv[1], argv[2], + foxxll::file::CREAT | foxxll::file::RDWR | foxxll::file::DIRECT + ); file->set_size(max_size); foxxll::request_ptr req; diff --git a/tests/io/test_mmap.cpp b/tests/io/test_mmap.cpp index 16b64c9e..1d1e0902 100644 --- a/tests/io/test_mmap.cpp +++ b/tests/io/test_mmap.cpp @@ -35,12 +35,14 @@ void testIO() #else const char* paths[2] = { "/var/tmp/data1", "/var/tmp/data2" }; foxxll::file_ptr file1 = tlx::make_counting( - paths[0], foxxll::file::CREAT | foxxll::file::RDWR, 0); + paths[0], foxxll::file::CREAT | foxxll::file::RDWR, 0 + ); file1->set_size(size * 1024); #endif foxxll::file_ptr file2 = tlx::make_counting( - paths[1], foxxll::file::CREAT | foxxll::file::RDWR, 1); + paths[1], foxxll::file::CREAT | foxxll::file::RDWR, 1 + ); foxxll::request_ptr req[16]; unsigned i = 0; diff --git a/tests/mng/test_block_manager.cpp b/tests/mng/test_block_manager.cpp index 95a06c3f..348c7294 100644 --- a/tests/mng/test_block_manager.cpp +++ b/tests/mng/test_block_manager.cpp @@ -91,9 +91,11 @@ int main() reqs[i]->wait(); for (size_t j = 0; j < block_type::size; ++j) { - die_with_message_unless(i + j == block[i].elem[j].integer, - "Error in block " << std::hex << i << " pos: " << j - << " value read: " << block[i].elem[j].integer); + die_with_message_unless( + i + j == block[i].elem[j].integer, + "Error in block " << std::hex << i << " pos: " << j + << " value read: " << block[i].elem[j].integer + ); } } diff --git a/tests/mng/test_block_scheduler.cpp b/tests/mng/test_block_scheduler.cpp index 04f56815..065fa0ef 100644 --- a/tests/mng/test_block_scheduler.cpp +++ b/tests/mng/test_block_scheduler.cpp @@ -101,8 +101,10 @@ void test1() size_t num_err = 0; for (size_t i = 0; i < block_size; ++i) num_err += (ib[i] != i); - die_with_message_unless(num_err == 0, - "previously initialized block had " << num_err << " errors."); + die_with_message_unless( + num_err == 0, + "previously initialized block had " << num_err << " errors." + ); } { // get a new reference to the already allocated block (because we forgot the old one) @@ -184,7 +186,8 @@ void test1() // switch to LFD processing delete bs.switch_algorithm_to( - new foxxll::block_scheduler_algorithm_offline_lfd(asim)); + new foxxll::block_scheduler_algorithm_offline_lfd(asim) + ); sbi = bs.allocate_swappable_block(); bs.acquire(sbi); @@ -203,7 +206,8 @@ void test1() #if 0 // 2013-tb: segfaults due to missing prediction sequence? TODO delete bs.switch_algorithm_to( - new foxxll::block_scheduler_algorithm_offline_lru_prefetching(asim)); + new foxxll::block_scheduler_algorithm_offline_lru_prefetching(asim) + ); sbi = bs.allocate_swappable_block(); bs.acquire(sbi); bs.acquire(sbi); @@ -222,8 +226,10 @@ void test1() delete bs_ptr; int_bl->read(ext_bl)->wait(); - die_with_message_unless(test_pattern_B(*int_bl) == 0, - "after extraction changed block should contain pattern B."); + die_with_message_unless( + test_pattern_B(*int_bl) == 0, + "after extraction changed block should contain pattern B." + ); delete int_bl; } @@ -353,10 +359,14 @@ int main(int argc, char** argv) tlx::CmdlineParser cp; - cp.add_int('t', "test-case", "I", test_case, - "number of the test case to run"); - cp.add_int('m', "memory", "N", internal_memory_megabytes, - "internal memory to use (in megabytes)"); + cp.add_int( + 't', "test-case", "I", test_case, + "number of the test case to run" + ); + cp.add_int( + 'm', "memory", "N", internal_memory_megabytes, + "internal memory to use (in megabytes)" + ); cp.set_description("foxxll block_scheduler test"); cp.set_author("Raoul Steffen, R-Steffen@gmx.de"); diff --git a/tests/mng/test_buf_streams.cpp b/tests/mng/test_buf_streams.cpp index d98fc054..357be534 100644 --- a/tests/mng/test_buf_streams.cpp +++ b/tests/mng/test_buf_streams.cpp @@ -56,8 +56,10 @@ int main() unsigned value; in >> value; - die_with_message_unless(value == i, - "Error at position " << std::hex << i << " (" << value << ") block " << (i / block_type::size)); + die_with_message_unless( + value == i, + "Error at position " << std::hex << i << " (" << value << ") block " << (i / block_type::size) + ); die_unless(prevalue == value); } } @@ -69,8 +71,10 @@ int main() unsigned value; in >> value; - die_with_message_unless(value == nelements - i - 1, - "Error at position " << std::hex << i << " (" << value << ") block " << (i / block_type::size)); + die_with_message_unless( + value == nelements - i - 1, + "Error at position " << std::hex << i << " (" << value << ") block " << (i / block_type::size) + ); die_unless(prevalue == value); } } diff --git a/tests/mng/test_config.cpp b/tests/mng/test_config.cpp index d5025ddb..4de85047 100644 --- a/tests/mng/test_config.cpp +++ b/tests/mng/test_config.cpp @@ -40,11 +40,13 @@ void test1() die_unless_throws( cfg.parse_line("disk=/var/tmp/foxxll.tmp, 100 GiB, wincall_fileperblock unlink direct=on"), - std::runtime_error); + std::runtime_error + ); die_unless_throws( cfg.parse_line("disk=/var/tmp/foxxll.tmp,0x,syscall"), - std::runtime_error); + std::runtime_error + ); } void test2() @@ -63,8 +65,10 @@ void test2() die_unequal(disk1.path, "/tmp/foxxll-1.tmp"); die_unequal(disk1.size, 100 * 1024 * uint64_t(1024)); die_unequal(disk1.autogrow, 1); - die_unequal(disk1.fileio_string(), - "syscall direct=off unlink_on_open"); + die_unequal( + disk1.fileio_string(), + "syscall direct=off unlink_on_open" + ); config->add_disk(disk1); @@ -74,8 +78,10 @@ void test2() die_unequal(disk2.path, "/tmp/foxxll-2.tmp"); die_unequal(disk2.size, 200 * 1024 * uint64_t(1024)); - die_unequal(disk2.fileio_string(), - "syscall autogrow=no direct=off unlink_on_open"); + die_unequal( + disk2.fileio_string(), + "syscall autogrow=no direct=off unlink_on_open" + ); die_unequal(disk2.direct, 0); config->add_disk(disk2); diff --git a/tests/mng/test_pool_pair.cpp b/tests/mng/test_pool_pair.cpp index ab3b116e..dee5d0d1 100644 --- a/tests/mng/test_pool_pair.cpp +++ b/tests/mng/test_pool_pair.cpp @@ -72,8 +72,10 @@ int main() blk = w_pool.steal(); p_pool.read(blk, bid)->wait(); - die_with_message_unless((*blk)[0].integer == 23, - "WRITE-AFTER-WRITE COHERENCE FAILURE"); + die_with_message_unless( + (*blk)[0].integer == 23, + "WRITE-AFTER-WRITE COHERENCE FAILURE" + ); w_pool.add(blk); bm->delete_block(bid); @@ -104,8 +106,10 @@ int main() // get the hinted block p_pool.read(blk, bid)->wait(); - die_with_message_unless((*blk)[0].integer == 23, - "WRITE-AFTER-HINT COHERENCE FAILURE"); + die_with_message_unless( + (*blk)[0].integer == 23, + "WRITE-AFTER-HINT COHERENCE FAILURE" + ); w_pool.add(blk); bm->delete_block(bid); @@ -136,8 +140,10 @@ int main() // get the hinted block p_pool.read(blk, bid)->wait(); - die_with_message_unless((*blk)[0].integer == 23, - "WRITE-AFTER-HINT COHERENCE FAILURE"); + die_with_message_unless( + (*blk)[0].integer == 23, + "WRITE-AFTER-HINT COHERENCE FAILURE" + ); w_pool.add(blk); bm->delete_block(bid); diff --git a/tests/mng/test_read_write_pool.cpp b/tests/mng/test_read_write_pool.cpp index e12216f9..005dadaa 100644 --- a/tests/mng/test_read_write_pool.cpp +++ b/tests/mng/test_read_write_pool.cpp @@ -70,8 +70,10 @@ int main() blk = pool.steal(); pool.read(blk, bid)->wait(); - die_with_message_unless((*blk)[0].integer == 23, - "WRITE-AFTER-WRITE COHERENCE FAILURE"); + die_with_message_unless( + (*blk)[0].integer == 23, + "WRITE-AFTER-WRITE COHERENCE FAILURE" + ); pool.add(blk); bm->delete_block(bid); @@ -100,8 +102,10 @@ int main() // get the hinted block pool.read(blk, bid)->wait(); - die_with_message_unless((*blk)[0].integer == 23, - "WRITE-AFTER-HINT COHERENCE FAILURE"); + die_with_message_unless( + (*blk)[0].integer == 23, + "WRITE-AFTER-HINT COHERENCE FAILURE" + ); pool.add(blk); bm->delete_block(bid); @@ -130,8 +134,10 @@ int main() // get the hinted block pool.read(blk, bid)->wait(); - die_with_message_unless((*blk)[0].integer == 23, - "WRITE-AFTER-HINT COHERENCE FAILURE"); + die_with_message_unless( + (*blk)[0].integer == 23, + "WRITE-AFTER-HINT COHERENCE FAILURE" + ); pool.add(blk); bm->delete_block(bid); diff --git a/tools/benchmark_disks.cpp b/tools/benchmark_disks.cpp index baa80012..027a0945 100644 --- a/tools/benchmark_disks.cpp +++ b/tools/benchmark_disks.cpp @@ -32,8 +32,8 @@ #include #include -#include #include +#include #include #include @@ -103,7 +103,7 @@ int benchmark_disks_alloc( // allocate data blocks for (size_t j = 0; j < num_blocks_per_batch; ++j) { buffer[j] = reinterpret_cast( - foxxll::aligned_alloc<4096>(raw_block_size)); + foxxll::aligned_alloc<4096>(raw_block_size)); } // touch data, so it is actually allocated @@ -119,7 +119,7 @@ int benchmark_disks_alloc( for (external_size_type offset = 0; offset < endpos; offset += current_batch_size) { current_batch_size = static_cast( - std::min(batch_size, endpos - offset)); + std::min(batch_size, endpos - offset)); #if CHECK_AFTER_READ const size_t current_batch_size_int = current_batch_size / sizeof(uint32_t); #endif @@ -133,7 +133,8 @@ int benchmark_disks_alloc( for (BID& b : bids) b.size = raw_block_size; foxxll::block_manager::get_instance()->new_blocks( - alloc, bids.begin() + num_total_blocks, bids.end()); + alloc, bids.begin() + num_total_blocks, bids.end() + ); if (offset < start_offset) continue; @@ -168,7 +169,8 @@ int benchmark_disks_alloc( { for (size_t j = 0; j < current_num_blocks_per_batch; j++) reqs[j] = bids[num_total_blocks + j].read( - buffer[j], raw_block_size); + buffer[j], raw_block_size + ); wait_all(reqs, current_num_blocks_per_batch); @@ -242,21 +244,31 @@ int benchmark_disks(int argc, char* argv[]) size_t block_size = 8 * MiB; std::string optrw = "rw", allocstr; - cp.add_param_bytes("size", length, - "Amount of data to write/read from disks (e.g. 10GiB)"); + cp.add_param_bytes( + "size", length, + "Amount of data to write/read from disks (e.g. 10GiB)" + ); cp.add_opt_param_string( "r|w", optrw, - "Only read or write blocks (default: both write and read)"); + "Only read or write blocks (default: both write and read)" + ); cp.add_opt_param_string( "alloc", allocstr, - "Block allocation strategy: random_cyclic, simple_random, fully_random, striping. (default: random_cyclic)"); - - cp.add_unsigned('b', "batch", batch_size, - "Number of blocks written/read in one batch (default: D * B)"); - cp.add_bytes('B', "block_size", block_size, - "Size of blocks written in one syscall. (default: B = 8MiB)"); - cp.add_bytes('o', "offset", offset, - "Starting offset of operation range. (default: 0)"); + "Block allocation strategy: random_cyclic, simple_random, fully_random, striping. (default: random_cyclic)" + ); + + cp.add_unsigned( + 'b', "batch", batch_size, + "Number of blocks written/read in one batch (default: D * B)" + ); + cp.add_bytes( + 'B', "block_size", block_size, + "Size of blocks written in one syscall. (default: B = 8MiB)" + ); + cp.add_bytes( + 'o', "offset", offset, + "Starting offset of operation range. (default: 0)" + ); cp.set_description( "This program will benchmark the disks configured by the standard " @@ -265,7 +277,8 @@ int benchmark_disks(int argc, char* argv[]) "size describes how many blocks are written/read in one batch. The " "are taken from block_manager using given the specified allocation " "strategy. If size == 0, then writing/reading operation are done " - "until an error occurs. "); + "until an error occurs. " + ); if (!cp.process(argc, argv)) return -1; @@ -274,16 +287,20 @@ int benchmark_disks(int argc, char* argv[]) { if (allocstr == "random_cyclic") return benchmark_disks_alloc( - length, offset, batch_size, block_size, optrw); + length, offset, batch_size, block_size, optrw + ); if (allocstr == "simple_random") return benchmark_disks_alloc( - length, offset, batch_size, block_size, optrw); + length, offset, batch_size, block_size, optrw + ); if (allocstr == "fully_random") return benchmark_disks_alloc( - length, offset, batch_size, block_size, optrw); + length, offset, batch_size, block_size, optrw + ); if (allocstr == "striping") return benchmark_disks_alloc( - length, offset, batch_size, block_size, optrw); + length, offset, batch_size, block_size, optrw + ); std::cout << "Unknown allocation strategy '" << allocstr << "'" << std::endl; cp.print_usage(); @@ -291,5 +308,6 @@ int benchmark_disks(int argc, char* argv[]) } return benchmark_disks_alloc( - length, offset, batch_size, block_size, optrw); + length, offset, batch_size, block_size, optrw + ); } diff --git a/tools/benchmark_disks_random.cpp b/tools/benchmark_disks_random.cpp index 496af7b3..9312d394 100644 --- a/tools/benchmark_disks_random.cpp +++ b/tools/benchmark_disks_random.cpp @@ -213,26 +213,32 @@ int benchmark_disks_random(int argc, char* argv[]) cp.add_param_bytes( "span", span, - "Span of external memory to write/read to (e.g. 10GiB)."); + "Span of external memory to write/read to (e.g. 10GiB)." + ); cp.add_opt_param_bytes( "block_size", block_size, - "Size of blocks to randomly write/read (default: 8MiB)."); + "Size of blocks to randomly write/read (default: 8MiB)." + ); cp.add_opt_param_bytes( "size", worksize, - "Amount of data to operate on (e.g. 2GiB), default: whole span."); + "Amount of data to operate on (e.g. 2GiB), default: whole span." + ); cp.add_opt_param_string( "i|r|w", optirw, - "Operations: [i]nitialize, [r]ead, and/or [w]rite (default: all)."); + "Operations: [i]nitialize, [r]ead, and/or [w]rite (default: all)." + ); cp.add_opt_param_string( "alloc", allocstr, - "Block allocation strategy: random_cyclic, simple_random, fully_random, striping (default: random_cyclic)."); + "Block allocation strategy: random_cyclic, simple_random, fully_random, striping (default: random_cyclic)." + ); cp.set_description( "This program will benchmark _random_ block access on the disks " "configured by the standard .foxxll disk configuration files mechanism. " "Available block sizes are power of two from 4 KiB to 128 MiB. " "A set of three operations can be performed: sequential initialization, " - "random reading and random writing."); + "random reading and random writing." + ); if (!cp.process(argc, argv)) return -1; diff --git a/tools/benchmark_files.cpp b/tools/benchmark_files.cpp index f7ed41e4..4599e471 100644 --- a/tools/benchmark_files.cpp +++ b/tools/benchmark_files.cpp @@ -116,42 +116,64 @@ int benchmark_files(int argc, char* argv[]) tlx::CmdlineParser cp; - cp.add_param_bytes("length", length, - "Length to write in file."); - - cp.add_param_stringlist("filename", files_arr, - "File path to run benchmark on."); - - cp.add_bytes('o', "offset", offset, - "Starting offset to write in file."); - - cp.add_bool(0, "no-direct", no_direct_io, - "open files without O_DIRECT"); - - cp.add_bool(0, "sync", sync_io, - "open files with O_SYNC|O_DSYNC|O_RSYNC"); - - cp.add_bool(0, "resize", resize_after_open, - "resize the file size after opening, " - "needed e.g. for creating mmap files"); - - cp.add_bytes(0, "block_size", block_size, - "block size for operations (default 8 MiB)"); - - cp.add_unsigned(0, "batch_size", batch_size, - "increase (default 1) to submit several I/Os at once " - "and report average rate"); - - cp.add_string('f', "file-type", file_type, - "Method to open file (syscall|mmap|wincall|...) " - "default: " + file_type); - - cp.add_string('p', "operations", opstr, - "[w]rite pattern, [r]ead without verification, " - "read and [v]erify pattern (default: 'wv')"); - - cp.add_unsigned(0, "pattern", pattern, - "32-bit pattern to write (default: block index)"); + cp.add_param_bytes( + "length", length, + "Length to write in file." + ); + + cp.add_param_stringlist( + "filename", files_arr, + "File path to run benchmark on." + ); + + cp.add_bytes( + 'o', "offset", offset, + "Starting offset to write in file." + ); + + cp.add_bool( + 0, "no-direct", no_direct_io, + "open files without O_DIRECT" + ); + + cp.add_bool( + 0, "sync", sync_io, + "open files with O_SYNC|O_DSYNC|O_RSYNC" + ); + + cp.add_bool( + 0, "resize", resize_after_open, + "resize the file size after opening, " + "needed e.g. for creating mmap files" + ); + + cp.add_bytes( + 0, "block_size", block_size, + "block size for operations (default 8 MiB)" + ); + + cp.add_unsigned( + 0, "batch_size", batch_size, + "increase (default 1) to submit several I/Os at once " + "and report average rate" + ); + + cp.add_string( + 'f', "file-type", file_type, + "Method to open file (syscall|mmap|wincall|...) " + "default: " + file_type + ); + + cp.add_string( + 'p', "operations", opstr, + "[w]rite pattern, [r]ead without verification, " + "read and [v]erify pattern (default: 'wv')" + ); + + cp.add_unsigned( + 0, "pattern", pattern, + "32-bit pattern to write (default: block index)" + ); cp.set_description( "Open a file using one of FOXXLL's file abstractions and perform " @@ -159,7 +181,8 @@ int benchmark_files(int argc, char* argv[]) "Block sizes and batch size can be adjusted via command line. " "If length == 0 , then operation will continue till end of space " "(please ignore the write error). " - "Memory consumption: block_size * batch_size * num_files"); + "Memory consumption: block_size * batch_size * num_files" + ); if (!cp.process(argc, argv)) return -1; @@ -276,9 +299,11 @@ int benchmark_files(int argc, char* argv[]) { for (size_t j = 0; j < current_num_blocks; j++) reqs[i * current_num_blocks + j] = - files[i]->awrite(buffer + current_step_size_int * i + j * block_size_int, - offset + j * block_size, - block_size); + files[i]->awrite( + buffer + current_step_size_int * i + j * block_size_int, + offset + j * block_size, + block_size + ); } #ifdef WATCH_TIMES @@ -322,9 +347,11 @@ int benchmark_files(int argc, char* argv[]) { for (size_t j = 0; j < current_num_blocks; j++) reqs[i * current_num_blocks + j] = - files[i]->aread(buffer + current_step_size_int * i + j * block_size_int, - offset + j * block_size, - block_size); + files[i]->aread( + buffer + current_step_size_int * i + j * block_size_int, + offset + j * block_size, + block_size + ); } #ifdef WATCH_TIMES diff --git a/tools/create_files.cpp b/tools/create_files.cpp index 89e43872..a5938f60 100644 --- a/tools/create_files.cpp +++ b/tools/create_files.cpp @@ -91,10 +91,14 @@ int create_files(int argc, char* argv[]) external_size_type offset = 0, length; tlx::CmdlineParser cp; - cp.add_param_bytes("filesize", length, - "Number of bytes to write to files."); - cp.add_param_stringlist("filename", disks_arr, - "Paths to files to write."); + cp.add_param_bytes( + "filesize", length, + "Number of bytes to write to files." + ); + cp.add_param_stringlist( + "filename", disks_arr, + "Paths to files to write." + ); if (!cp.process(argc, argv)) return -1; @@ -137,19 +141,27 @@ int create_files(int argc, char* argv[]) { #if FOXXLL_WINDOWS #ifdef RAW_ACCESS - disks[i] = new foxxll::wincall_file(disks_arr[i], - file::CREAT | file::RDWR | file::DIRECT, static_cast(i)); + disks[i] = new foxxll::wincall_file( + disks_arr[i], + file::CREAT | file::RDWR | file::DIRECT, static_cast(i) + ); #else - disks[i] = new foxxll::wincall_file(disks_arr[i], - file::CREAT | file::RDWR, static_cast(i)); + disks[i] = new foxxll::wincall_file( + disks_arr[i], + file::CREAT | file::RDWR, static_cast(i) + ); #endif #else #ifdef RAW_ACCESS - disks[i] = new foxxll::syscall_file(disks_arr[i], - file::CREAT | file::RDWR | file::DIRECT, static_cast(i)); + disks[i] = new foxxll::syscall_file( + disks_arr[i], + file::CREAT | file::RDWR | file::DIRECT, static_cast(i) + ); #else - disks[i] = new foxxll::syscall_file(disks_arr[i], - file::CREAT | file::RDWR, static_cast(i)); + disks[i] = new foxxll::syscall_file( + disks_arr[i], + file::CREAT | file::RDWR, static_cast(i) + ); #endif #endif } @@ -172,9 +184,11 @@ int create_files(int argc, char* argv[]) { for (j = 0; j < chunks; j++) reqs[i * chunks + j] = - disks[i]->awrite(buffer + buffer_size_int * i + j * chunk_size_int, - offset + j * current_chunk_size, - current_chunk_size); + disks[i]->awrite( + buffer + buffer_size_int * i + j * chunk_size_int, + offset + j * current_chunk_size, + current_chunk_size + ); } #ifdef WATCH_TIMES @@ -206,9 +220,11 @@ int create_files(int argc, char* argv[]) for (i = 0; i < ndisks; i++) { for (j = 0; j < chunks; j++) - reqs[i * chunks + j] = disks[i]->aread(buffer + buffer_size_int * i + j * chunk_size_int, - offset + j * current_chunk_size, - current_chunk_size); + reqs[i * chunks + j] = disks[i]->aread( + buffer + buffer_size_int * i + j * chunk_size_int, + offset + j * current_chunk_size, + current_chunk_size + ); } #ifdef WATCH_TIMES