-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proper implementation of next_clear_bit for Bitset and update int…
…_allocator to use it, and fix issues with Bitset creating large fixnums. - Fix lots of left-shift related bugs in Bitset (as we were creating a large number of BigNum's with potentially thousands of binary digits to hold our "words" due to left-shift converting FixNums to BigNums. It's still going to happen from 61-64 bits, but way better than 2048-bit fixnums being used). - Added benchmark for IntAllocator. It used to take up to a minute to allocate 10,000 integers on a 2.7 GHz Intel Core i5, now takes 4 seconds for 65,536 (which we killed after waiting for 6 minutes using the old allocator).
- Loading branch information
Showing
4 changed files
with
196 additions
and
32 deletions.
There are no files selected for viewing
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")) | ||
|
||
require 'amq/int_allocator' | ||
require "benchmark" | ||
|
||
allocator = AMQ::IntAllocator.new(1,65535) | ||
mutex = Mutex.new | ||
|
||
Benchmark.bm do |x| | ||
|
||
|
||
x.report("allocate") do | ||
allocator = AMQ::IntAllocator.new(1,65535) | ||
1.upto(65534) do |i| | ||
mutex.synchronize do | ||
n = allocator.allocate | ||
raise 'it be broke' unless n == i | ||
end | ||
end | ||
end | ||
|
||
x.report("allocate_with_release") do | ||
allocator = AMQ::IntAllocator.new(1,65535) | ||
1.upto(65534) do |i| | ||
mutex.synchronize do | ||
n = allocator.allocate | ||
if i % 5 == 0 | ||
allocator.release(n) | ||
end | ||
end | ||
end | ||
end | ||
|
||
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
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
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