Multiple changes.
- Complete first round of documentation. - Complete first round of tests and coverage. - Expand the thread benchmarker for testing metasync. - Add enumerators (each_key/each_value/each_pair) using cursors. - Remove keys() implementation in favor of using the emumerable. - Make deserialization more DRY. - Add an efficient length() method. - Add various Hash-alike methods. - General code cleanup for release. FossilOrigin-Name: 0d2bd3995f203c9ac1734ac3da32dd2f09efda9a394e554e6006e44dd07a33b0
This commit is contained in:
parent
907cdecfc5
commit
c0cd35e260
8 changed files with 828 additions and 271 deletions
|
|
@ -7,10 +7,6 @@ require 'fileutils'
|
|||
|
||||
include FileUtils
|
||||
|
||||
|
||||
db = MDBX::Database.open( 'tmpdb' )
|
||||
mtx = Mutex.new
|
||||
|
||||
at_exit do
|
||||
rm_r 'tmpdb'
|
||||
end
|
||||
|
|
@ -20,31 +16,17 @@ WRITES_PER = 1000
|
|||
|
||||
puts "#{THREAD_COUNT} simultaneous threads, #{WRITES_PER} writes each:"
|
||||
|
||||
Benchmark.bm( 10 ) do |x|
|
||||
x.report( " txn per write:" ) do
|
||||
threads = []
|
||||
THREAD_COUNT.times do |i|
|
||||
threads << Thread.new do
|
||||
mtx.synchronize do
|
||||
WRITES_PER.times do
|
||||
key = "%02d-%d" % [ i, rand(1000) ]
|
||||
db[ key ] = rand(1000)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
threads.map( &:join )
|
||||
end
|
||||
def run_bench( db, msg )
|
||||
mtx = Mutex.new
|
||||
Benchmark.bm( 10 ) do |x|
|
||||
puts msg
|
||||
puts '-' * 60
|
||||
|
||||
|
||||
# Long running transactions require a mutex across threads.
|
||||
#
|
||||
x.report( "txn per thread:" ) do
|
||||
threads = []
|
||||
THREAD_COUNT.times do |i|
|
||||
threads << Thread.new do
|
||||
mtx.synchronize do
|
||||
db.transaction do
|
||||
x.report( " txn per write:" ) do
|
||||
threads = []
|
||||
THREAD_COUNT.times do |i|
|
||||
threads << Thread.new do
|
||||
mtx.synchronize do
|
||||
WRITES_PER.times do
|
||||
key = "%02d-%d" % [ i, rand(1000) ]
|
||||
db[ key ] = rand(1000)
|
||||
|
|
@ -52,18 +34,48 @@ Benchmark.bm( 10 ) do |x|
|
|||
end
|
||||
end
|
||||
end
|
||||
threads.map( &:join )
|
||||
end
|
||||
threads.map( &:join )
|
||||
end
|
||||
|
||||
x.report( " unthreaded:" ) do
|
||||
db.transaction do
|
||||
( THREAD_COUNT * WRITES_PER ).times do
|
||||
key = "000-%d" % [ rand(1000) ]
|
||||
db[ key ] = rand(1000)
|
||||
|
||||
# Long running transactions require a mutex across threads.
|
||||
#
|
||||
x.report( "txn per thread:" ) do
|
||||
threads = []
|
||||
THREAD_COUNT.times do |i|
|
||||
threads << Thread.new do
|
||||
mtx.synchronize do
|
||||
db.transaction do
|
||||
WRITES_PER.times do
|
||||
key = "%02d-%d" % [ i, rand(1000) ]
|
||||
db[ key ] = rand(1000)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
threads.map( &:join )
|
||||
end
|
||||
|
||||
x.report( " unthreaded:" ) do
|
||||
db.transaction do
|
||||
( THREAD_COUNT * WRITES_PER ).times do
|
||||
key = "000-%d" % [ rand(1000) ]
|
||||
db[ key ] = rand(1000)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
db.close
|
||||
puts
|
||||
end
|
||||
|
||||
|
||||
db = MDBX::Database.open( 'tmpdb' )
|
||||
run_bench( db, "Default database flags:" )
|
||||
|
||||
db = MDBX::Database.open( 'tmpdb', no_metasync: true )
|
||||
run_bench( db, "Disabled metasync:" )
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue