diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2017-08-28 19:17:25 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2017-08-28 19:17:25 +0300 |
commit | 71632c273d167e5de0de273bd5bc2d426fda64c4 (patch) | |
tree | 570f9ede30b922bd9cf2da4b61fb82bd5b131198 | |
parent | 2d807ea2643b89aa106b7556f279672653e3d64e (diff) |
Minor fixes to safe_byte_ranges, but will need to wait to tonight with a proper POSIX machine to debug.
-rw-r--r-- | include/afio/v2.0/detail/impl/posix/utils.ipp | 9 | ||||
-rw-r--r-- | include/afio/v2.0/detail/impl/safe_byte_ranges.ipp | 19 | ||||
-rw-r--r-- | release_notes.md | 5 |
3 files changed, 20 insertions, 13 deletions
diff --git a/include/afio/v2.0/detail/impl/posix/utils.ipp b/include/afio/v2.0/detail/impl/posix/utils.ipp index c6c37ec0..e2bd0bf9 100644 --- a/include/afio/v2.0/detail/impl/posix/utils.ipp +++ b/include/afio/v2.0/detail/impl/posix/utils.ipp @@ -117,13 +117,14 @@ namespace utils void random_fill(char *buffer, size_t bytes) noexcept { static QUICKCPPLIB_NAMESPACE::configurable_spinlock::spinlock<bool> lock; - static int randomfd = -1; - if(-1 == randomfd) + static std::atomic<int> randomfd(-1); + int fd = randomfd; + if(-1 == fd) { std::lock_guard<decltype(lock)> g(lock); - randomfd = ::open("/dev/urandom", O_RDONLY); + randomfd = fd = ::open("/dev/urandom", O_RDONLY); } - if(-1 == randomfd || ::read(randomfd, buffer, bytes) < (ssize_t) bytes) + if(-1 == fd || ::read(fd, buffer, bytes) < (ssize_t) bytes) { AFIO_LOG_FATAL(0, "afio: Kernel crypto function failed"); std::terminate(); diff --git a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp index 162bb328..aea2db85 100644 --- a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp +++ b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp @@ -86,6 +86,8 @@ namespace algorithm void _unlock(unsigned mythreadid, entity_type entity) { auto it = _thread_locks.find(entity.value); + assert(it != _thread_locks.end()); + assert(it->second.writer_tid == mythreadid || it->second.writer_tid == 0); if(it->second.writer_tid == mythreadid) { if(!it->second.reader_tids.empty()) @@ -101,14 +103,17 @@ namespace algorithm return; } } - // Remove me from reader tids - auto reader_tid_it = std::find(it->second.reader_tids.begin(), it->second.reader_tids.end(), mythreadid); - assert(reader_tid_it != it->second.reader_tids.end()); - if(reader_tid_it != it->second.reader_tids.end()) + else { - // We don't care about the order, so fastest is to swap this tid with final tid and resize down - std::swap(*reader_tid_it, it->second.reader_tids.back()); - it->second.reader_tids.pop_back(); + // Remove me from reader tids + auto reader_tid_it = std::find(it->second.reader_tids.begin(), it->second.reader_tids.end(), mythreadid); + assert(reader_tid_it != it->second.reader_tids.end()); + if(reader_tid_it != it->second.reader_tids.end()) + { + // We don't care about the order, so fastest is to swap this tid with final tid and resize down + std::swap(*reader_tid_it, it->second.reader_tids.back()); + it->second.reader_tids.pop_back(); + } } if(it->second.reader_tids.empty()) { diff --git a/release_notes.md b/release_notes.md index 80978374..81538af1 100644 --- a/release_notes.md +++ b/release_notes.md @@ -35,7 +35,7 @@ Manufacturer claimed 4Kb transfer latencies for the physical hardware: - < 99% SATA flash drive latency: Windows **290us** Linux **158us** - < 99% NVMe drive latency: Windows **150us** FreeBSD **70us** Linux **30us** -Lowest achievable 4Kb read latency benchmarked to date by author: **0.19us** (5.3M IOPS @ QD1, approx 20Gb/sec) +Empirical AFIO read latency benchmarked by author: **0.19us** (5.3M IOPS @ QD1, approx 20Gb/sec) </td> <td valign="top" width="33%"> 75% read 25% write QD4 4Kb direct transfer latencies for the software with AFIO: @@ -43,7 +43,7 @@ Lowest achievable 4Kb read latency benchmarked to date by author: **0.19us** (5. - < 99% SATA flash drive latency: Windows **1,812us** Linux **1,416us** - < 99% NVMe drive latency: Windows **95us** FreeBSD **143us** Linux **40us** -Lowest achievable 4Kb write latency benchmarked to date by author: **0.18us** (5.6M IOPS @ QD1, approx 21Gb/sec) +Empirical AFIO write latency benchmarked by author: **0.18us** (5.6M IOPS @ QD1, approx 21Gb/sec) </td> </tr> </table> @@ -142,6 +142,7 @@ Todo: | ✔ | ✔ | ✔ | Universal portable UTF-8 path views. | | ✔ | ✔ | "Hole punching" and hole enumeration ported over from AFIO v1. | | ✔ | ✔ | Directory handles and very fast directory enumeration ported over from AFIO v1. +| ✔ | ✔ | ✔ | `shared_fs_mutex` shared/exclusive entities locking based on safe byte ranges Todo to reach feature parity with AFIO v1: |