Added some UE isnights traces

This commit is contained in:
doterop 2021-03-26 08:50:54 +01:00 committed by bernat
parent e1938e13bd
commit 86efe6f581
6 changed files with 48 additions and 13 deletions

View File

@ -51,6 +51,7 @@ namespace rpc {
}
void SyncRunFor(time_duration duration) {
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
_sync_io_context.reset();
_sync_io_context.run_for(duration.to_chrono());
}

View File

@ -111,6 +111,7 @@ void FCarlaEngine::NotifyEndEpisode()
void FCarlaEngine::OnPreTick(UWorld *, ELevelTick TickType, float DeltaSeconds)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
if (TickType == ELevelTick::LEVELTICK_All)
{
// update frame counter
@ -132,6 +133,7 @@ void FCarlaEngine::OnPreTick(UWorld *, ELevelTick TickType, float DeltaSeconds)
void FCarlaEngine::OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
// tick the recorder/replayer system
if (GetCurrentEpisode())
{

View File

@ -46,6 +46,7 @@ static void WritePixelsToBuffer_Vulkan(
uint32 Offset,
FRHICommandListImmediate &InRHICmdList)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
check(IsInRenderingThread());
auto RenderResource =
static_cast<const FTextureRenderTarget2DResource *>(RenderTarget.Resource);
@ -58,13 +59,19 @@ static void WritePixelsToBuffer_Vulkan(
FIntPoint Rect = RenderResource->GetSizeXY();
// NS: Extra copy here, don't know how to avoid it.
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT("Read Surface");
InRHICmdList.ReadSurfaceData(
Texture,
FIntRect(0, 0, Rect.X, Rect.Y),
gPixels,
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
}
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT("Buffer Copy");
Buffer.copy_from(Offset, gPixels);
}
}
// =============================================================================
// -- FPixelReader -------------------------------------------------------------
@ -130,6 +137,7 @@ void FPixelReader::WritePixelsToBuffer(
FRHICommandListImmediate &InRHICmdList
)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
check(IsInRenderingThread());
if (IsVulkanPlatform(GMaxRHIShaderPlatform) || IsD3DPlatform(GMaxRHIShaderPlatform, false))

View File

@ -101,6 +101,8 @@ void FPixelReader::SendPixelsInRenderThread(TSensor &Sensor)
(
[&Sensor, Stream=Sensor.GetDataStream(Sensor)](auto &InRHICmdList) mutable
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT("FWritePixels_SendPixelsInRenderThread");
/// @todo Can we make sure the sensor is not going to be destroyed?
if (!Sensor.IsPendingKill())
{
@ -113,12 +115,16 @@ void FPixelReader::SendPixelsInRenderThread(TSensor &Sensor)
if(Buffer.data())
{
SCOPE_CYCLE_COUNTER(STAT_CarlaSensorStreamSend);
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT("Stream Send");
Stream.Send(Sensor, std::move(Buffer));
}
}
}
);
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT("FPixelReader::WaitForRenderThreadToFinsih");
// Blocks until the render thread has finished all it's tasks
Sensor.WaitForRenderThreadToFinsih();
}
}

View File

@ -179,7 +179,7 @@ static carla::Buffer FWorldObserver_Serialize(
bool MapChange,
bool PendingLightUpdates)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
using Serializer = carla::sensor::s11n::EpisodeStateSerializer;
using SimulationState = carla::sensor::s11n::EpisodeStateSerializer::SimulationState;
using ActorDynamicState = carla::sensor::data::ActorDynamicState;
@ -243,6 +243,7 @@ void FWorldObserver::BroadcastTick(
bool MapChange,
bool PendingLightUpdates)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
auto AsyncStream = Stream.MakeAsyncDataStream(*this, Episode.GetElapsedGameTime());
auto buffer = FWorldObserver_Serialize(

View File

@ -1664,14 +1664,31 @@ void FCarlaServer::AsyncRun(uint32 NumberOfWorkerThreads)
{
check(Pimpl != nullptr);
/// @todo Define better the number of threads each server gets.
auto RPCThreads = NumberOfWorkerThreads / 2u;
auto StreamingThreads = NumberOfWorkerThreads - RPCThreads;
Pimpl->Server.AsyncRun(std::max(2u, RPCThreads));
Pimpl->StreamingServer.AsyncRun(std::max(2u, StreamingThreads));
int32_t RPCThreads = std::max(2u, NumberOfWorkerThreads / 2u);
int32_t StreamingThreads = std::max(2u, NumberOfWorkerThreads - RPCThreads);
UE_LOG(LogCarla, Error, TEXT("FCommandLine %s"), FCommandLine::Get());
if(!FParse::Value(FCommandLine::Get(), TEXT("-RPCThreads="), RPCThreads))
{
RPCThreads = std::max(2u, NumberOfWorkerThreads / 2u);
}
if(!FParse::Value(FCommandLine::Get(), TEXT("-StreamingThreads="), StreamingThreads))
{
StreamingThreads = std::max(2u, NumberOfWorkerThreads - RPCThreads);
}
UE_LOG(LogCarla, Error, TEXT("FCarlaServer AsyncRun %d, RPCThreads %d, StreamingThreads %d"),
NumberOfWorkerThreads, RPCThreads, StreamingThreads);
Pimpl->Server.AsyncRun(RPCThreads);
Pimpl->StreamingServer.AsyncRun(StreamingThreads);
}
void FCarlaServer::RunSome(uint32 Milliseconds)
{
TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(__FUNCTION__);
Pimpl->Server.SyncRunFor(carla::time_duration::milliseconds(Milliseconds));
}