Skip to content

Instantly share code, notes, and snippets.

Avatar

Arseny Kapoulkine zeux

View GitHub Profile
@zeux
zeux / meshlets.py
Last active December 20, 2022 02:19
Gather best meshlet configurations (from the topology perspective) for each meshlet size limit
View meshlets.py
tl = 512
for vl in [32, 64, 96, 128, 256]:
bestx = 0
besty = 0
bests = vl
for x in range(1, vl):
for y in range(1, vl):
v = (x+1)*(y+1)
@zeux
zeux / gctracker.lua
Last active November 12, 2022 09:14
GC tracker for Luau that provides more predicatable (compared to `__gc`...) destructor invocation for dead objects. Supports ~constant time update cost by limiting the iteration count such that update can be called every frame with a small n for negligible performance cost.
View gctracker.lua
--!strict
--[[
BSD Zero Clause License
Copyright (c) 2022 Arseny Kapoulkine
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
@zeux
zeux / gcpacer.md
Last active February 23, 2022 22:53
Luau GC exploration: doing some math on relationship between S / G / P
View gcpacer.md

GC pacing

This document tries to establish a mathematical formulation for GC pacing in Luau GC, assuming a uniform rate of allocation in an application with steady live set.

GC algorithm assumptions

  • GC proceeds in three phases: mark, atomic, sweep
  • During mark, the heap size only grows as we don't deallocate memory short of table resize
  • During sweep, the heap size grows due to new allocations and shrinks due to swept objects
  • Live set is fixed at atomic time (between mark & sweep)
@zeux
zeux / usleep.cpp
Last active November 26, 2021 21:24
Run with intervals 100, 1000, 10000 as a command line input
View usleep.cpp
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <stdint.h>
#ifdef __APPLE__
#include <mach/mach_time.h>
#else
@zeux
zeux / luaubind.hpp
Last active November 24, 2021 20:28
A simple proof of concept for Luau function binding.
View luaubind.hpp
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once
// Use this with luaL_Reg + luaL_register:
//
// static const luaL_Reg funcs[] = {
// {"test123", LUAU_BIND(test123)},
// {NULL, NULL},
// };
@zeux
zeux / clang27.md
Last active August 1, 2022 11:14
How does clang 2.7 hold up in 2021?
View clang27.md

A friend recently learned about Proebsting's law and mentioned it to me off hand. I knew about the law's existence but I never really asked myself - do I believe in it?

For people who aren't aware, Proebsting's law states:

Compiler Advances Double Computing Power Every 18 Years

Which is to say, if you upgrade your compiler every 18 years, you would expect on average your code to double in performance on the same hardware.

Let's C about this

View roblox-graphics-apis-2021.md

State of Roblox graphics API across all platforms, with percentage deltas since EOY 2020. Updated December 31 2021.

Windows

API Share
Direct3D 11+ 92% (+3%)
Direct3D 10.1 5% (-2%)
Direct3D 10.0 3% (-0.5%)
@zeux
zeux / builtin.lua
Created May 20, 2020 15:43
Roblox Luau type surface as of May 20, 2020
View builtin.lua
export type any=any
export type nil=nil
export type string=string
export type number=number
export type boolean=boolean
@zeux
zeux / codecbench-clang.txt
Created April 25, 2020 18:41
codecbench: native gcc vs native clang vs v8 Wasm vs WAVM Wasm
View codecbench-clang.txt
source: vertex data 32064032 bytes, index data 24000000 bytes
pass 0: vertex data 18518385 bytes, index data 2332680 bytes
decode: vertex 9.31 ms (3.21 GB/sec), index 5.65 ms (3.95 GB/sec)
decode: vertex 9.43 ms (3.17 GB/sec), index 5.64 ms (3.96 GB/sec)
decode: vertex 9.44 ms (3.16 GB/sec), index 5.69 ms (3.93 GB/sec)
decode: vertex 9.47 ms (3.15 GB/sec), index 5.72 ms (3.91 GB/sec)
decode: vertex 9.50 ms (3.14 GB/sec), index 5.72 ms (3.91 GB/sec)
decode: vertex 9.36 ms (3.19 GB/sec), index 5.82 ms (3.84 GB/sec)
decode: vertex 9.57 ms (3.12 GB/sec), index 5.75 ms (3.89 GB/sec)
decode: vertex 9.47 ms (3.15 GB/sec), index 5.72 ms (3.91 GB/sec)
@zeux
zeux / fixupsimd.js
Last active April 3, 2020 19:42
A SIMD opcode remapper for the impending Wasm SIMD instruction renumbering, written on stream https://www.youtube.com/watch?v=zo20ryVj6e8
View fixupsimd.js
function fixupSimd(input) {
var data = new Uint8Array(input);
var read = 0;
var result = new Uint8Array(data.length * 2); // worst case: opcode renumbering changes 1-byte to 2-byte
var write = 0;
var readByte = function() {
read++;
if (read >= data.length) {