Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# Hook to verify what modified lua files pass luacheck checks before got committed.
# Called by "git commit" with no arguments.
# To enable this hook, put it to `.git/hooks/pre-commit` and make it executable.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else

Datetime benchmark: selecting double vs int64_t

It was told that if field datetime.secs would be double we should get better performance in LuaJIT instead of uint64_t type used at the moment.

So we have created benchmark, which was comparing implementations of functions from datetime.c if we would use double or int64_t for datetime.secs field.

@tsafin
tsafin / bench-datetime-secs.lua
Last active August 15, 2021 20:46
datetime.secs vs secsf vs double. int64_t vs double
local ffi = require('ffi')
local clock = require('clock')
local builtin = ffi.C
local datetime_t = ffi.typeof('struct datetime')
local SECS_PER_DAY = 86400
local DT_EPOCH_1970_OFFSET = 719163LL
ffi.cdef [[
struct datetime_double {
@tsafin
tsafin / check.disasm
Last active August 6, 2021 22:21
There is no even simple peephole optimizations in LuaJIT
01:20 $ luajit -jdump -O3 -Ohotloop=9 -Ocse -Ofold ../days_ffi.lua
---- TRACE 1 start days_ffi.lua:14
0015 MOV 9 3
0016 MOV 10 2
0017 CALL 9 2 2
0000 . FUNCF 3 ; days_ffi.lua:9
0001 . GGET 1 0 ; "tonumber"
0002 . TGETS 2 0 1 ; "secs"
0003 . CALL 1 2 2
0000 . . FUNCC ; tonumber
#/usr/bin/bash
root=$(git rev-parse --show-toplevel)
if [ "$1" == "--gdb" ]; then
prefix="gdb --args"
shift
fi
LUA_PATH="$root/test/sql-tap/lua/?.lua;$root/test/sql/lua/?.lua;;" \
$prefix $root/build/src/tarantool $*
@tsafin
tsafin / d-all.sh
Created April 15, 2020 17:55
Mocking with visibility=default
gcc -m64 -O2 -o export_api main.c
nm -a export_api |grep ' [tT] ' |tee nm-t-0.txt
gcc -m64 -O2 -o export_api_1 -fvisibility=hidden main.c
nm -a export_api_1 |grep ' [tT] ' |tee nm-t-1.txt
g++ -m64 -O2 -o export_api_cxx main.c
nm -a export_api_cxx |grep ' [tT] ' |tee nm-t-2.txt
g++ -m64 -O2 -o export_api_cxx_1 -fvisibility=hidden main.c
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.4 (Build 555U JAVAINTEG)" ts="2016-07-18 15:27:06">
<Class name="Sample.LoggingProxy">
<Description>
simple sample of a logging proxy object:
each access (via call or property access) will
be logged to the designated global</Description>
<Super>%RegisteredObject</Super>
<TimeChanged>64116,57644.95789</TimeChanged>
<TimeCreated>64110,60845.71095</TimeCreated>
@tsafin
tsafin / dockerize
Created February 2, 2016 22:27 — forked from wjordan/dockerize.sh
Dockerize: A tiny replacement for Dockerfiles
#!/bin/sh
####
# Dockerize: A tiny replacement for Dockerfiles
# This script leverages `docker run` and `docker commit` to provide a usable workaround for
# restrictions of `docker build` and Dockerfile syntax to strictly host-independent builds.
#
# See these discussions:
# https://github.com/docker/docker/pull/1124
# https://github.com/docker/docker/issues/3156
# https://github.com/docker/docker/issues/3949
@tsafin
tsafin / designer.html
Last active January 20, 2016 12:18
designer
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
@tsafin
tsafin / gist:a443ceddbfb29c6c81ab
Created October 7, 2015 14:46
iKnow CRCs output
This file has been truncated, but you can view the full file.
{
"children":[
{"crcId":11520,"master":"","relation":"к","slave":"сообщению","freq":167,"spread":167}
,{"crcId":96545,"master":"сообщению","relation":"приложен","slave":"файл","freq":153,"spread":153}
,{"crcId":11651,"master":"","relation":"как","slave":"вариант","freq":126,"spread":126}
,{"crcId":73843,"master":"не рубящий","relation":"в","slave":"каше","freq":77,"spread":77}
,{"crcId":1351,"master":"","relation":"в","slave":"cache","freq":72,"spread":72}
,{"crcId":53695,"master":"все","relation":"работает","slave":"","freq":69,"spread":68}
,{"crcId":2718,"master":"","relation":"в","slave":"случае","freq":60,"spread":60}
,{"crcId":1850,"master":"","relation":"в","slave":"документации","freq":55,"spread":55}