This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'tokyo_tyrant' | |
TYRANT = TokyoTyrant::Table.new | |
AMOUNT_RECORDS = 8000 | |
$TYRANT_ID = 0 | |
RECORD = { | |
"component_version" => "X", | |
"state" => "Analyze", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "rbench" | |
def omg_slow | |
return 1 | |
end | |
def omg_fast | |
1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix memory caching in dev mode | |
# put this in config/initializers/fix_caching_in_dev.rb | |
# Hopefully this won't be needed for long, this fixes cache calls (due to class reloading in dev) | |
# http://blog.bashme.org/2008/07/25/rails-21-model-caching-issue/ | |
if ActiveSupport::Dependencies.mechanism == :load | |
module ActiveSupport | |
module Cache | |
class Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TokyoTyrant Single Node | |
user system total real | |
inserting data 0.320000 0.170000 0.490000 ( 1.415912) | |
reading data 0.310000 0.170000 0.480000 ( 1.394186) | |
TokyoTyrant Balanced 3 nodes using Ruby C Fast Hash Ring | |
user system total real | |
inserting data 0.300000 0.170000 0.470000 ( 1.464022) | |
reading data 0.350000 0.170000 0.520000 ( 1.489997) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Spoiler... | |
# user system total real | |
# Hash Ring 4.580000 0.040000 4.620000 ( 4.785069) | |
# Fash Hash Ring 0.080000 0.000000 0.080000 ( 0.087039) | |
# | |
require 'benchmark' | |
require 'rubygems' | |
require 'faker' | |
require 'hash_ring' | |
require 'fast_hash_ring' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scopes[:your_composite_scope_name] = proc{ Scope.new(your.combined.scopes.here, {}) } | |
def self.your_composite_scope_name(*args) | |
scopes[:your_composite_scope_name].call(self, *args) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nginx with memcache module... after a request the connection to memcached closes, what gives? | |
http { | |
upstream memcache { | |
server 127.0.0.1:11211; | |
keepalive 1024 single; # with this or without http://mdounin.ru/hg/ngx_http_upstream_keepalive/ | |
} | |
server { | |
listen 80; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Message Pack vs similar utilities | |
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02 | |
Packing | |
user system total real | |
pack: bert 18.320000 0.770000 19.090000 ( 19.101583) | |
pack: bson_ext 0.850000 0.030000 0.880000 ( 0.878398) | |
pack: json_ext 2.540000 0.040000 2.580000 ( 2.582495) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- tcadb.c.orig 2010-03-11 09:55:29.000000000 -0500 | |
+++ tcadb.c 2010-03-13 15:34:13.000000000 -0500 | |
@@ -2423,6 +2423,25 @@ TCLIST *tcadbmisc(TCADB *adb, const char | |
tclistdel(rv); | |
rv = NULL; | |
} | |
+ } else if(!strcmp(name, "iterrec")){ | |
+ rv = tclistnew2(1); | |
+ int ksiz; | |
+ const char *kbuf = tcbdbcurkey3(adb->cur, &ksiz); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ttutil.c.orig 2010-03-13 00:33:29.000000000 -0500 | |
+++ ttutil.c 2010-03-13 00:34:05.000000000 -0500 | |
@@ -127,7 +127,7 @@ int ttopensockunix(const char *path){ | |
struct sockaddr_un saun; | |
memset(&saun, 0, sizeof(saun)); | |
saun.sun_family = AF_UNIX; | |
- snprintf(saun.sun_path, SOCKPATHBUFSIZ, "%s", path); | |
+ strncpy(saun.sun_path, path, sizeof(saun.sun_path)-1); | |
int fd = socket(PF_UNIX, SOCK_STREAM, 0); | |
if(fd == -1) return -1; |