Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5,832 changes: 2,916 additions & 2,916 deletions BENCHMARKS/benchmark.NUMA.out.txt

Large diffs are not rendered by default.

8,544 changes: 0 additions & 8,544 deletions BENCHMARKS/benchmark.out

This file was deleted.

36 changes: 36 additions & 0 deletions UNIT_TESTS/c_plugin_test/forkrun_plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// forkrun_plugin.h
#ifndef FORKRUN_PLUGIN_H
#define FORKRUN_PLUGIN_H

#include <stdint.h>

// Opt-in flag: define this in exactly ONE of your C files to receive the context
// int forkrun_use_ctx = 1;

struct forkrun_ctx {
uint64_t batch_index; // global batch sequence number
uint64_t batch_offset; // byte offset in input stream
uint64_t batch_byte_length; // length of current batch in bytes
uint32_t version; // struct version, currently 1
uint32_t worker_id; // internal worker ID
uint32_t node_id; // NUMA node ID
uint32_t num_kills; // retry count for this batch (if failure recovery active)
uint32_t numa_major; // NUMA major sequence (0 if not NUMA)
uint32_t numa_minor; // NUMA minor sequence (0 if not NUMA)
int32_t fd_in; // input memfd file descriptor
char delimiter; // batch delimiter character
uint8_t cfg_state[3]; // global configuration state
};


/* === FUNCTION DEFINITION TEMPLATES ===
*
* 1. Standard Fast Path (2-arg):
* int my_func(int argc, char **argv) { ... }
*
* 2. Context-Aware Path (3-arg):
* int forkrun_use_ctx = 1;
* int my_func(int argc, char **argv, const struct forkrun_ctx *ctx) { ... }
*/

Check warning on line 34 in UNIT_TESTS/c_plugin_test/forkrun_plugin.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfpHIOjC2UiMnfDk&open=AZ5hrfpHIOjC2UiMnfDk&pullRequest=299

#endif // FORKRUN_PLUGIN_H
9 changes: 9 additions & 0 deletions UNIT_TESTS/c_plugin_test/plugin_ctx_math.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>
#include "forkrun_plugin.h"
int forkrun_use_ctx = 1;

int plugin_ctx_math(int argc, char **argv, void *ctx_ptr) {

Check warning on line 5 in UNIT_TESTS/c_plugin_test/plugin_ctx_math.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused parameter "argv", make it unnamed, or declare it "[[maybe_unused]]".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfpVIOjC2UiMnfDn&open=AZ5hrfpVIOjC2UiMnfDn&pullRequest=299

Check warning on line 5 in UNIT_TESTS/c_plugin_test/plugin_ctx_math.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused parameter "argc", make it unnamed, or declare it "[[maybe_unused]]".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfpVIOjC2UiMnfDm&open=AZ5hrfpVIOjC2UiMnfDm&pullRequest=299
struct forkrun_ctx *ctx = (struct forkrun_ctx *)ctx_ptr;

Check warning on line 6 in UNIT_TESTS/c_plugin_test/plugin_ctx_math.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "ctx" is "struct forkrun_ctx *".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfpVIOjC2UiMnfDo&open=AZ5hrfpVIOjC2UiMnfDo&pullRequest=299
printf("%lu\n", ctx->batch_byte_length);
return 0;
}
Binary file added UNIT_TESTS/c_plugin_test/plugin_ctx_math.so
Binary file not shown.
5 changes: 5 additions & 0 deletions UNIT_TESTS/c_plugin_test/plugin_echo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int plugin_echo(int argc, char **argv) {
for (int i = 0; i < argc; i++) printf("%s\n", argv[i]);
return 0;
}
Binary file added UNIT_TESTS/c_plugin_test/plugin_echo.so
Binary file not shown.
16 changes: 16 additions & 0 deletions UNIT_TESTS/c_plugin_test/plugin_poison.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
#include "forkrun_plugin.h"
int forkrun_use_ctx = 1;

int plugin_poison(int argc, char **argv, void *ctx_ptr) {
struct forkrun_ctx *ctx = (struct forkrun_ctx *)ctx_ptr;

Check warning on line 6 in UNIT_TESTS/c_plugin_test/plugin_poison.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "ctx" is "struct forkrun_ctx *".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfo4IOjC2UiMnfDh&open=AZ5hrfo4IOjC2UiMnfDh&pullRequest=299

// Simulate a segfault/crash on batch index 7, ONLY on the first attempt
if (ctx->batch_index == 7 && ctx->num_kills == 0) {
return 1; // Trigger failure!
}

// On retry (num_kills > 0) or normal batches, process normally
for (int i = 0; i < argc; i++) printf("%s\n", argv[i]);
return 0;
}
Binary file added UNIT_TESTS/c_plugin_test/plugin_poison.so
Binary file not shown.
9 changes: 9 additions & 0 deletions UNIT_TESTS/c_plugin_test/test_basic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>
#include <string.h>

int test_basic(int argc, char **argv) {
size_t total = 0;
for (int i = 0; i < argc; i++) total += strlen(argv[i]);
printf("BASIC: batch_size=%d total_chars=%zu\n", argc, total);
return 0;
}
Binary file added UNIT_TESTS/c_plugin_test/test_basic.so
Binary file not shown.
13 changes: 13 additions & 0 deletions UNIT_TESTS/c_plugin_test/test_ctx_header.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
#include "forkrun_plugin.h"

int forkrun_use_ctx = 1;

int test_ctx_header(int argc, char **argv, const struct forkrun_ctx *ctx) {

Check warning on line 6 in UNIT_TESTS/c_plugin_test/test_ctx_header.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused parameter "argv", make it unnamed, or declare it "[[maybe_unused]]".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrflQIOjC2UiMnfDg&open=AZ5hrflQIOjC2UiMnfDg&pullRequest=299

Check warning on line 6 in UNIT_TESTS/c_plugin_test/test_ctx_header.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused parameter "argc", make it unnamed, or declare it "[[maybe_unused]]".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrflQIOjC2UiMnfDf&open=AZ5hrflQIOjC2UiMnfDf&pullRequest=299
if (ctx && ctx->version >= 1) {
printf("CTX_HEADER: batch=%lu worker=%u node=%u retries=%u bytes=%lu\n",
ctx->batch_index, ctx->worker_id, ctx->node_id,
ctx->num_kills, ctx->batch_byte_length);
}
return 0;
}
Binary file added UNIT_TESTS/c_plugin_test/test_ctx_header.so
Binary file not shown.
28 changes: 28 additions & 0 deletions UNIT_TESTS/c_plugin_test/test_ctx_naked.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdint.h>

int forkrun_use_ctx = 1;

struct forkrun_ctx {
uint64_t batch_index;
uint64_t batch_offset;
uint64_t batch_byte_length;
uint32_t version;
uint32_t worker_id;
uint32_t node_id;
uint32_t num_kills;
uint32_t numa_major;
uint32_t numa_minor;
int32_t fd_in;
char delimiter;
char _pad[3];
};

int test_ctx_naked(int argc, char **argv, const struct forkrun_ctx *ctx) {

Check warning on line 21 in UNIT_TESTS/c_plugin_test/test_ctx_naked.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused parameter "argc", make it unnamed, or declare it "[[maybe_unused]]".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfo_IOjC2UiMnfDi&open=AZ5hrfo_IOjC2UiMnfDi&pullRequest=299

Check warning on line 21 in UNIT_TESTS/c_plugin_test/test_ctx_naked.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused parameter "argv", make it unnamed, or declare it "[[maybe_unused]]".

See more on https://sonarcloud.io/project/issues?id=jkool702_forkrun&issues=AZ5hrfo_IOjC2UiMnfDj&open=AZ5hrfo_IOjC2UiMnfDj&pullRequest=299
if (ctx && ctx->version >= 1) {
printf("CTX_NAKED: batch=%lu worker=%u node=%u retries=%u bytes=%lu\n",
ctx->batch_index, ctx->worker_id, ctx->node_id, ctx->num_kills,
ctx->batch_byte_length);
}
return 0;
}
Binary file added UNIT_TESTS/c_plugin_test/test_ctx_naked.so
Binary file not shown.
Loading
Loading