hyperoptimized file reading

This commit is contained in:
2026-08-14 18:00:02 +02:00
parent 901d5b53d9
commit 81cfc2ce0d
8 changed files with 172 additions and 150 deletions

View File

@@ -23,13 +23,13 @@ static constexpr char netif[] = "enp4s0f0";
static constexpr char cpu_pcidev[] = "0000:00:18.3";
static constexpr char gpu_pcidev[] = "0000:0a:00.0";
struct control_t {
static struct {
pthread_mutex_t sensors_mtx;
pthread_cond_t sensors_ready;
atomic_bool running;
} control;
struct sensors_t { // NOLINT yes it is
struct sensors_t { // NOLINT stfu
time_t ts;
struct memory_t ram;
struct disk_t home;
@@ -56,6 +56,7 @@ static void *sensors_thread(void *arg) {
cpu_detect(&sensors->cpu, cpu_pcidev);
gpu_detect(&sensors->gpu, gpu_pcidev);
sys_detect(&sensors->sys, "nct6775.656");
sys_netdev_detect(&sensors->net);
aio_detect(&sensors->aio);
/* main sensor loop */
@@ -90,7 +91,7 @@ static void *sensors_thread(void *arg) {
static void *display_thread(void *arg) {
applog(LOG_START, "display thread started");
struct sensors_t *sensors = arg;
const struct sensors_t *sensors = arg;
/* lcd setup */
struct lcd_t lcd = {
@@ -191,7 +192,7 @@ int main() {
}
/* malloc memory for the struct */
struct sensors_t *sensors = malloc(sizeof(*sensors)); // no actual point in mallocing and it is ever so sligtly slower to access heap vs stack, but its cool
struct sensors_t *sensors = malloc(sizeof(struct sensors_t)); // no actual point in mallocing but its cool
if (sensors == nullptr) {
applog(LOG_ERR, "can't allocate mem for the sensor struct. You don't got %lu bytes bro?", sizeof(*sensors));
free(sensors);