0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

modules/console: Add bare metal latency as control result.

This commit is contained in:
Jason Volk 2019-09-18 22:58:21 -07:00
parent 217076f147
commit fa698123dc

View file

@ -1352,20 +1352,69 @@ console_cmd__ios(opt &out, const string_view &line)
return true; return true;
} }
#ifdef __x86_64__
bool bool
console_cmd__ios__latency(opt &out, const string_view &line) console_cmd__ios__latency(opt &out, const string_view &line)
{ {
auto returned(0UL); volatile long long returned, executed, started;
auto executed(0UL);
auto started(0UL); // control
{
__sync_synchronize();
asm volatile ("lfence" :::);
started = prof::cycles();
asm volatile ("lfence" :::);
executed = prof::cycles();
asm volatile ("lfence" :::);
returned = prof::cycles();
asm volatile ("lfence" :::);
}
out
<< "bare send: " << (executed - started) << std::endl
<< "bare recv: " << (returned - executed) << std::endl
<< "bare rtt: " << (returned - started) << std::endl
<< std::endl;
// control
{
__sync_synchronize();
started = prof::x86::rdtscp();
asm volatile ("lfence" :::);
executed = prof::x86::rdtscp();
asm volatile ("lfence" :::);
returned = prof::x86::rdtscp();
asm volatile ("lfence" :::);
}
out
<< "tscp send: " << (executed - started) << std::endl
<< "tscp recv: " << (returned - executed) << std::endl
<< "tscp rtt: " << (returned - started) << std::endl
<< std::endl;
//
// ios::dispatch
//
{ {
__sync_synchronize();
asm volatile ("lfence" :::);
started = prof::cycles(); started = prof::cycles();
asm volatile ("lfence" :::);
ios::dispatch(ios::synchronous, [&executed] ios::dispatch(ios::synchronous, [&executed]
{ {
__sync_synchronize();
asm volatile ("lfence" :::);
executed = prof::cycles(); executed = prof::cycles();
asm volatile ("lfence" :::);
}); });
__sync_synchronize();
asm volatile ("lfence" :::);
returned = prof::cycles(); returned = prof::cycles();
asm volatile ("lfence" :::);
} }
out out
@ -1374,28 +1423,28 @@ console_cmd__ios__latency(opt &out, const string_view &line)
<< "disp rtt: " << (returned - started) << std::endl << "disp rtt: " << (returned - started) << std::endl
<< std::endl; << std::endl;
{ //
started = prof::cycles(); // ios::defer
ios::post(ios::synchronous, [&executed] //
{
executed = prof::cycles();
});
returned = prof::cycles();
}
out
<< "post send: " << (executed - started) << std::endl
<< "post recv: " << (returned - executed) << std::endl
<< "post rtt: " << (returned - started) << std::endl
<< std::endl;
{ {
__sync_synchronize();
asm volatile ("lfence" :::);
started = prof::cycles(); started = prof::cycles();
asm volatile ("lfence" :::);
ios::defer(ios::synchronous, [&executed] ios::defer(ios::synchronous, [&executed]
{ {
__sync_synchronize();
asm volatile ("lfence" :::);
executed = prof::cycles(); executed = prof::cycles();
asm volatile ("lfence" :::);
}); });
__sync_synchronize();
asm volatile ("lfence" :::);
returned = prof::cycles(); returned = prof::cycles();
asm volatile ("lfence" :::);
} }
out out
@ -1404,9 +1453,39 @@ console_cmd__ios__latency(opt &out, const string_view &line)
<< "defer rtt: " << (returned - started) << std::endl << "defer rtt: " << (returned - started) << std::endl
<< std::endl; << std::endl;
//
// ios::post
//
{
__sync_synchronize();
asm volatile ("lfence" :::);
started = prof::cycles();
asm volatile ("lfence" :::);
ios::post(ios::synchronous, [&executed]
{
__sync_synchronize();
asm volatile ("lfence" :::);
executed = prof::cycles();
asm volatile ("lfence" :::);
});
__sync_synchronize();
asm volatile ("lfence" :::);
returned = prof::cycles();
asm volatile ("lfence" :::);
}
out
<< "post send: " << (executed - started) << std::endl
<< "post recv: " << (returned - executed) << std::endl
<< "post rtt: " << (returned - started) << std::endl
<< std::endl;
return true; return true;
} }
#endif
// //
// aio // aio