Skip to content

Instantly share code, notes, and snippets.

View nmoinvaz's full-sized avatar

Nathan Moinvaziri nmoinvaz

  • Phoenix, United States
View GitHub Profile
// Polynomial for CRC32 (IEEE 802.3): 0x1EDC6F41
// Intel whitepaper uses reflected polynomial: 0x82F63B78
// We'll use 0x1EDC6F41 for compatibility with zlib-ng
Z_INTERNAL Z_TARGET_CRC uint32_t crc32_armv8_pmull(uint32_t crc, const uint8_t *buf, size_t len) {
uint32_t c = ~crc;
// Constants for PMULL folding (from Intel whitepaper)
const uint64x2_t k1 = {0x0154442bd4ULL, 0x00000001ULL};
@nmoinvaz
nmoinvaz / crc32_armv8_pmull_single_lane.c
Created December 9, 2025 20:34
crc32_armv8_pmull_single_lane
Z_INTERNAL Z_TARGET_PMULL uint32_t crc32_armv8_pmull_single_lane(uint32_t crc, const uint8_t *buf, size_t len) {
uint32_t crc0 = ~crc;
/* 1. Alignment (Scalar) */
for (; len && ((uintptr_t)buf & 7); --len) {
crc0 = __crc32b(crc0, *buf++);
}
/* 2. Alignment to 16-byte boundary (8-byte scalar CRC) */
if (((uintptr_t)buf & 8) && len >= 8) {
@nmoinvaz
nmoinvaz / arm_cpu_info.c
Created December 8, 2025 01:55
ARM fast pmull detection
/* arm_cpu_id.c -- ARM CPU identification for microarchitecture detection
* Copyright (C) 2025 Nathan Moinvaziri
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zbuild.h"
#include "arm_cpu_id.h"
#if defined(__linux__)
# include <stdio.h>
@nmoinvaz
nmoinvaz / dougallj-benchmarks.md
Last active December 1, 2025 22:20
Benchmarks for zlib-ng issue #1998
@nmoinvaz
nmoinvaz / insert_string_distributions.md
Last active August 23, 2025 00:11
insert_string distributions

silesia.tar level 6

Total calls: 16533400
Count	Frequency	Percentage
3	4314962		26.10%
4	2598912		15.72%
5	2051025		12.41%
6	1613384		9.76%
7	1142336		6.91%
8	571554		3.46%
[==========] Running 5 tests from 2 test suites.
[----------] Global test environment set-up.
2025-03-13T14:13:33.462-07 [19301] Log Level: DEBUG
2025-03-13T14:13:33.462-07 [19301] Log Filename: /home/buildbox/.local/share/gtest_host/gtest_host.log
2025-03-13T14:13:33.462-07 [19301] Command Line: /home/buildbox/actions-runner/_work/client/client/build/Coverage/gtest_host --verbose
2025-03-13T14:13:33.462-07 [19301] INFO - Desktop environment: Gnome3
2025-03-13T14:13:33.462-07 [19301] INFO - System: x86_64 Linux 6.8.0-51-generic x86_64
2025-03-13T14:13:33.462-07 [19301] INFO - Elevated: false
2025-03-13T14:13:33.462-07 [19301] INFO - Process Id: 19301
2025-03-13T14:13:33.462-07 [19301] INFO - Current Directory: /home/buildbox/actions-runner/_work/client/client/test/
Repeating all tests (iteration 1) . . .
Note: Google Test filter = AnalyticsWebTest.*:AppTrackTest.*
[==========] Running 5 tests from 2 test suites.
[----------] Global test environment set-up.
2025-03-13T14:04:52.621-07 [18056] Log Level: DEBUG
2025-03-13T14:04:52.621-07 [18056] Log Filename: /home/buildbox/.local/share/gtest_host/gtest_host.log
2025-03-13T14:04:52.621-07 [18056] Command Line: /home/buildbox/actions-runner/_work/client/client/build/Coverage/gtest_host --verbose
2025-03-13T14:04:52.621-07 [18056] INFO - Desktop environment: Gnome3
2025-03-13T14:04:52.621-07 [18056] INFO - System: x86_64 Linux 6.8.0-51-generic x86_64
@nmoinvaz
nmoinvaz / useEnhancedQuery.js
Last active January 3, 2025 21:04
useQuery with Enhanced Error Handling
import {useCallback, useEffect, useMemo, useState} from "react";
import {useQuery} from "react-query";
// Provide ability to reset the error
const useEnhancedQuery = (queryKey, queryFn, options) => {
const {error: queryError, refetch: queryRefetch, status, ...queryResult} =
useQuery(queryKey, queryFn, options);
const [error, setError] = useState(queryError);
@nmoinvaz
nmoinvaz / cef-symbols-sentry.yaml
Last active May 3, 2024 21:34
Upload CEF symbols to Sentry.io
# CEF symbols are too large to upload directly to Sentry.io. The maximum size is 2GB.
# We use Breakpad to reduce the size of the original symbols at the expense of some
# fidelity for inline functions.
name: CEF Symbols
on:
workflow_dispatch:
inputs:
cef-version:
description: 'Version of CEF to upload'
required: true
@nmoinvaz
nmoinvaz / notary.py
Created December 23, 2022 01:24
Apple Notarization Submission Script
#!/usr/bin/env python
import argparse
import boto3
import jwt
import requests
import time
import os
import hashlib
from datetime import timezone
from datetime import datetime