Add asl store GC tool
This commit is contained in:
parent
43428cce9c
commit
94566056bd
|
|
@ -33,3 +33,19 @@ target_link_libraries(amduatd
|
||||||
PRIVATE amduat_tgk amduat_pel amduat_format amduat_asl_store_fs amduat_asl
|
PRIVATE amduat_tgk amduat_pel amduat_format amduat_asl_store_fs amduat_asl
|
||||||
amduat_enc amduat_hash_asl1 amduat_util amduat_federation
|
amduat_enc amduat_hash_asl1 amduat_util amduat_federation
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_executable(amduat_pel_gc
|
||||||
|
src/amduat_pel_gc.c
|
||||||
|
src/asl_gc_fs.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(amduat_pel_gc PROPERTIES OUTPUT_NAME "amduat-pel")
|
||||||
|
|
||||||
|
target_include_directories(amduat_pel_gc
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/amduat/include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(amduat_pel_gc
|
||||||
|
PRIVATE amduat_asl_store_fs amduat_asl_record amduat_asl amduat_enc
|
||||||
|
amduat_hash_asl1 amduat_pel amduat_util
|
||||||
|
)
|
||||||
|
|
|
||||||
75
src/amduat_pel_gc.c
Normal file
75
src/amduat_pel_gc.c
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
#include "asl_gc_fs.h"
|
||||||
|
|
||||||
|
#include "amduat/util/log.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static void amduat_pel_gc_usage(const char *argv0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage: %s gc --root <root> [--keep-materializations] [--delete] [--dry-run]\n",
|
||||||
|
argv0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
const char *root = NULL;
|
||||||
|
bool keep_materializations = false;
|
||||||
|
bool delete_artifacts = false;
|
||||||
|
bool dry_run = true;
|
||||||
|
amduat_asl_gc_fs_options_t opts;
|
||||||
|
amduat_asl_gc_fs_stats_t stats;
|
||||||
|
|
||||||
|
if (argc < 2 || strcmp(argv[1], "gc") != 0) {
|
||||||
|
amduat_pel_gc_usage(argv[0]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 2; i < argc; ++i) {
|
||||||
|
if (strcmp(argv[i], "--root") == 0) {
|
||||||
|
if (i + 1 >= argc) {
|
||||||
|
amduat_pel_gc_usage(argv[0]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
root = argv[++i];
|
||||||
|
} else if (strcmp(argv[i], "--keep-materializations") == 0) {
|
||||||
|
keep_materializations = true;
|
||||||
|
} else if (strcmp(argv[i], "--delete") == 0) {
|
||||||
|
delete_artifacts = true;
|
||||||
|
dry_run = false;
|
||||||
|
} else if (strcmp(argv[i], "--dry-run") == 0) {
|
||||||
|
dry_run = true;
|
||||||
|
delete_artifacts = false;
|
||||||
|
} else if (strcmp(argv[i], "--help") == 0 ||
|
||||||
|
strcmp(argv[i], "-h") == 0) {
|
||||||
|
amduat_pel_gc_usage(argv[0]);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
amduat_pel_gc_usage(argv[0]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root == NULL) {
|
||||||
|
amduat_pel_gc_usage(argv[0]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
opts.keep_materializations = keep_materializations;
|
||||||
|
opts.delete_artifacts = delete_artifacts;
|
||||||
|
opts.dry_run = dry_run;
|
||||||
|
if (!amduat_asl_gc_fs_run(root, &opts, &stats)) {
|
||||||
|
amduat_log(AMDUAT_LOG_ERROR, "gc failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("pointer_roots=%zu\n", stats.pointer_roots);
|
||||||
|
printf("materialization_roots=%zu\n", stats.materialization_roots);
|
||||||
|
printf("marked_artifacts=%zu\n", stats.marked_artifacts);
|
||||||
|
printf("candidates=%zu\n", stats.candidates);
|
||||||
|
printf("candidate_bytes=%llu\n",
|
||||||
|
(unsigned long long)stats.candidate_bytes);
|
||||||
|
printf("mode=%s\n", delete_artifacts ? "delete" : "dry-run");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1399
src/asl_gc_fs.c
Normal file
1399
src/asl_gc_fs.c
Normal file
File diff suppressed because it is too large
Load diff
34
src/asl_gc_fs.h
Normal file
34
src/asl_gc_fs.h
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef AMDUAT_API_ASL_GC_FS_H
|
||||||
|
#define AMDUAT_API_ASL_GC_FS_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool keep_materializations;
|
||||||
|
bool delete_artifacts;
|
||||||
|
bool dry_run;
|
||||||
|
} amduat_asl_gc_fs_options_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t pointer_roots;
|
||||||
|
size_t materialization_roots;
|
||||||
|
size_t marked_artifacts;
|
||||||
|
size_t candidates;
|
||||||
|
uint64_t candidate_bytes;
|
||||||
|
} amduat_asl_gc_fs_stats_t;
|
||||||
|
|
||||||
|
bool amduat_asl_gc_fs_run(const char *root_path,
|
||||||
|
const amduat_asl_gc_fs_options_t *opts,
|
||||||
|
amduat_asl_gc_fs_stats_t *out_stats);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* AMDUAT_API_ASL_GC_FS_H */
|
||||||
2
vendor/amduat
vendored
2
vendor/amduat
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit 85c23e49eb88768d076c26bd587ca842ce8b39ab
|
Subproject commit 3e526975ce2aac60b2dd09252a5edff86d4e8abe
|
||||||
Loading…
Reference in a new issue