Skip to content

Instantly share code, notes, and snippets.

View Rexicon226's full-sized avatar
💭
optimizing

David Rubin Rexicon226

💭
optimizing
View GitHub Profile
@Rexicon226
Rexicon226 / benchmark.zig
Created November 28, 2025 04:54
RVV indexOfSentinel benchmark
const std = @import("std");
const iterations_per_byte = 1000;
const warmup_iterations = 10;
pub fn main() !void {
const allocator = std.heap.smp_allocator;
// Pin the process to a single core (1)
const cpu0001: std.os.linux.cpu_set_t = [1]usize{0b0001} ++ ([_]usize{0} ** (16 - 1));
const std = @import("std");
const el: u256 = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed;
const L = 1 * el;
fn heea(v: u256) struct { u128, u128 } {
std.debug.assert(len(L) == 253);
std.debug.assert(v < L);
std.debug.assert(v > 0);
From e9b300e1579d456fd307659f86d8ac0373a25fea Mon Sep 17 00:00:00 2001
From: David Rubin <[email protected]>
Date: Wed, 5 Nov 2025 18:26:33 -0800
Subject: [PATCH] explicit `PROT_WRITE` in `zero_bss` is redundant
The `PAGE_WRITE` check already protects the `memset`.
The Zig compiler uses `memsz` to reserve virtual address
space that can be used by future updates, including
in non-writable sections such as `.text`.
const std = @import("std");
const Edwards25519 = std.crypto.ecc.Edwards25519;
export fn slow(s: *const [32]u8) bool {
Edwards25519.scalar.rejectNonCanonical(s.*) catch return false;
return true;
}
export fn fast(s: *const [32]u8) bool {
// If none of the top 4 bits are set, then the scalar fits into S \in [0, 2^252),
@Rexicon226
Rexicon226 / benchmark.zig
Last active August 15, 2025 07:03
countScalar benchmark
const std = @import("std");
const testing = std.testing;
const iterations_per_byte = 1000;
const warmup_iterations = 10;
pub fn main() !void {
const allocator = std.heap.smp_allocator;
// Pin the process to a single core (1)
diff --git a/lib/libtsan/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc b/lib/libtsan/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
index 16b2a10d8b..6370e63ab6 100644
--- a/lib/libtsan/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
+++ b/lib/libtsan/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
@@ -641,22 +641,6 @@ static void ioctl_table_fill() {
_(SPKRSETVOL, READ, sizeof(unsigned int));
#if defined(__x86_64__)
/* Entries from file: dev/nvmm/nvmm_ioctl.h */
- _(NVMM_IOC_CAPABILITY, WRITE, struct_nvmm_ioc_capability_sz);
- _(NVMM_IOC_MACHINE_CREATE, READWRITE, struct_nvmm_ioc_machine_create_sz);
@Rexicon226
Rexicon226 / bench.zig
Created August 3, 2025 01:13
RVV `indexOfSentinel` benchmark
const std = @import("std");
const iterations_per_byte = 1000;
const warmup_iterations = 10;
pub fn main() !void {
const allocator = std.heap.smp_allocator;
// Pin the process to a single core (1)
const cpu0001: std.os.linux.cpu_set_t = [1]usize{0b0001} ++ ([_]usize{0} ** (16 - 1));
@Rexicon226
Rexicon226 / benchmark.zig
Last active November 28, 2025 01:48
CRC-32C benchmark
const std = @import("std");
const Wrapper = @import("crc32c.zig").Wrapper;
const iterations_per_byte = 1000;
const warmup_iterations = 10;
pub fn main() !void {
const allocator = std.heap.smp_allocator;
// Pin the process to a single core (1)
@Rexicon226
Rexicon226 / pippinger.zig
Created May 31, 2025 02:02
Pippinger MSM with no allocation
inline fn radixSizeHint(w: u64) u64 {
return switch (w) {
4...7 => (@as(u64, 256) + w - 1) / w,
8 => (@as(u64, 256) + w - 1) / w + 1,
else => unreachable,
};
}
inline fn mulByPow2(p: Ed25519, k: u32) Ed25519 {
var s = p;
import Lean
open Lean
open IO
inductive SExpr
| atom : String → SExpr
| list : List SExpr → SExpr
deriving Repr, Nonempty