Skip to content

Instantly share code, notes, and snippets.

@sergos

sergos/load3.lua Secret

Created July 6, 2020 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergos/feb397ed4d5a5f739ee501f768da31e6 to your computer and use it in GitHub Desktop.
Save sergos/feb397ed4d5a5f739ee501f768da31e6 to your computer and use it in GitHub Desktop.
1Mop/Sec Tarantool
os.execute('rm *.snap *.xlog')
t=require('clock')
y=require('yaml')
f=require('fiber')
box.cfg{log_level = 0,
memtx_memory = 1024*1024*2048,
-- replication_synchro_quorum = 1
}
s=box.schema.create_space('test'
-- , {is_sync = true}
)
pk=s:create_index('pk',{type = 'HASH'})
-- number of transactions
num_ins = 100000
-- number of fibers
num_fibers = 50
if arg[1] ~= nil then num_fibers=arg[1] end
-- number of ops per transaction
num_ops = 10
function fi(start, s)
local ss = start
for i = 1, num_ins/num_fibers do
box.begin()
for j=1, num_ops do
s:insert{start}
start=start+1
end
box.commit()
end
end
-- fiber storage to join them
fs = {}
begin = {t.time(),t.proc()}
for i = 1, num_fibers do
fs[i] = f.create(fi, i*num_ins, s)
fs[i]:wakeup() -- needed for backward compatibility with 1.7
end
for i=1,num_fibers do
while fs[i]:status() ~= 'dead' do f.yield() end -- needed for backward compatibility with 1.7
end
len={t.time()-begin[1], t.proc()-begin[2]}
-- print(y.encode(len))
-- print('inserted:', pk:count())
print(num_fibers, pk:count() / len[1])
os.exit()
@cyrillos
Copy link

cyrillos commented Aug 31, 2020

taskset -a 0xe tarantool load.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment