This file contains 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
echo 1 > /sys/block/sd#/device/delete |
This file contains 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
diff --git a/common.mk b/common.mk | |
index eb89a2b..59cdfe4 100644 | |
--- a/common.mk | |
+++ b/common.mk | |
@@ -630,7 +630,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 \ |
This file contains 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
# simple fiber pool for EM::Synchrony (or same) | |
class FiberPool | |
def initialize(count) | |
@queue = EM::Queue.new | |
@count = count | |
count.times do | |
fib = Fiber.new do | |
fiber_loop(fib) | |
end | |
fib.resume |
This file contains 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
def EM.run_deferred_callbacks | |
until (@resultqueue ||= []).empty? | |
result,cback = @resultqueue.pop | |
cback.call result if cback | |
end | |
# Capture the size at the start of this tick... | |
time = Time.now | |
size = @next_tick_queue.size | |
cur_ticks = @next_tick_mutex.synchronize{ @next_tick_queue.slice!(0, size) } |
This file contains 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 'kgio' | |
ip = '127.0.0.1' # better write here real IP address of your network card | |
prc = fork do | |
srv = Kgio::TCPServer.new(ip, 8000) | |
sock = srv.kgio_accept(Kgio::TCPSocket) | |
count = 0 | |
b = '' | |
while s = sock.kgio_read(1024*1024, b) |
This file contains 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
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 1 MB sequentially from memory 250,000 ns 0.25 ms | |
Round trip within same datacenter 500,000 ns 0.5 ms | |
Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory |
This file contains 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
diff --git a/array.c b/array.c | |
index 64647c3..76fac8a 100644 | |
--- a/array.c | |
+++ b/array.c | |
@@ -255,15 +255,24 @@ rb_ary_modify(VALUE ary) | |
rb_ary_modify_check(ary); | |
if (ARY_SHARED_P(ary)) { | |
long len = RARRAY_LEN(ary); | |
+ VALUE shared = ARY_SHARED(ary); | |
if (len <= RARRAY_EMBED_LEN_MAX) { |
This file contains 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
$ ruby -v | |
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux] | |
$ # Ruby 1.9.2 fails to run finalizer until program exit | |
$ ruby test_finalizer.rb outter | |
assigned | |
deassigned | |
stop | |
HI 9472020 | |
$ ruby test_finalizer.rb inner | |
assigned |
This file contains 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
#GC.stress = true | |
STDOUT.sync = true | |
$stdout.sync = true | |
KIND = ARGV[0] || 'inner' | |
def finalizer(i) | |
proc{|id| puts "HI #{i} #{id}"} | |
end |
This file contains 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
Original article: http://www.franzens.org/2011/10/writing-minimalistic-web-server-using.html |