Skip to content

Instantly share code, notes, and snippets.

View funny-falcon's full-sized avatar

Sokolov Yura funny-falcon

View GitHub Profile
@funny-falcon
funny-falcon / hasher.cr
Last active June 17, 2017 10:18
Hasher Crystal draft
require "secure_random"
require "static_array"
module Hashing
alias Type = UInt32
@@seed = uninitialized StaticArray(UInt32, 6)
struct StdHasher
# lucky777 hash https://github.com/funny-falcon/fanom_hash/blob/master/lucky777.h
struct Impl
@funny-falcon
funny-falcon / 00-report.md
Last active January 31, 2017 14:02
improved id_table

Report for improved id_table implementation

  • it has up to 25% less size (19% on smallest tables)

  • it is a bit slower on small tables (~3%) for hit and a bit faster for miss

  • due to additional mix of key bits, it is always faster on big tables.

    Note: bit mixing makes small tables slower, so it is enabled only for big tables (>64 capacity).

    If performance for small tables much more important, mixing could be removed completely (this will return 1% on hit)

@funny-falcon
funny-falcon / go-rpc-client.go
Created January 27, 2017 08:41
simple go-rpc bench
package main
import (
"flag"
"fmt"
"log"
"net/rpc"
"sync"
"time"
)
@funny-falcon
funny-falcon / simple-client.go
Last active January 27, 2017 07:46
simple bench net/rpc
package main
import (
"bufio"
"encoding/binary"
"flag"
"fmt"
"io"
"log"
"net"
@funny-falcon
funny-falcon / rand_test.go
Last active January 10, 2017 17:35
Use of runtime.Mid and runtime.Fastrand
package benchmarks
/*
BenchmarkRandInt63_Global-4 10000000 154 ns/op
BenchmarkRandInt63_Channel-4 10000000 220 ns/op
BenchmarkRandInt63_Pool-4 50000000 28.8 ns/op
BenchmarkSourceInt63_Pool-4 50000000 34.9 ns/op
BenchmarkRandInt63_Source-4 300000000 5.71 ns/op
BenchmarkRandInt63_ShardsGettid-4 50000000 29.2 ns/op
BenchmarkRandInt63_ShardsMid-4 100000000 14.2 ns/op
@funny-falcon
funny-falcon / ciph48.c
Last active July 19, 2016 11:29
Encrypt 32bit value + 2*32bit seed + 128bit key into 48bit cipher text
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <assert.h>
#include <sys/stat.h>
#include <unistd.h>
#include <inttypes.h>
#include <string.h>
// Minimum recommended values are DOUBLEROUND=3 and MIX=2.
@funny-falcon
funny-falcon / 00_unpacthed
Last active May 4, 2016 12:15
Test patched luajit
# unpatched
$ for i in {1..6} ; do time src/luajit test_str.lua $i ; done
1 1000000 8191
real 0m0.197s
user 0m0.196s
sys 0m0.000s
2 500000 8191
real 0m0.169s
@funny-falcon
funny-falcon / bash.out
Last active March 25, 2016 12:31
bench pipe vs socket
$ echo $((16*1024*1024)) | sudo tee /proc/sys/fs/pipe-max-size
$ gcc -ggdb3 -DN=256 -O1 bench-unixsocket-pipe.c
yura@falcon-new:~/tmp$ taskset -c 2,3 ./a.out 1000000000 $((16*1024*1024))
pipe lasts: 3.121495 sec, iter/sec: 320359349.183537
sock lasts: 5.402942 sec, iter/sec: 185084353.868363
pipe lasts: 3.287446 sec, iter/sec: 304187536.025462
sock lasts: 5.444722 sec, iter/sec: 183664098.170782
$ gcc -ggdb3 -DN=512 -O1 bench-unixsocket-pipe.c
$ taskset -c 2,3 ./a.out 1000000000 $((16*1024*1024))
pipe lasts: 1.790609 sec, iter/sec: 558469073.197397
@funny-falcon
funny-falcon / mypassw.rb
Last active December 29, 2020 10:42
Personal password storage :)
#!/usr/bin/env ruby
require 'digest/sha2'
require 'io/console'
require 'base64'
USAGE = <<EOF
USAGE:
#$0 set domain [file]
- store encoded password for domain
#$0 domain [file]
/*
* Copyright (C) 2011, 2012, 2013, 2014 Mail.RU
* Copyright (C) 2011, 2012, 2013, 2014 Yuriy Vostrikov
* Copyright (C) 2014 Yuriy Sokolov aka funny_falcon
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.