Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capio v2 #113

Draft
wants to merge 86 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
cc96736
Cleanup of CAPIOV1 unused code
Jul 17, 2024
00ac7d9
storage_engine for metadata handling
Jul 18, 2024
4ebc302
Improved systemcall handlers
Jul 19, 2024
034eed9
Support for commit rule
Jul 30, 2024
18ebd6f
Implemented write cache for write requests
Jul 31, 2024
c9ea4f9
Filesystem Monitor thread
Aug 2, 2024
4f209b1
Improved read request cache
Aug 2, 2024
61d23b0
Capioctl
Aug 10, 2024
5627e72
Refactor code to reflect choosen architecture
Sep 5, 2024
468f583
JSON parser
Sep 5, 2024
188f8a5
Improved logging request
Sep 10, 2024
1b035b9
Varius bugfixes
Sep 10, 2024
6af3b46
cache
Sep 11, 2024
a1558ab
File System Monitor fixes
Sep 11, 2024
59b88b1
Memory initialization and bugfixes
Sep 11, 2024
60aae95
Code cleanup and bugfixes
Sep 12, 2024
152b219
Support for n_files
Sep 12, 2024
e6d0c10
Support for CoF
marcoSanti Sep 17, 2024
aa2824c
Support for CoC:n
Sep 21, 2024
8a81ade
Bugfixes
Sep 27, 2024
0d1d793
Moved CAPIO metadata to other directory
Oct 1, 2024
8c48981
Protected map access to avoid std::out_of_range
Oct 2, 2024
cc23d15
updated readme
Oct 2, 2024
d42b14d
Merge pull request #112 from marcoSanti/master
marcoSanti Oct 7, 2024
17df088
Added doxygen documentation
Oct 7, 2024
85e293e
Added cache to consent to proceed handler
Oct 7, 2024
796208f
Merge pull request #114 from High-Performance-IO/consent_cache
marcoSanti Oct 7, 2024
ddacc35
Improvements in code cleaness and performance
Oct 7, 2024
0d916e0
Improved performances
Oct 8, 2024
a1253cd
added cache to commit files
Oct 10, 2024
0cfd470
Improved code
Oct 10, 2024
eff20d7
Improved code
Oct 10, 2024
8f070ed
Replaced match_globs with std::regex
Oct 10, 2024
cb7096b
Improved code
Oct 10, 2024
a5a67ca
Fix on regex lang
Oct 10, 2024
ed0c860
possible fix on regex
Oct 10, 2024
974be60
Fixed capio cl regex
Oct 12, 2024
69f16cd
fixes
Oct 14, 2024
5b8bf92
Bugfix on client manager and create handler
Oct 14, 2024
3eaedce
Merge pull request #115 from High-Performance-IO/performance-improv
marcoSanti Oct 14, 2024
9cfc25a
Improved the file_manager_impl.hpp
Oct 14, 2024
dbaba99
Varius fixes and hopefully performance improvements
Oct 14, 2024
eceaf4c
Fixed issue on FSMonitor
Oct 15, 2024
8923920
fix
Oct 15, 2024
d78d41f
fixes
Oct 15, 2024
9c42bd9
Clean code and reduced operation overhead
Oct 16, 2024
0f1c799
Refactor of file-manager component
Oct 16, 2024
e884f4f
fix
Oct 16, 2024
d7aa698
fix
Oct 16, 2024
7c5fb49
fix
Oct 16, 2024
7dff576
fix
Oct 16, 2024
1b1a541
fix
Oct 16, 2024
91a2e78
fix
Oct 16, 2024
fb13db5
fixes
Oct 16, 2024
a8fe195
fixes
Oct 16, 2024
5c75d7b
fix
Oct 16, 2024
36616fc
fix
Oct 16, 2024
7c0fff7
fix
Oct 16, 2024
0d0fd1f
added timestamps to log
Oct 17, 2024
41e5e51
millis_time
Oct 17, 2024
3820c5c
log
Oct 17, 2024
305cbca
log
Oct 17, 2024
8fe23bb
fix
Oct 17, 2024
2a91463
fixes
Oct 17, 2024
d668344
Merge pull request #116 from High-Performance-IO/streaming_fixes
marcoSanti Oct 17, 2024
9edb367
fix
Oct 18, 2024
0d266bf
streaming fix
Oct 18, 2024
dbcbda9
fixes
Oct 18, 2024
57722f2
fix
Oct 18, 2024
4942532
logs
Oct 24, 2024
ed49245
Update CMakeLists.txt
Oct 24, 2024
8435d97
fixes
Oct 25, 2024
9bd965c
logs
Oct 25, 2024
b73428d
Merge pull request #117 from High-Performance-IO/streaming
marcoSanti Oct 25, 2024
f74c4de
Added CI tests on capio-v2 branch
Oct 25, 2024
15d2189
Fixes on consent (#118)
marcoSanti Oct 25, 2024
c2c7657
Capio memory file (#119)
marcoSanti Oct 30, 2024
5deb358
Capio memory file (#119)
marcoSanti Oct 30, 2024
d5d02f3
Added storage service
Oct 30, 2024
614205f
Bugfixes and unit tests
Nov 5, 2024
33c9eb6
Added fetching mechanism for file to store
Nov 19, 2024
5dd1f0f
Ported caches and write requests
Nov 26, 2024
8b2d4a5
Bugfixes
Nov 28, 2024
08f8bf3
Read and write caches
Dec 2, 2024
5feb88d
Merge branch 'capio-v2' into storage-service
marcoSanti Dec 11, 2024
55de1b6
Merge pull request #120 from High-Performance-IO/storage-service
marcoSanti Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Varius bugfixes
  • Loading branch information
Marco Edoardo Santimaria committed Oct 2, 2024
commit 1b035b916f124869306e34fe14f8e826737cc942
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

# Set compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pedantic -O0 -Wno-gnu-zero-variadic-macro-arguments")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pedantic -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")

#####################################
Expand Down
6 changes: 3 additions & 3 deletions src/common/capio/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ constexpr char CAPIO_SERVER_CLI_LOG_SERVER_WARNING[] = "[ \033[1;33m SERVER \033
constexpr char CAPIO_SERVER_CLI_LOG_SERVER_ERROR[] = "[ \033[1;31m SERVER \033[0m ] ";
constexpr char LOG_CAPIO_START_REQUEST[] = "\n+++++++++++ SYSCALL %s (%d) +++++++++++";
constexpr char LOG_CAPIO_END_REQUEST[] = "----------- END SYSCALL ----------\n";
constexpr char CAPIO_SERVER_LOG_START_REQUEST_MSG[] = "\n+++++++++++++++++REQUEST+++++++++++++++++";
constexpr char CAPIO_SERVER_LOG_END_REQUEST_MSG[] = "~~~~~~~~~~~~~~~END REQUEST~~~~~~~~~~~~~~~";
constexpr int CAPIO_LOG_MAX_MSG_LEN = 2048;
constexpr char CAPIO_SERVER_LOG_START_REQUEST_MSG[] = "\n+++++++++++++++++REQUEST+++++++++++++++++";
constexpr char CAPIO_SERVER_LOG_END_REQUEST_MSG[] = "~~~~~~~~~~~~~~~END REQUEST~~~~~~~~~~~~~~~";
constexpr int CAPIO_LOG_MAX_MSG_LEN = 2048;

// CAPIO streaming semantics
constexpr char CAPIO_FILE_MODE_NO_UPDATE[] = "no_update";
Expand Down
1 change: 1 addition & 0 deletions src/posix/libcapio_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ static int hook(long syscall_number, long arg0, long arg1, long arg2, long arg3,
return 1;
}

LOG("Handling syscall NO %ld (max num is %ld)", syscall_number, CAPIO_NR_SYSCALLS);
return syscallTable[syscall_number](arg0, arg1, arg2, arg3, arg4, arg5, result);
}

Expand Down
107 changes: 84 additions & 23 deletions src/server/capio-cl-engine/capio_cl_engine.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef CAPIO_ENGINE_HPP
#define CAPIO_ENGINE_HPP

#include "client-manager/client_manager.hpp"
#include "utils/common.hpp"

class CapioCLEngine {
Expand All @@ -18,7 +19,7 @@ class CapioCLEngine {
>
_locations;

static inline std::string truncate_last_n(const std::string &str, int n) {
static std::string truncate_last_n(const std::string &str, int n) {
return str.length() > n ? "[..] " + str.substr(str.length() - n) : str;
}

Expand Down Expand Up @@ -107,6 +108,7 @@ class CapioCLEngine {

// TODO: might need to be improved
bool file_to_be_handled(std::filesystem::path::iterator::reference path) const {
START_LOG(gettid(), "call(path=%s)", path.c_str());
for (const auto &entry : _locations) {
auto capio_path = entry.first;
if (path == capio_path) {
Expand All @@ -121,14 +123,18 @@ class CapioCLEngine {
return false;
};

inline void add(std::string &path, std::vector<std::string> &producers,
std::vector<std::string> &consumers, const std::string &commit_rule,
const std::string &fire_rule, bool permanent, bool exclude) {
void add(std::string &path, std::vector<std::string> &producers,
std::vector<std::string> &consumers, const std::string &commit_rule,
const std::string &fire_rule, bool permanent, bool exclude) {
START_LOG(gettid(), "call(path=%s, commit=%s, fire=%s, permanent=%s, exclude=%s)",
path.c_str(), commit_rule.c_str(), fire_rule.c_str(), permanent ? "YES" : "NO",
exclude ? "YES" : "NO");
_locations.emplace(path, std::make_tuple(producers, consumers, commit_rule, fire_rule,
permanent, exclude, true, -1, -1));
}

inline void newFile(const std::string &path) {
void newFile(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
if (_locations.find(path) == _locations.end()) {
std::string commit = CAPIO_FILE_COMMITTED_ON_TERMINATION;
std::string fire = CAPIO_FILE_MODE_UPDATE;
Expand All @@ -153,66 +159,121 @@ class CapioCLEngine {
}
}

inline void addProducer(const std::string &path, std::string &producer) {
void addProducer(const std::string &path, std::string &producer) {
START_LOG(gettid(), "call(path=%s, producer=%s)", path.c_str(), producer.c_str());
producer.erase(remove_if(producer.begin(), producer.end(), isspace), producer.end());
std::get<0>(_locations.at(path)).emplace_back(producer);
}

inline void addConsumer(const std::string &path, std::string &consumer) {
void addConsumer(const std::string &path, std::string &consumer) {
START_LOG(gettid(), "call(path=%s, consumer=%s)", path.c_str(), consumer.c_str());
consumer.erase(remove_if(consumer.begin(), consumer.end(), isspace), consumer.end());
std::get<1>(_locations.at(path)).emplace_back(consumer);
}

inline void setCommitRule(const std::string &path, const std::string &commit_rule) {
void setCommitRule(const std::string &path, const std::string &commit_rule) {
START_LOG(gettid(), "call(path=%s, commit_rule=%s)", path.c_str(), commit_rule.c_str());
std::get<2>(_locations.at(path)) = commit_rule;
}

inline std::string getCommitRule(const std::string &path) {
std::string getCommitRule(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
LOG("Fire rule: %s", std::get<2>(_locations.at(path)).c_str());
return std::get<2>(_locations.at(path));
}

inline void setFireRule(const std::string &path, const std::string &fire_rule) {
void setFireRule(const std::string &path, const std::string &fire_rule) {
START_LOG(gettid(), "call(path=%s, fire_rule=%s)", path.c_str(), fire_rule.c_str());
std::get<3>(_locations.at(path)) = fire_rule;
}

inline std::string getFireRule(const std::string &path) {
std::string getFireRule(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
return std::get<3>(_locations.at(path));
}

inline void setPermanent(const std::string &path, bool value) {
void setPermanent(const std::string &path, bool value) {
START_LOG(gettid(), "call(path=%s, value=%s)", path.c_str(), value ? "true" : "false");
std::get<4>(_locations.at(path)) = value;
}

inline void setExclude(const std::string &path, const bool value) {
void setExclude(const std::string &path, const bool value) {
START_LOG(gettid(), "call(path=%s, value=%s)", path.c_str(), value ? "true" : "false");
std::get<5>(_locations.at(path)) = value;
}

inline void setDirectory(const std::string &path) { std::get<6>(_locations.at(path)) = false; }
void setDirectory(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
std::get<6>(_locations.at(path)) = false;
}

inline bool isDirectory(const std::string &path) const {
bool isDirectory(const std::string &path) const {
START_LOG(gettid(), "call(path=%s)", path.c_str());
return !std::get<6>(_locations.at(path));
}

inline void setFile(const std::string &path) { std::get<6>(_locations.at(path)) = true; }
void setFile(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
std::get<6>(_locations.at(path)) = true;
}

inline bool isFile(const std::string &path) const { return std::get<6>(_locations.at(path)); }
bool isFile(const std::string &path) const {
START_LOG(gettid(), "call(path=%s)", path.c_str());
return std::get<6>(_locations.at(path));
}

inline void setCommitedNumber(const std::string &path, const int num) {
void setCommitedNumber(const std::string &path, const int num) {
START_LOG(gettid(), "call(path=%s, num=%ld)", path.c_str(), num);
std::get<7>(_locations.at(path)) = num;
}

inline void setDirectoryFileCount(const std::string &path, long num) {
void setDirectoryFileCount(const std::string &path, long num) {
START_LOG(gettid(), "call(path=%s, num=%ld)", path.c_str(), num);
std::get<8>(_locations.at(path)) = num;
}

inline void remove(const std::string &path) { _locations.erase(path); }
void remove(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
_locations.erase(path);
}

// TODO: return vector
inline auto producers(const std::string &path) { return std::get<0>(_locations.at(path)); }
auto producers(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
return std::get<0>(_locations.at(path));
}

// TODO: return vector
inline auto consumers(const std::string &path) { return std::get<1>(_locations.at(path)); }
auto consumers(const std::string &path) {
START_LOG(gettid(), "call(path=%s)", path.c_str());
return std::get<1>(_locations.at(path));
}

bool isProducer(const std::string &path, const pid_t pid) {
START_LOG(gettid(), "call(path=%s, pid=%ld", path.c_str(), pid);

const auto app_name = client_manager->get_app_name(pid);
LOG("App name for tid %d is %s", pid, app_name.c_str());

// check for exact entry
if (_locations.find(path) != _locations.end()) {
LOG("Found exact match for path");
std::vector<std::string> producers = std::get<0>(_locations.at(path));
return std::find(producers.begin(), producers.end(), app_name) != producers.end();
}
LOG("No exact match found in locations. checking for globs");
// check for glob
for (const auto &[k, entry] : _locations) {
if (match_globs(k, path)) {
LOG("Found possible glob match");
std::vector<std::string> producers = std::get<0>(_locations.at(k));
return std::find(producers.begin(), producers.end(), app_name) != producers.end();
}
}
LOG("No match has been found");
return false;
}
};

inline CapioCLEngine *capio_cl_engine;
CapioCLEngine *capio_cl_engine;
#endif // CAPIO_ENGINE_HPP
2 changes: 1 addition & 1 deletion src/server/capio-cl-engine/json_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class JsonParser {
std::filesystem::path file_fs(elem);
if (file_fs.is_relative() ||
first_is_subpath_of_second(file_fs, get_capio_dir())) {
LOG("Saving file %s to locations", elem.data());
LOG("Saving file %s to locations", std::string(elem).c_str());
streaming_names.emplace_back(elem);
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/server/client-manager/client_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ClientManager {

public:
ClientManager() {
START_LOG(gettid(), "call()");
bufs_response = new CSBufResponse_t();
app_names = new std::unordered_map<int, const std::string>;
files_to_be_committed_by_tid = new std::unordered_map<pid_t, std::vector<std::string> *>;
Expand All @@ -19,6 +20,7 @@ class ClientManager {
}

~ClientManager() {
START_LOG(gettid(), "call()");
delete bufs_response;
delete app_names;
delete files_to_be_committed_by_tid;
Expand All @@ -32,6 +34,7 @@ class ClientManager {
* @return
*/
inline void register_new_client(pid_t tid, const std::string &app_name) const {
START_LOG(gettid(), "call(tid=%ld, app_name=%s)", tid, app_name.c_str());
// TODO: replace numbers with constexpr
auto *p_buf_response =
new CircularBuffer<capio_off64_t>(SHM_COMM_CHAN_NAME_RESP + std::to_string(tid),
Expand All @@ -47,6 +50,7 @@ class ClientManager {
* @return
*/
inline void remove_client(pid_t tid) {
START_LOG(gettid(), "call(tid=%ld)", tid);
auto it_resp = bufs_response->find(tid);
if (it_resp != bufs_response->end()) {
delete it_resp->second;
Expand All @@ -68,12 +72,19 @@ class ClientManager {
}

void add_producer_file_path(pid_t tid, std::string &path) const {
START_LOG(gettid(), "call(tid=%ld, path=%s)", tid, path.c_str());
files_to_be_committed_by_tid->at(tid)->emplace_back(path);
}

[[nodiscard]] auto get_produced_files(pid_t tid) const {
START_LOG(gettid(), "call(tid=%ld)", tid);
return files_to_be_committed_by_tid->at(tid);
}

std::string get_app_name(pid_t tid) const {
START_LOG(gettid(), "call(tid=%ld)", tid);
return app_names->at(tid);
}
};

inline ClientManager *client_manager;
Expand Down
5 changes: 3 additions & 2 deletions src/server/client-manager/handlers/consent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ inline void consent_to_proceed_handler(const char *const str) {
return;
}

if (std::filesystem::exists(path) || CapioFileManager::is_committed(path)) {
LOG("It is possible to unlokc waiting thread");
if (std::filesystem::exists(path) || CapioFileManager::is_committed(path) ||
capio_cl_engine->isProducer(path, tid)) {
LOG("It is possible to unlock waiting thread");
client_manager->reply_to_client(tid, 1);
} else {
LOG("Requested file %s does not exists yet. awaiting for creation", path);
Expand Down
6 changes: 6 additions & 0 deletions src/server/file-manager/file_manager.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#ifndef FILE_MANAGER_HEADER_HPP
#define FILE_MANAGER_HEADER_HPP

#include <mutex>
std::mutex threads_mutex;
std::mutex data_mutex;

class CapioFileManager {
std::unordered_map<std::string, std::vector<pid_t> *> *thread_awaiting_file_creation;
std::unordered_map<std::string, std::unordered_map<pid_t, capio_off64_t> *>
*thread_awaiting_data;

public:
CapioFileManager() {
START_LOG(gettid(), "call()");
thread_awaiting_file_creation = new std::unordered_map<std::string, std::vector<pid_t> *>;
thread_awaiting_data =
new std::unordered_map<std::string, std::unordered_map<pid_t, capio_off64_t> *>;
std::cout << CAPIO_SERVER_CLI_LOG_SERVER << "CapioFileManager initialization completed."
<< std::endl;
}
~CapioFileManager() {
START_LOG(gettid(), "call()");
delete thread_awaiting_file_creation;
delete thread_awaiting_data;
}
Expand Down
Loading