Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ecbd7a1
add hdf5 backend for data swap
bozhang-hpc Aug 30, 2024
fd4e8fa
add swap policy and swap logic to put() & get()
bozhang-hpc Sep 10, 2024
a151dd9
fix comments
bozhang-hpc Sep 11, 2024
f05bf48
add toml default for swap space; add simple file debug logic
bozhang-hpc Sep 11, 2024
2ae4152
Merge branch 'master' into feat/file
bozhang-hpc Sep 11, 2024
3e3c3a5
fix conf header
bozhang-hpc Sep 11, 2024
90ac132
add swap config
bozhang-hpc Sep 11, 2024
e66c849
add directory operations
bozhang-hpc Sep 11, 2024
21cc604
change default swap dir path
bozhang-hpc Sep 11, 2024
44295a2
fix creating hdf5 files in a non-existing directory; fix no dataset w…
bozhang-hpc Sep 11, 2024
33aeacd
fix write_od arguments; add rm swap dir at server finalization
bozhang-hpc Sep 11, 2024
002675b
fix bbox init in read_od; fix hdf5 dataset name
bozhang-hpc Sep 11, 2024
8f2312b
fix dspaces DATATYPE translation in get()
bozhang-hpc Sep 11, 2024
3921641
add error info for empty swap list; rm hdf5 debug codes
bozhang-hpc Sep 12, 2024
26cb0c6
move all the bbox functions for swap to bbox.h & bbox.c
bozhang-hpc Sep 27, 2024
ca59ef7
fix the curl find_package(); conditionally required HDF5 & NetCDF; ad…
bozhang-hpc Sep 27, 2024
68dac37
conditionally enable file swap & HDF5
bozhang-hpc Sep 27, 2024
af34945
refactor the swap conf settings
bozhang-hpc Sep 27, 2024
6748f5a
add an abstraction for file swap backend; conditionally include file …
bozhang-hpc Sep 27, 2024
3a959c8
switch memory value type to an enum
bozhang-hpc Sep 27, 2024
e79e1b2
fix the potential fatal exit(); use uint64_t for memory values
bozhang-hpc Sep 27, 2024
ed4e692
add a default file backend setting into the swap_conf and adpat all o…
bozhang-hpc Sep 27, 2024
d84a86e
remove swap dir cleanup
bozhang-hpc Sep 27, 2024
407a6b9
fix conditional compilation for od swap in put()/get(); make the file…
bozhang-hpc Sep 29, 2024
e72bc53
fix od allocation when there is no file backend
bozhang-hpc Sep 29, 2024
caf0eee
more fix on conditional compilation
bozhang-hpc Sep 30, 2024
ab2df4a
add set_default_swap() to non toml conf setup
bozhang-hpc Oct 1, 2024
d8a8703
fix the declaration order
bozhang-hpc Oct 1, 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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ if(OPENMP_FOUND AND DSPACES_USE_OPENMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
add_definitions(-DOPS_USE_OPENMP)
endif()
find_package(CURL REQUIRED)
find_package(CURL)
Comment thread
bozhang-hpc marked this conversation as resolved.
if(CURL_FOUND)
add_definitions(-DDSPACES_HAVE_CURL)
endif()
find_package(HDF5 REQUIRED)
Comment thread
bozhang-hpc marked this conversation as resolved.
Outdated

include(CheckLanguage)
check_language(Fortran)
Expand Down
1 change: 1 addition & 0 deletions include/bbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int bbox_include(const struct bbox *, const struct bbox *);
int bbox_does_intersect(const struct bbox *, const struct bbox *);
void bbox_intersect(const struct bbox *, const struct bbox *, struct bbox *);
int bbox_equals(const struct bbox *, const struct bbox *);
int bbox_include_ondim(const struct bbox *b0, const struct bbox *b1, int dim);

uint64_t bbox_volume(const struct bbox *);
void bbox_to_intv(const struct bbox *, uint64_t, int, struct intv **, int *);
Expand Down
2 changes: 2 additions & 0 deletions include/dspaces-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ extern "C" {
#define dspaces_ERR_UNKNOWN_PR -7 /* Could not find server */
#define dspaces_ERR_UNKNOWN_OBJ -8 /* Could not find the object*/
#define dspaces_ERR_END -9 /* End of range for valid error codes */
#define dspaces_ERR_UTILS -12
#define dspaces_ERR_HDF5 -13

#define DS_MOD_EFAULT -1
#define DS_MOD_ENODEF -2
Expand Down
2 changes: 2 additions & 0 deletions include/dspaces-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "bbox.h"
#include "dspaces-remote.h"
#include "list.h"
#include "file_storage/policy.h"

static char *hash_strings[] = {"Dynamic", "Unitary", "SFC", "Bisection"};

Expand All @@ -18,6 +19,7 @@ struct ds_conf {
struct remote **remotes;
int nremote;
struct list_head *mods;
struct swap_config swap;
};

int parse_conf(const char *fname, struct ds_conf *conf);
Expand Down
10 changes: 10 additions & 0 deletions include/file_storage/file_hdf5.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __DSPACES_FILE_STORAGE_HDF5_H__
#define __DSPACES_FILE_STORAGE_HDF5_H__

#include "ss_data.h"
#include "file_storage/policy.h"

int hdf5_write_od(struct swap_config* swap_conf, struct obj_data *od);
int hdf5_read_od(struct swap_config* swap_conf, struct obj_data *od);

#endif // __DSPACES_FILE_STORAGE_HDF5_H__
33 changes: 33 additions & 0 deletions include/file_storage/policy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef __DSPACES_FILE_STORAGE_POLICY_H__
#define __DSPACES_FILE_STORAGE_POLICY_H__

#include "stdint.h"


#include "ss_data.h"

/* Server swap space configuration parameters */
struct swap_config
{
char *file_dir;
int mem_quota_type;
char *policy;
float disk_quota_MB;
union {
float MB;
float percent;
} mem_quota;
};

void free_ls_od_list(struct list_head* ls_od_list);

void memory_quota_parser(char* str, struct swap_config* swap);
void disk_quota_parser(char* str, struct swap_config* swap);

int policy_str_check(const char*str);

int need_swap_out(struct swap_config *swap, uint64_t size_MB);

struct obj_data* which_swap_out(struct swap_config* swap, struct list_head* ls_od_list);

#endif // __DSPACES_FILE_STORAGE_POLICY_H__
3 changes: 3 additions & 0 deletions include/gspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ struct ds_gspace {
/* Pending object descriptors for draining. */
struct list_head obj_desc_drain_list;

/* List of object data for swap out */
struct list_head ls_od_list;

int rank;
int size_sp;
char **server_address;
Expand Down
14 changes: 13 additions & 1 deletion include/ss_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ struct global_dimension {
struct coord sizes;
};

struct flat_od_list_info {
struct list_head entry;
int usecnt;
};

struct obj_data {
struct list_head obj_entry;

struct flat_od_list_info flat_list_entry;

obj_descriptor obj_desc;

struct global_dimension gdim;
Expand All @@ -83,6 +90,9 @@ struct obj_data {

/* Flag to mark if we should free this data object. */
unsigned int f_free : 1;

/* Reference to the flat od list in local storage; Used for advanced swap policy */
struct obj_data_ptr_flat_list_entry* ls_od_entry;
};

struct gdim_list_entry {
Expand Down Expand Up @@ -439,6 +449,7 @@ struct obj_data *ls_lookup(ss_storage *, char *);
void ls_remove(ss_storage *, struct obj_data *);
void ls_try_remove_free(ss_storage *, struct obj_data *);
struct obj_data *ls_find(ss_storage *, obj_descriptor *);
struct obj_data *ls_find_include(ss_storage *, obj_descriptor *);
struct obj_data *ls_find_od(ss_storage *, obj_descriptor *);
int ls_find_ods(ss_storage *ls, obj_descriptor *odsc, obj_descriptor ***od_tab);
struct obj_data *ls_find_no_version(ss_storage *, obj_descriptor *);
Expand All @@ -460,10 +471,11 @@ void obj_data_resize(obj_descriptor *obj_desc, uint64_t *new_dims);
int obj_desc_equals(obj_descriptor *, obj_descriptor *);
int obj_desc_equals_no_owner(const obj_descriptor *, const obj_descriptor *);

int obj_desc_equals_intersect(obj_descriptor *odsc1, obj_descriptor *odsc2);
int obj_desc_equals_intersect(const obj_descriptor *odsc1, const obj_descriptor *odsc2);

int obj_desc_by_name_intersect(const obj_descriptor *odsc1,
const obj_descriptor *odsc2);
int obj_desc_equals_include(const obj_descriptor *odsc1, const obj_descriptor *odsc2);

// void copy_global_dimension(struct global_dimension *l, int ndim, const
// uint64_t *gdim);
Expand Down
38 changes: 38 additions & 0 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,42 @@ struct name_value_pair *text_to_nv_pairs(const char *text);
void free_nv_pairs(struct name_value_pair *pairs);
char *alloc_sprintf(const char *fmt_str, ...);

/*******************************************************
Memory Info
**********************************************************/

#define MEM_PATH_LEN 256
typedef struct {
// Values from /proc/meminfo, in KiB or converted to MiB.
long long MemTotalKiB;
Comment thread
bozhang-hpc marked this conversation as resolved.
Outdated
long long MemTotalMiB;
long long MemAvailableMiB; // -1 means no data available
long long SwapTotalMiB;
long long SwapTotalKiB;
long long SwapFreeMiB;
// Calculated percentages
double MemAvailablePercent; // percent of total memory that is available
double SwapFreePercent; // percent of total swap that is free
} meminfo_t;

typedef struct procinfo {
int pid;
int pidfd;
int uid;
int badness;
int oom_score_adj;
long long VmRSSkiB;
char name[MEM_PATH_LEN];
} procinfo_t;

meminfo_t parse_meminfo();

/*******************************************************
Directory Opreations
**********************************************************/
int check_dir_exist(const char* dir_path);
int check_dir_write_permission(const char* dir_path);
void mkdir_all_owner_permission(const char* dir_path);
int remove_dir_rf(const char *dir_path);

#endif
7 changes: 4 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ set_target_properties (dspaces
PROPERTIES VERSION ${dspaces_VERSION}
SOVERSION ${dspaces_VERSION_MAJOR})

set(dspaces-server-src util.c bbox.c ss_data.c dspaces-server.c dspaces-conf.c dspaces-modules.c dspaces-logging.c toml.c)
set(dspaces-server-src util.c bbox.c ss_data.c dspaces-server.c dspaces-conf.c dspaces-modules.c
Comment thread
bozhang-hpc marked this conversation as resolved.
Outdated
dspaces-logging.c toml.c file_storage/file_hdf5.c file_storage/policy.c)

add_library(dspaces-server ${dspaces-server-src} ${dspaces-src})
if(HAVE_DRC)
target_link_libraries (dspaces-server margo m pthread ${DRC_LIBRARIES} liblz4)
target_link_libraries (dspaces-server margo m pthread ${DRC_LIBRARIES} liblz4 ${CURL_LIBRARIES} HDF5::HDF5)
Comment thread
bozhang-hpc marked this conversation as resolved.
Outdated
target_include_directories (dspaces-server BEFORE PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> ${DRC_INCLUDE_DIRS})
else()
target_link_libraries (dspaces-server margo m pthread liblz4)
target_link_libraries (dspaces-server margo m pthread liblz4 HDF5::HDF5)
Comment thread
bozhang-hpc marked this conversation as resolved.
Outdated
target_include_directories (dspaces-server BEFORE PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/bbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void bbox_divide(struct bbox *b0, struct bbox *b_tab)
/*
Test if bounding box b0 includes b1 along dimension dim.
*/
static inline int bbox_include_ondim(const struct bbox *b0,
int bbox_include_ondim(const struct bbox *b0,
const struct bbox *b1, int dim)
{
if((b0->lb.c[dim] <= b1->lb.c[dim]) && (b0->ub.c[dim] >= b1->ub.c[dim]))
Expand Down
7 changes: 6 additions & 1 deletion src/dspaces-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,12 @@ static void fill_odsc(dspaces_client_t client, const char *var_name,
odsc->version = ver;
memset(odsc->owner, 0, sizeof(odsc->owner));
odsc->st = st;
odsc->size = elem_size;
if(elem_size < 0) {
Comment thread
bozhang-hpc marked this conversation as resolved.
odsc->type = elem_size;
odsc->size = type_to_size(elem_size);
} else {
odsc->size = elem_size;
}
odsc->bb.num_dims = ndim;

memset(odsc->bb.lb.c, 0, sizeof(uint64_t) * BBOX_MAX_NDIM);
Expand Down
62 changes: 61 additions & 1 deletion src/dspaces-conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,63 @@ static void parse_modules_table(toml_table_t *modules, struct ds_conf *conf)
#endif
}

static void parse_swap_table(toml_table_t *swap, struct ds_conf *conf)
{
toml_datum_t dat;

dat = toml_string_in(swap, "directory");
Comment thread
bozhang-hpc marked this conversation as resolved.
if(dat.ok) {
conf->swap.file_dir = strdup(dat.u.s);
free(dat.u.s);
} else{
conf->swap.file_dir = strdup("./dspaces_swap/");
}

dat = toml_string_in(swap, "memory quota");
if(dat.ok) {
memory_quota_parser(dat.u.s, &conf->swap);
free(dat.u.s);
} else{
conf->swap.mem_quota_type = 1;
conf->swap.mem_quota.percent = 1.0;
}

dat = toml_string_in(swap, "policy");
if(dat.ok) {
if(policy_str_check(dat.u.s)) {
conf->swap.policy = strdup(dat.u.s);
} else {
conf->swap.policy = strdup("Default");
fprintf(stderr, "WARNING: Swap Policy: %s is not supported. "
"Use FIFO policy as default.\n", dat.u.s);
}
free(dat.u.s);
} else {
conf->swap.policy = strdup("Default");
}

dat = toml_string_in(swap, "disk quota");
if(dat.ok) {
disk_quota_parser(dat.u.s, &conf->swap);
free(dat.u.s);
} else {
conf->swap.disk_quota_MB = -1.0;
}
}

static inline void set_default_swap(struct ds_conf *conf)
{
conf->swap.file_dir = strdup("./dspaces_swap/");
conf->swap.mem_quota_type = 1;
conf->swap.mem_quota.percent = 1.0;
conf->swap.policy = strdup("Default");
conf->swap.disk_quota_MB = -1.0;
}

int parse_conf_toml(const char *fname, struct ds_conf *conf)
{
FILE *fin;
toml_table_t *toml_conf, *server, *remotes, *storage, *modules;
toml_table_t *toml_conf, *server, *remotes, *storage, *modules, *swap;
char errbuf[200];
char *ip;
int port;
Expand Down Expand Up @@ -366,6 +419,13 @@ int parse_conf_toml(const char *fname, struct ds_conf *conf)
parse_modules_table(modules, conf);
}

swap = toml_table_in(toml_conf, "swap space");
if(swap) {
parse_swap_table(swap, conf);
} else {
set_default_swap(conf);
Comment thread
bozhang-hpc marked this conversation as resolved.
Outdated
}

toml_free(toml_conf);

return (0);
Expand Down
Loading