hashers now use thread local arena

Instead of writing directly to file_hashes.txt, hash_workers now are
using a local arena, writing everything once at the end

using #pragma once to ensure that a given header file is included only
once in a single compilation unit
This commit is contained in:
2026-03-08 10:46:05 +01:00
parent ee02b83094
commit dd0797df79
7 changed files with 177 additions and 73 deletions

39
base.h
View File

@@ -1,11 +1,40 @@
#ifndef BASE_H
#define BASE_H
#pragma once
#include <assert.h>
#include <immintrin.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if defined(_WIN32) || defined(_WIN64)
#define PLATFORM_WINDOWS 1
#include <aclapi.h>
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <windows.h>
#define strdup _strdup
#else
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <pwd.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#define XXH_VECTOR \
XXH_AVX2 // not recommanded to compile with gcc see xxhash.h line 4082
// Must compile with /arch:AVX2 in clang-cl or -mavx2 in clang/gcc
#define XXH_INLINE_ALL
#include "xxhash.c"
#include "xxhash.h"
/* ------------------------------------------------------------
Base types
@@ -25,12 +54,14 @@ typedef int b32;
typedef float f32;
typedef double f64;
/* ------------------------------------------------------------
Size helpers
------------------------------------------------------------ */
#define KiB(x) ((u64)(x) * 1024ULL)
#define MiB(x) (KiB(x) * 1024ULL)
#define GiB(x) (MiB(x) * 1024ULL)
/* ------------------------------------------------------------
Min / Max helpers
@@ -48,7 +79,7 @@ typedef double f64;
Alignment helpers
------------------------------------------------------------ */
#define ALIGN_UP_POW2(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
#define ALIGN_UP_POW2(x, a) ((a) ? (((x) + ((a) - 1)) & ~((a) - 1)) : (x))
/* ------------------------------------------------------------
Assert
@@ -58,4 +89,4 @@ typedef double f64;
#define ASSERT(x) assert(x)
#endif
#endif // Base.h
#define NDEBUG // Comment to enable asserts