Skip to content

Commit a2a3577

Browse files
committed
feat(file_reader): swap std::deque for small_fifo
Significantly improves `file_reader` performance, especially when used with `libc++`, where `std::deque` causes a significant regression due to its larger block size. ``` Summary libc++/dwarfsck.fifo8 -i perl-install-small-v0.7.5.dwarfs --checksum sha256 ran 1.00 ± 0.03 times faster than libstdc++/dwarfsck.fifo16 -i perl-install-small-v0.7.5.dwarfs --checksum sha256 1.00 ± 0.03 times faster than libc++/dwarfsck.fifo4 -i perl-install-small-v0.7.5.dwarfs --checksum sha256 1.01 ± 0.04 times faster than libstdc++/dwarfsck.deque -i perl-install-small-v0.7.5.dwarfs --checksum sha256 1.02 ± 0.03 times faster than libc++/dwarfsck.fifo16 -i perl-install-small-v0.7.5.dwarfs --checksum sha256 1.03 ± 0.04 times faster than libc++/dwarfsck.fifo32 -i perl-install-small-v0.7.5.dwarfs --checksum sha256 1.31 ± 0.04 times faster than libc++/dwarfsck.deque -i perl-install-small-v0.7.5.dwarfs --checksum sha256 ```
1 parent 9a30e5e commit a2a3577

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/reader/detail/file_reader.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
#include <array>
3030
#include <cassert>
31-
#include <deque>
3231
#include <numeric>
3332

3433
#include <dwarfs/binary_literals.h>
34+
#include <dwarfs/container/small_fifo.h>
3535
#include <dwarfs/detail/file_view_impl.h>
3636
#include <dwarfs/reader/detail/file_reader.h>
3737
#include <dwarfs/reader/filesystem_v2.h>
@@ -110,10 +110,13 @@ class block_range_iterable::state {
110110
}
111111

112112
private:
113+
template <typename T>
114+
using fifo_t = container::small_fifo<T, 8>;
115+
113116
filesystem_v2_lite const& fs_;
114117
uint32_t inode_;
115-
std::deque<file_range> ranges_;
116-
std::deque<std::future<block_range>> pending_;
118+
fifo_t<file_range> ranges_;
119+
fifo_t<std::future<block_range>> pending_;
117120
file_size_t current_bytes_{0};
118121
file_size_t pending_bytes_{0};
119122
file_size_t remaining_{0};

0 commit comments

Comments
 (0)