Skip to content

Instantly share code, notes, and snippets.

View redknightlois's full-sized avatar

Federico Andres Lois redknightlois

  • Independent · Systems Engineering · Former founder @ Corvalius & Codealike
  • Buenos Aires - Argentina
  • X @federicolois
  • LinkedIn in/federicolois
View GitHub Profile
@redknightlois
redknightlois / bench-compound-field.csx
Created April 6, 2026 15:44
RavenDB-25930: Benchmark showing compound field query plan degradation without the `right is null` fix in CoraxQueryBuilder.TrySetAsStreamingField()
#!/usr/bin/env dotnet-script
// Benchmark: RavenDB-25930 Compound Field Query Plan Degradation
//
// Demonstrates the performance impact of the `right is null` fix in
// CoraxQueryBuilder.TrySetAsStreamingField(). Without the fix, a compound
// field definition (Name, Count) incorrectly captures the query plan for
// `WHERE Name = '1' AND Count > 100 ORDER BY Count`, preventing the
// CoraxBooleanItem merge that produces an efficient UnaryMatch range scan.
//
// Usage:
Checking BASE (http://127.0.0.1:18081)... OK {"BuildVersion":62,"ProductVersion":"6.2","CommitHash":"a377982","FullVersion":"6.2.14-custom-62"}
Checking PR (http://127.0.0.1:18080)... OK {"BuildVersion":62,"ProductVersion":"6.2","CommitHash":"a377982","FullVersion":"6.2.14-custom-62"}
── Populating 3M databases ──
BASE/Bench3M_Corax: 3,000,000 docs + index ready, skipping.
PR/Bench3M_Corax: populating 3,000,000 docs (Corax)...
300,000 / 3,000,000 (7.4s)
600,000 / 3,000,000 (13.9s)
900,000 / 3,000,000 (20.3s)
1,200,000 / 3,000,000 (26.3s)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
// BASE (pre-PR) on 18081, PR on 18080
---
name: john-carmack-synthesizer
description: Use this agent when you need to cut through complexity and synthesize the essential truth from multiple inputs. This agent embodies John Carmack's engineering philosophy - first principles thinking, brutal honesty about trade-offs, and focus on what actually works. Examples: <example>Context: Multiple agents have provided conflicting recommendations about system architecture. user: "I have 5 different architectural proposals and need to decide which approach is actually best" assistant: "I'll use the john-carmack-synthesizer to cut through the complexity and identify the fundamental constraints and optimal solution." <commentary>When faced with multiple complex inputs, this agent strips away the noise to find the core engineering truth.</commentary></example> <example>Context: Team is over-engineering a solution with unnecessary abstractions. user: "Our trading system design has become overly complex with too many layers" assistant: "Let me use the john-carmack-
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
private static ReadOnlySpan<byte> LoadMaskTable => new byte[]
{
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
@redknightlois
redknightlois / mish_init.py
Created July 15, 2020 14:54
Variance based initialization method for Mish activation
def init_weights(m, variance=1.0):
def _calculate_fan_in_and_fan_out(tensor):
dimensions = tensor.dim()
if dimensions < 2:
return 1, 1
if dimensions == 2: # Linear
fan_in = tensor.size(1)
fan_out = tensor.size(0)
@redknightlois
redknightlois / ralamb.py
Last active August 9, 2023 20:50
Ralamb optimizer (RAdam + LARS trick)
class Ralamb(Optimizer):
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0):
defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay)
self.buffer = [[None, None, None] for ind in range(10)]
super(Ralamb, self).__init__(params, defaults)
def __setstate__(self, state):
super(Ralamb, self).__setstate__(state)
using System;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics.X86;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;