Skip to content

Commit

Permalink
Merge pull request #339 from BigVan/main
Browse files Browse the repository at this point in the history
[feat.] DynamicPrefetcher
  • Loading branch information
yuchen0cc authored Jul 30, 2024
2 parents 35d90d2 + 0753065 commit acf9140
Show file tree
Hide file tree
Showing 10 changed files with 407 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The whole project is managed by CMake. Binaries and resource files will be insta
```bash
mkdir build
cd build
cmake ..
cmake .. # -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=true -DBUILD_TESTING=true
make -j
sudo make install
```
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_library(overlaybd_image_lib
bk_download.cpp
prefetch.cpp
tools/sha256file.cpp
tools/comm_func.cpp
)
target_include_directories(overlaybd_image_lib PUBLIC
${CURL_INCLUDE_DIRS}
Expand Down
4 changes: 2 additions & 2 deletions src/image_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ LSMT::IFileRO *ImageFile::open_lowers(std::vector<ImageConfigNS::LayerConfig> &l
LOG_INFO("LSMT::open_files_ro(files, `) success", lowers.size());

if (m_prefetcher != nullptr) {
m_prefetcher->replay();
m_prefetcher->replay((IFile*)ret);
}

return ret;
Expand Down Expand Up @@ -463,7 +463,7 @@ int ImageFile::init_image_file() {
m_prefetcher = new_prefetcher(trace_file, concurrency);
}

} else if (!conf.recordTracePath().empty()) {
} else if (!conf.recordTracePath().empty() && (::access(conf.recordTracePath().c_str(), F_OK) == 0)) {
auto mode = Prefetcher::detect_mode(conf.recordTracePath());
if (mode != Prefetcher::Mode::Record && mode != Prefetcher::Mode::Replay) {
LOG_ERROR("Prefetch: incorrect mode ` for prefetching", mode);
Expand Down
1 change: 1 addition & 0 deletions src/image_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class ImageFile : public photon::fs::ForwardFile {
uint32_t block_size;
bool read_only = false;

// a merged view after stack all layers.
IFile* get_base() {
return m_file;
}
Expand Down
12 changes: 7 additions & 5 deletions src/overlaybd/lsmt/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ static LSMTReadOnlyFile *open_file_ro(IFile *file, bool ownership, bool reserve_
static HeaderTrailer *verify_ht(IFile *file, char *buf, bool is_trailer = false,
ssize_t st_size = -1);

static const uint32_t ALIGNMENT = 512; // same as trim block size.
static const uint32_t ALIGNMENT4K = 4096;

static const int ABORT_FLAG_DETECTED = -2;

Expand Down Expand Up @@ -546,7 +544,9 @@ class LSMTReadOnlyFile : public IFileRW {
auto ret = pread(buf, MAX_IO_SIZE, offset);
if (ret < (ssize_t)MAX_IO_SIZE)
return -1;
(char *&)buf += MAX_IO_SIZE;
if (buf != nullptr) {
(char *&)buf += MAX_IO_SIZE;
}
count -= MAX_IO_SIZE;
offset += MAX_IO_SIZE;
}
Expand All @@ -557,8 +557,10 @@ class LSMTReadOnlyFile : public IFileRW {
m_index, s,
[&](const Segment &m) __attribute__((always_inline)) {
auto step = m.length * ALIGNMENT;
memset(buf, 0, step);
(char *&)buf += step;
if (buf != nullptr) {
memset(buf, 0, step);
(char *&)buf += step;
}
return 0;
},
[&](const SegmentMapping &m) __attribute__((always_inline)) {
Expand Down
2 changes: 2 additions & 0 deletions src/overlaybd/lsmt/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace LSMT {

static const int MAX_STACK_LAYERS = 255;

static const uint32_t ALIGNMENT = 512; // same as trim block size.
static const uint32_t ALIGNMENT4K = 4096;
class IFileRO : public photon::fs::VirtualReadOnlyFile {
public:
static const int GetType = 12;
Expand Down
Loading

0 comments on commit acf9140

Please sign in to comment.