Skip to content

Instantly share code, notes, and snippets.

View puzpuzpuz's full-sized avatar
🐢

Andrei Pechkurov puzpuzpuz

🐢
View GitHub Profile
@puzpuzpuz
puzpuzpuz / test_distributions.sql
Created March 13, 2026 14:28
Test data distributions for HORIZON JOIN adaptive scan benchmarking
-- =============================================================================
-- Test data distributions for HORIZON JOIN adaptive scan benchmarking.
--
-- Each scenario generates fx_trades_* and market_data_* with different symbol
-- cardinality, gap sizes, and key distributions to exercise the adaptive
-- backward-to-forward scan switch.
--
-- Benchmark query template (replace suffixes):
--
-- SELECT t.symbol, h.offset, avg(m.best_bid), avg(m.best_ask), count(*)
@puzpuzpuz
puzpuzpuz / gist:0894a0140a2f054dec06a919ad1a5b11
Last active February 5, 2026 12:23
analyze-flamegraph.js
#!/usr/bin/env node
/**
* Flame graph analyzer for async-profiler HTML output.
*
* Usage: node analyze-flamegraph.js <flamegraph.html> [thread-filter]
*
* Examples:
* node analyze-flamegraph.js flame.html # All threads
* node analyze-flamegraph.js flame.html query_ # Only query worker threads
* node analyze-flamegraph.js flame.html shared-network # Network threads
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2024 QuestDB
*
@puzpuzpuz
puzpuzpuz / bench.rs
Last active August 20, 2025 10:25
Benchmarks for QuestDB array shape calculation function
use std::hint::black_box;
use std::time::Instant;
const ARRAY_NDIMS_LIMIT: usize = 32;
// Simple linear congruential generator for reproducible random numbers
struct SimpleRng {
state: u64,
}
@puzpuzpuz
puzpuzpuz / main.go
Last active July 15, 2023 11:26
Reproducer for heavy O3 ingestion
package main
import (
"context"
"fmt"
"log"
"math/rand"
"strconv"
"strings"
"time"
@puzpuzpuz
puzpuzpuz / main.go
Created May 23, 2023 10:51
Dynamic column definition in QuestDB Go client
package main
import (
"context"
"log"
"strconv"
"time"
qdb "github.com/questdb/go-questdb-client"
)
public class Main {
public static void main(String[] args) {
int[] arr = new int[]{1, 2, 3};
for (int i = 0, n = arr.length; i < n; i++) {
System.out.println(arr[i]);
}
for (int n : arr) {
@puzpuzpuz
puzpuzpuz / benchstat.txt
Created November 2, 2022 18:41
xsync v.2.3.1 measurements on c6g.metal
$ go version
go version go1.19.3 linux/arm64
$ go test -run='^$' -cpu=1,2,4,8,16,32,64 -bench . -count=30 -timeout=0 | tee bench.txt
$ benchstat bench.txt | tee benchstat.txt
name time/op
Counter 27.3ns ± 1%
Counter-2 27.2ns ±11%
Counter-4 15.3ns ± 8%
Counter-8 7.43ns ± 7%
@puzpuzpuz
puzpuzpuz / gist:4618459e6508736b5b413ad6b5bd3908
Last active November 16, 2020 07:59
check-is-http-token.js
'use strict'
const keys = [
'TCN',
'alternate-protocol',
':',
'@@',
'中文呢',
'((((())))',
':alternate-protocol',
interface MetricsStorage {
store(dataPoints: DataPoint[]): Promise<void>;
queryRange(query: Query): Promise<DataPoint[]>;
queryLatest(query: Query): Promise<DataPoint | null>;
}