Reworking IO Ring pipeline to fully support multiple infilght files
Reworking the filequeue, the buffer chaining logic and the error handling. Renaming functions. Fix bug in arena.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ temp_code.c
|
||||
/.cache/clangd/index
|
||||
/file_hasher
|
||||
/io_uring_test
|
||||
/file_hasher
|
||||
|
||||
6
arena.c
6
arena.c
@@ -437,12 +437,14 @@ void *arena_push(mem_arena **arena_ptr, u64 size, bool zero) { // mk push
|
||||
Commit memory if needed
|
||||
------------------------------------------------------------ */
|
||||
|
||||
if (local_post > selected->commit_pos) {
|
||||
u64 new_commit = ALIGN_UP_POW2(local_post, arena_pagesize());
|
||||
if (local_post > selected->commit_pos -
|
||||
ALIGN_UP_POW2(sizeof(mem_arena), selected->align)) {
|
||||
u64 new_commit = ALIGN_UP_POW2(local_post + ALIGN_UP_POW2(sizeof(mem_arena), selected->align), arena_pagesize());
|
||||
new_commit = MIN(new_commit, selected->reserve_size);
|
||||
|
||||
if (!plat_mem_commit((u8 *)selected + selected->commit_pos,
|
||||
new_commit - selected->commit_pos)) {
|
||||
printf("ERROR: Could not commit memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
1
base.h
1
base.h
@@ -46,6 +46,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
Base types
|
||||
|
||||
@@ -50,7 +50,7 @@ Fixing user prompt parsing
|
||||
Reorganising the code
|
||||
Improving the scan function
|
||||
|
||||
5.0: Implementing the IO Ring for windows and ui_uring for linux instead of buffered hashing, huge performance gains. The IO Ring is event driven, thread local, uses DMA and direct disk I/O, bypassing the OS cash completely, registred buffers, it supports bashing multiple submissions and can handle multiple files at the same time.
|
||||
5.0: Implementing the IO Ring for windows and ui_uring for linux instead of buffered hashing, huge performance gains. The IO Ring is event driven, thread local, uses DMA and direct disk I/O, bypassing the OS cache completely, registred buffers, it supports bashing multiple submissions and can handle multiple files at the same time.
|
||||
Hashing small files using XXH3_128bits() instead of the streaming pipeline(XXH3_128bits_reset(), XXH3_128bits_update(), XXH3_128bits_digest()), this reduses the overhead of creating a state and digest, coupled with the IO Ring it improves the hashing of small files whose size is inferior to the size of IO Ring buffers
|
||||
fixing the xxh_x86dispatch warnings
|
||||
Updating the progress printing function
|
||||
|
||||
BIN
file_hasher
BIN
file_hasher
Binary file not shown.
@@ -77,14 +77,19 @@ int main(int argc, char **argv) {
|
||||
// Detect hardware
|
||||
// -------------------------------
|
||||
// --- Windows: detect PHYSICAL cores (not logical threads) ---
|
||||
size_t hw_threads = platform_physical_cores();
|
||||
uint32_t cpu_cores = platform_physical_cores();
|
||||
|
||||
// Logical threads = CPU cores * 2
|
||||
size_t num_threads = hw_threads * 2;
|
||||
uint32_t cpu_threads = cpu_cores * 2;
|
||||
|
||||
printf("Starting thread pool: %zu threads (CPU cores: %zu)\n", num_threads,
|
||||
hw_threads);
|
||||
printf(" Selected instruction set: %s\n", get_xxhash_instruction_set());
|
||||
uint32_t num_scan_threads = cpu_threads;
|
||||
uint32_t num_hash_threads = cpu_threads;
|
||||
// uint32_t num_hash_threads = 1;
|
||||
|
||||
printf("%d cores %d threads CPU detected with %s instruction set\n"
|
||||
"Starting thread pool: %d scanning and %d hashing threads\n",
|
||||
cpu_cores, cpu_threads, get_xxhash_instruction_set(), num_scan_threads,
|
||||
num_hash_threads);
|
||||
|
||||
// Align IO Ring block size to the system page size
|
||||
g_ioring_buffer_size = ALIGN_UP_POW2(g_ioring_buffer_size, g_pagesize);
|
||||
@@ -119,9 +124,6 @@ int main(int argc, char **argv) {
|
||||
// }
|
||||
|
||||
// Starting hash threads
|
||||
size_t num_hash_threads = num_threads;
|
||||
// size_t num_hash_threads = 1;
|
||||
|
||||
WorkerContext workers[num_hash_threads];
|
||||
Thread *hash_threads =
|
||||
arena_push(&gp_arena, sizeof(Thread) * num_hash_threads, true);
|
||||
@@ -130,7 +132,7 @@ int main(int argc, char **argv) {
|
||||
workers[i].arena = arena_create(¶ms);
|
||||
workers[i].file_queue = &file_queue;
|
||||
|
||||
if (thread_create(&hash_threads[i], (ThreadFunc)hash_worker_io_ring,
|
||||
if (thread_create(&hash_threads[i], (ThreadFunc)hash_worker_ioring,
|
||||
&workers[i]) != 0) {
|
||||
fprintf(stderr, "Failed to create hash thread %zu\n", i);
|
||||
exit(1);
|
||||
@@ -178,8 +180,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Starting scan threads
|
||||
size_t num_scan_threads = num_threads;
|
||||
|
||||
ScannerContext scanners[num_scan_threads];
|
||||
Thread *scan_threads =
|
||||
arena_push(&gp_arena, sizeof(Thread) * num_scan_threads, true);
|
||||
|
||||
682
platform.c
682
platform.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user