Skip to content

Instantly share code, notes, and snippets.


Systems Performance 2nd edition

See synthesized write-up here

  • Do a quick performance check in 60 seconds
  • Use a number of different tools available in unix
  • Use flamegraphs of the callstack if you have access to them
  • Best performance winds are elimiating unnecessary wrok, for example a thread stack in a loop, eliminating bad config
  • Mantras: Don't do it (elimiate); do it again (caching); do it less (polling), do it when they're not looking, do it concurrently, do it more cheaply
ochaton /
Created July 6, 2021 16:45
Monitoring fiber of latency of single ev_once
> tarantool -l fiber -l clock -e 'fiber.create(function() while true do while clock.time() < fiber.time()+0.1 do end fiber.sleep(0.01) end end)' test.lua
entering the event loop
e:100.011µs p:0.017µs t:99.998µs
e:100.042µs p:0.010µs t:100.035µs
e:100.013µs p:0.015µs t:100.004µs
e:100.005µs p:0.006µs t:99.994µs
e:100.007µs p:0.004µs t:99.996µs
e:100.010µs p:0.009µs t:99.993µs
e:100.012µs p:0.016µs t:100.000µs
e:100.009µs p:0.050µs t:99.999µs
Grinnz /
Last active July 19, 2023 23:31
Perl 7 FAQ
View ls.lua = setmetatable({}, {
__serialize = function()
local res = {}
for _, sp_info in, { iterator = "GE" }) do
local sp =[]
local info = {} = tostring(
info.engine = tostring(sp.engine)
info.len = tostring(sp:len())
knazarov / full_text_search_tarantool.lua
Created September 23, 2020 08:00
Full text search example for Tarantool
View full_text_search_tarantool.lua
#!/usr/bin/env tarantool
local pickle = require('pickle')
local yaml = require('yaml')
function trivec(str)
str = string.lower(str)
local vec = ""
View rsa.lua
--- RSA bindings for Tarantool
--- Carefully adapted from
local bit = require "bit"
local band =
local ffi = require "ffi"
local ffi_new =
local ffi_gc = ffi.gc
local ffi_copy = ffi.copy
local ffi_str = ffi.string
R-omk / tnteval
Created January 24, 2020 06:56
Print output from tarantool to stdout
View tnteval
#!/usr/bin/env tarantool
local CONSOLE_SOCKET_PATH = 'unix/:/var/run/tarantool/tarantool.sock'
local os = require("os")
console = require('console')
local status, reason
status, reason = pcall(function() require('console').connect(CONSOLE_SOCKET_PATH) end)
if not status then
RunsFor / nginx.conf
Last active August 1, 2022 19:48
HTTP terminating tools comparison in tarantool (MacBook Pro 13 2017 3.5 Ghz Intel Core i7, 16GB)
View nginx.conf
worker_processes 8;
error_log logs/error.log info;
events {
worker_connections 4096;
http {
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
shafik /
Last active September 23, 2023 03:11
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

jef-sure /
Created December 9, 2017 16:56
Check for Positive Integer entry
use B;
use Scalar::Util::LooksLikeNumber 'looks_like_number';
sub positive_int {
my $lln = looks_like_number($_[0]);
($lln == 1 || $lln & B::SVf_IOK) && $_[0] > 0;
for (0, "0", 123, "123", 123.45, "123.45", "yolki-palki", "nancy") {
print "$_ -> " . (positive_int($_) ? "true" : "false");