Skip to content

Instantly share code, notes, and snippets.

View foamdino's full-sized avatar
🏠
Working from home

Kev Jackson foamdino

🏠
Working from home
View GitHub Profile
@foamdino
foamdino / q.c
Created November 25, 2025 06:23
q
#include <assert.h>
#include <pthread.h>
#define Q_SZ 4096
typedef enum q_entry_type q_entry_type_e;
typedef struct q_entry q_entry_t;
typedef struct q q_t;
enum q_entry_type
Message from lib: hot test msg
Message from lib: hot test msg
library changed, reloading...
Lib loaded (version: 1.0.0)
Message from lib: hotter test msg
Message from lib: hotter test msg
Message from lib: hotter test msg
Message from lib: hotter test msg
@foamdino
foamdino / dependencies.md
Last active May 30, 2025 12:19
framework dependency counts
Framework / Tool Command Total Dependencies (Approximate) Notes
Node.js (Express) npm install express ~50–80 Express is minimal, but it depends on several packages like accepts, body-parser, and cookie. These, in turn, have their own dependencies.
Java (Spring Boot Starter Web) mvn package ~20–30 Includes transitive dependencies such as spring-web, spring-boot-starter-tomcat, and spring-boot-starter-logging.
Rust (Actix Web) cargo build ~30–50 Depends on crates like actix-rt, tokio, and futures. Count varies by enabled features.
Go (Chi) go get github.com/go-chi/chi ~5–10
@foamdino
foamdino / bl_pal_linux_activate_irq_mapping.c
Created April 24, 2025 10:53
Active irq-to-core mapping
/**
* Given a single populated irq_info, activate the mapping from irq to cpus
*
* @param teb Pointer to our teb
* @param irq IRQ line number to map
* @param coremap Pointer to coremap to map IRQ to
*
* @return BL_OK on success, BL_ERR otherwise.
*/
__BL_STATIC int
@foamdino
foamdino / xsk_instance_start_core.c
Last active April 24, 2025 10:43
Start XSK instance core
/* If we have an IRQ and IRQ Core ID, we should ask the PAL to map the IRQ to
* the provided Core ID. */
if (xi->irq < UINT32_MAX && xi->irq_core_id < UINT32_MAX)
{
/* Initially set all cores off */
bl_pal_clear_coremap(&coremap);
/* Then enable single selected core */
@foamdino
foamdino / xsk_start_core.c
Created April 24, 2025 08:00
XSK startup core
for (channel_num = 0; channel_num < drone->wss->allocated_if->channels;
channel_num++)
{
/* Ensure our IRQ values are reset every iteration. */
irq_num = UINT32_MAX;
/* Ask Interface Manager for the IRQ mapping for this channel. */
res = drone_ifmgr_find_channel_irq(
@foamdino
foamdino / split_affinity.c
Created April 24, 2025 07:45
split affinity
/**
* Assign the packet parsing threads to the top half of the CPUs supplied in the
* config. The bottom half of the CPUs will be used for the channel threads.
*
* @param teb Pointer to our TEB.
*
* @retval BL_OK.
*/
__BL_STATIC int
drone_sysmgr_aff_core_split(bl_teb_t *teb)
@foamdino
foamdino / check_irq_affinity.c
Created April 24, 2025 07:38
check IRQ affinity
/**
* Check the current irq affinity and core map to apply
*
* @param teb Pointer to our teb
* @param irq IRQ line number to check
* @param coremap Pointer to a coremap to apply
* @param is_equal Pointer to variabl that will receive coremap comparison result
*
* @return BL_OK | BL_ERR
*/
@foamdino
foamdino / coremap.c
Created April 24, 2025 07:34
coremap
/** CPU core bitmap. */
struct bl_pal_coremap
{
/* The coremap bitmap itself is an array of 64-bit integers of sufficient size
* to store up to BL_PAL_MAX_CORES of cores (be that physical or logical cores).
*/
__BL_BITMAP_DECLARE(bits, BL_PAL_MAX_CORES);
};
@foamdino
foamdino / read_procfs.c
Created April 24, 2025 05:03
Read /proc/interrupts
/**
* Read /proc/interrupts and collect resulting current irq information into a list
* filtered by a pattern adapted from irqbalance
*
* @param teb Pointer to our teb
* @param pattern Pointer to const pattern to check in /proc/interrupts for
* @param irq_head Pointer to bl_pal_irq_info linked_list (initially empty)
*
* @retval BL_OK on success, BL_ERR otherwise
*/