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 / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@funny-falcon
funny-falcon / 00-test_hash_shift.rb
Last active March 15, 2024 04:20
Fix Ruby Hash#shift
require 'benchmark'
N = 50000
K = 10000
a = {}
K.times{|i| a[i] = nil}
class Hash
def custom_shift
@funny-falcon
funny-falcon / cumulative_performance.patch
Created January 22, 2012 19:19
ruby-1.9.3-p0 cumulative performance patch.
diff --git a/common.mk b/common.mk
index ea244cc..4f22609 100644
--- a/common.mk
+++ b/common.mk
@@ -629,7 +629,8 @@ file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
- {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h
+ {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \
@funny-falcon
funny-falcon / results.md
Last active October 8, 2023 14:51
Crystal String.index patch benchmark
was idx now idx diff idx was bidx now bidx diff bidx
small 1 0.068663 0.061373 -10.62 0.071392 0.008054 -88.72
medium 1 0.503822 0.334602 -33.59 0.545443 0.010590 -98.06
big 1 4.697361 2.865704 -38.99 5.058999 0.027877 -99.45
small 2 0.069861 0.053189 -23.86 0.073254 0.034132 -53.41
medium 2 0.509033 0.336184 -33.96 0.548318 0.235357 -57.08
big 2 4.730817 3.117069 -34.11 5.062775 2.049732 -59.51
small 4 0.077225 0.058108 -24.75 0.079227 0.036833 -53.51
medium 4 0.510799 0.340637 -33.31 0.554923 0.242836 -56.24
cmake_minimum_required(VERSION 3.16)
project(test_backtrace VERSION 0.1 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS true)
find_library(LIBBACKTRACE backtrace)
add_executable(test_exe test_exe.c)
target_link_libraries(test_exe PUBLIC backtrace)
@funny-falcon
funny-falcon / sshrc
Created July 18, 2022 08:11
.ssh/rc to constant ssh_auth_sock but not fake X11 auth
if test "$SSH_AUTH_SOCK" ; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
export SSH_AUTH_SOCK
fi
# example sshrc file
if read proto cookie && [ -n "$DISPLAY" ]; then
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
# X11UseLocalhost=yes
@funny-falcon
funny-falcon / gist:4003797
Created November 2, 2012 19:30
IcedCoffeeScript examples
# Examples from http://andreypopp.com/posts/2012-10-30-callbacks-to-promises.html
# using IcedCoffeeScript http://maxtaco.github.com/coffee-script/ :
search = (engine, q, cb) ->
$.ajax(url: engine, success: cb)
await
search 'google', 'js', defer(googleSearched)
search 'bing', 'js', defer(bingSearched)
processResults(bingSearched, googleSearched)
await
@funny-falcon
funny-falcon / patch-1.9.2-gc.patch
Created March 5, 2011 11:11
GC tunning simple patch ruby 1.9.2 p180
diff --git a/gc.c b/gc.c
--- a/gc.c
+++ b/gc.c
@@ -77,6 +77,41 @@ void *alloca ();
#ifndef GC_MALLOC_LIMIT
#define GC_MALLOC_LIMIT 8000000
#endif
+#define HEAP_MIN_SLOTS 10000
+#define FREE_MIN 4096
+
class HashChTbl(K, V)
include Enumerable({K, V})
include Iterable({K, V})
getter size : Int32 = 0
# index into SIZES array
@sz : UInt8 = 0_u8
@rebuild_num : UInt16 = 0_u16
@first : UInt32 = 0_u32
@last : UInt32 = 0_u32