- 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
> 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 |
_G.ls = setmetatable({}, { | |
__serialize = function() | |
local res = {} | |
for _, sp_info in box.space._space:pairs(512, { iterator = "GE" }) do | |
local sp = box.space[sp_info.name] | |
local info = {} | |
info.name = tostring(sp.name) | |
info.engine = tostring(sp.engine) | |
info.len = tostring(sp:len()) |
#!/usr/bin/env tarantool | |
local pickle = require('pickle') | |
local yaml = require('yaml') | |
function trivec(str) | |
str = string.lower(str) | |
local vec = "" |
--- RSA bindings for Tarantool | |
--- Carefully adapted from https://github.com/spacewander/lua-resty-rsa | |
local bit = require "bit" | |
local band = bit.band | |
local ffi = require "ffi" | |
local ffi_new = ffi.new | |
local ffi_gc = ffi.gc | |
local ffi_copy = ffi.copy | |
local ffi_str = ffi.string |
#!/usr/bin/env tarantool | |
local CONSOLE_SOCKET_PATH = 'unix/:/var/run/tarantool/tarantool.sock' | |
local os = require("os") | |
console = require('console') | |
console.on_start(function(self) | |
local status, reason | |
status, reason = pcall(function() require('console').connect(CONSOLE_SOCKET_PATH) end) | |
if not status then |
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; |
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