Skip to content

Commit

Permalink
Update wrk scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
harrywong committed Aug 13, 2018
1 parent 0abce21 commit e1e0fb1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 116 deletions.
1 change: 0 additions & 1 deletion bind/libevt/evt_abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ extern "C" {
void*
evt_abi() {
abi_serializer::set_max_serialization_time(fc::hours(1));

auto abi = new abi_def(evt::chain::contracts::evt_contract_abi());
return (void*)abi;
}
Expand Down
5 changes: 4 additions & 1 deletion libraries/chain/contracts/abi_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using boost::algorithm::ends_with;
using std::string;

const size_t abi_serializer::max_recursion_depth;
fc::microseconds abi_serializer::max_serialization_time = fc::milliseconds(15); // 15ms
fc::microseconds abi_serializer::max_serialization_time;

template <typename T>
inline fc::variant
Expand Down Expand Up @@ -52,6 +52,9 @@ pack_unpack() {
}

abi_serializer::abi_serializer(const abi_def& abi) {
if(get_max_serialization_time().count() == 0) {
set_max_serialization_time(fc::milliseconds(15)); // 15ms
}
configure_built_in_types();
set_abi(abi);
}
Expand Down
12 changes: 6 additions & 6 deletions libraries/fc/include/fc/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace fc {
class microseconds {
public:
explicit microseconds( int64_t c = 0) :_count(c){}
explicit constexpr microseconds( int64_t c = 0) :_count(c){}
static microseconds maximum() { return microseconds(0x7fffffffffffffffll); }
friend microseconds operator + (const microseconds& l, const microseconds& r ) { return microseconds(l._count+r._count); }
friend microseconds operator - (const microseconds& l, const microseconds& r ) { return microseconds(l._count-r._count); }
Expand All @@ -31,11 +31,11 @@ namespace fc {
friend class time_point;
int64_t _count;
};
inline microseconds seconds( int64_t s ) { return microseconds( s * 1000000 ); }
inline microseconds milliseconds( int64_t s ) { return microseconds( s * 1000 ); }
inline microseconds minutes(int64_t m) { return seconds(60*m); }
inline microseconds hours(int64_t h) { return minutes(60*h); }
inline microseconds days(int64_t d) { return hours(24*d); }
inline microseconds constexpr seconds( int64_t s ) { return microseconds( s * 1000000 ); }
inline microseconds constexpr milliseconds( int64_t s ) { return microseconds( s * 1000 ); }
inline microseconds constexpr minutes(int64_t m) { return seconds(60*m); }
inline microseconds constexpr hours(int64_t h) { return minutes(60*h); }
inline microseconds constexpr days(int64_t d) { return hours(24*d); }

class variant;
void to_variant( const fc::microseconds&, fc::variant& );
Expand Down
21 changes: 11 additions & 10 deletions loadtest/wrk-scripts/loadtest.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
Reader = require("reader")
local reader = require("reader")

local counter = 1
local threads = {}
local header = {}
header["Content-Type"] = "application/json"
local header = {
"Content-Type" = "application/json"
}

setup = function(thread)
thread:set("id", counter)
thread:set("id", #threads)
thread:set("reader", reader)
table.insert(threads, thread)
counter = counter + 1
end

init = function(args)
local regions = args
local regions = select(2, unpack(args))
local folder = args[1]

trx_num = 0
resp = 0
reader = Reader.new('trxs/'..regions[id]..'_traffic_data.lz4')
file = reader.open(folder..regions[id]..'_traffic_data.lz4')
print(("thread %d region %s"):format(id, regions[id]))
end

request = function()
trx = reader:read_trx()
trx = reader.read_trx(file)
trx_num = trx_num + 1
post = wrk.format("POST", "/v1/chain/push_transaction", header, trx)
return post
Expand All @@ -30,7 +32,6 @@ response = function(status, headers, body)
resp = resp + 1
end


done = function(summary, latency, requests)
for _, thd in ipairs(threads) do
local id = thd:get("id")
Expand Down
97 changes: 0 additions & 97 deletions loadtest/wrk-scripts/reader.lua

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
};

auto id = trx->id();
if(fc::time_point(trx->expiration()) < block_time) {
if(!chain.loadtest_mode() && fc::time_point(trx->expiration()) < block_time) {
send_response(std::static_pointer_cast<fc::exception>(std::make_shared<expired_tx_exception>(FC_LOG_MESSAGE(error, "expired transaction ${id}", ("id", id)))));
return;
}
Expand Down

0 comments on commit e1e0fb1

Please sign in to comment.