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
| // How do I make the 'f' function parameterized by the type of the implicit? | |
| def cas[T](key: Array[Byte], | |
| ttl: Int = 0) | |
| (f: Option[T] => Option[T]) | |
| (implicit transcoder: Transcoder[T] = defaultTranscoder): Boolean = { ... } | |
| // trying to compile this usage fails. would like to avoid using c.cas[SomeType](key) |
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
| (0 to 7).foldLeft(BigInt(0)) { (acc, idx) => | |
| idx match { | |
| case 7 => acc | bytes.get(idx) | |
| case _ => acc | bytes.get(idx) << 8 | |
| } | |
| } |
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
| # to test, with the rackup and config files in place | |
| $ gem install zbatery | |
| $ zbatery -c zb_config.rb test.ru | |
| # in another terminal | |
| $ ab -n 300 -c 1 http://127.0.0.1:8080/ |
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
| listen loop error: #<Errno::EBADF: Bad file descriptor>. | |
| kernel/common/io.rb:1701:in `close' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/process_client.rb:59:in `process_client' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/thread_pool.rb:46:in `sync_worker' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/thread_pool.rb:30:in `worker_loop' | |
| kernel/common/thread.rb:66:in `__run__' | |
| listen loop error: #<Errno::EBADF: Bad file descriptor>. | |
| kernel/common/io.rb:1701:in `close' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/process_client.rb:59:in `process_client' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/thread_pool.rb:46:in `sync_worker' |
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
| Error convert fd (14) to lowlevel IO: Too many open files (24)app error: #<TypeError: unable to convert fd (14) to lowlevel IO: Too many open files (24)> | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/process_client.rb:22:in `process_client' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/thread_pool.rb:46:in `sync_worker' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/thread_pool.rb:30:in `worker_loop' | |
| kernel/common/thread.rb:66:in `__run__' | |
| Error convert fd (14) to lowlevel IO: Too many open files (24)Error convert fd (14) to lowlevel IO: Too many open files (24)app error: #<TypeError: unable to convert fd (14) to lowlevel IO: Too many open files (24)> | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/process_client.rb:22:in `process_client' | |
| /Users/jake/development/rnkfoods/vendorgems/rbx/1.8/gems/rainbows-1.0.0/lib/rainbows/thread_pool.rb:46:in `sync_worker' | |
| /U |
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
| (gdb) bt | |
| #0 rubinius::TypeError::raise (type=rubinius::ModuleType, obj=0x1012630a8, reason=0x0) at vm/exception.cpp:25 | |
| #1 0x000000010016c4e8 in as<rubinius::Module> [inlined] () at /Users/jake/.rvm/src/rbx-head/vm/object_utils.hpp:94 | |
| #2 0x000000010016c4e8 in rubinius::Module::cvar_defined (this=0x11542b4b0, state=0x101004c00, name=0x1f14e) at object_utils.hpp:199 | |
| #3 0x00000001000d420e in rubinius::Primitives::static_scope_cvar_defined (state=0x101004c00, call_frame=0x7fff5fbf4ee0, msg=@0x11542eb90, args=@0x7fff5fbf4e30) at primitives_glue.gen.cpp:26010 | |
| #4 0x0000000100074c01 in rubinius::VMMethod::interpreter (state=0x101004c00, vmm=0x11542df20, call_frame=0x7fff5fbf4ee0) at instruction_implementations.hpp:548 | |
| #5 0x000000010014fa4d in rubinius::BlockEnvironment::execute_interpreter (state=0x101004c00, previous=0x7fff5fbf5728, env=0x1012d2ae0, args=@0x7fff5fbf5670, invocation=@0x7fff5fbf5080) at vm/builtin/block_environment.cpp:161 | |
| #6 0x00000001001500a3 in rubinius::BlockEnvironment::call_under (this=0x1 |
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 'benchmark' | |
| puts Benchmark.measure { | |
| a = [] | |
| 5000000.times { a << []} # use up some RAM | |
| 3000000.times {[]} | |
| } | |
| -O0: |
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
| diff --git a/vm/capi/gc.cpp b/vm/capi/gc.cpp | |
| index c6231e4..71c17a0 100644 | |
| --- a/vm/capi/gc.cpp | |
| +++ b/vm/capi/gc.cpp | |
| @@ -55,6 +55,11 @@ extern "C" { | |
| * to be in the heap. | |
| */ | |
| void rb_gc_mark_maybe(VALUE ptr) { | |
| - rb_gc_mark(ptr); | |
| + NativeMethodEnvironment* env = NativeMethodEnvironment::get(); |
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
| bool Handle::valid_handle_p(STATE, Handle* handle) { | |
| Handles* handles = state->shared.global_handles(); | |
| for(Handles::Iterator i(*handles); i.more(); i.advance()) { | |
| if(*i == handle) return true; | |
| } | |
| return false; | |
| } |
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
| From 47aed113b4a3059bd98d25bd28f01402895df5ff Mon Sep 17 00:00:00 2001 | |
| From: Jake Douglas <[email protected]> | |
| Date: Mon, 26 Jul 2010 11:11:58 -0700 | |
| Subject: [PATCH] Zero out the generator struct to avoid GC problems | |
| --- | |
| ext/json/ext/generator/generator.c | 1 + | |
| 1 files changed, 1 insertions(+), 0 deletions(-) | |
| diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c |
NewerOlder