1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Keep Lua zone insertion time to a minimum.

No functional changes here. Only the variable retrieval was separated from
filling in the queue items. While with the async queue this makes no
difference, it will be important when the serial queue is used here.
This commit is contained in:
Bartosz Taudul 2021-10-09 15:35:11 +02:00
parent 7527f33d6c
commit fcda1f6a7f
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -204,11 +204,12 @@ static inline int LuaZoneBeginS( lua_State* L )
#endif
SendLuaCallstack( L, depth );
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
lua_Debug dbg;
lua_getstack( L, 1, &dbg );
lua_getinfo( L, "Snl", &dbg );
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src );
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyLfqCommit;
@ -232,13 +233,14 @@ static inline int LuaZoneBeginNS( lua_State* L )
#endif
SendLuaCallstack( L, depth );
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
lua_Debug dbg;
lua_getstack( L, 1, &dbg );
lua_getinfo( L, "Snl", &dbg );
size_t nsz;
const auto name = lua_tolstring( L, 1, &nsz );
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src, name, nsz );
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyLfqCommit;
@ -259,11 +261,12 @@ static inline int LuaZoneBegin( lua_State* L )
if( !GetLuaZoneState().active ) return 0;
#endif
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLoc );
lua_Debug dbg;
lua_getstack( L, 1, &dbg );
lua_getinfo( L, "Snl", &dbg );
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src );
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLoc );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyLfqCommit;
@ -283,13 +286,14 @@ static inline int LuaZoneBeginN( lua_State* L )
if( !GetLuaZoneState().active ) return 0;
#endif
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLoc );
lua_Debug dbg;
lua_getstack( L, 1, &dbg );
lua_getinfo( L, "Snl", &dbg );
size_t nsz;
const auto name = lua_tolstring( L, 1, &nsz );
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src, name, nsz );
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLoc );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyLfqCommit;
@ -333,6 +337,7 @@ static inline int LuaZoneText( lua_State* L )
auto ptr = (char*)tracy_malloc( size );
memcpy( ptr, txt, size );
TracyLfqPrepare( QueueType::ZoneText );
MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
MemWrite( &item->zoneTextFat.size, (uint16_t)size );
@ -357,6 +362,7 @@ static inline int LuaZoneName( lua_State* L )
auto ptr = (char*)tracy_malloc( size );
memcpy( ptr, txt, size );
TracyLfqPrepare( QueueType::ZoneName );
MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
MemWrite( &item->zoneTextFat.size, (uint16_t)size );
@ -374,9 +380,10 @@ static inline int LuaMessage( lua_State* L )
const auto size = strlen( txt );
assert( size < std::numeric_limits<uint16_t>::max() );
TracyLfqPrepare( QueueType::Message );
auto ptr = (char*)tracy_malloc( size );
memcpy( ptr, txt, size );
TracyLfqPrepare( QueueType::Message );
MemWrite( &item->messageFat.time, Profiler::GetTime() );
MemWrite( &item->messageFat.text, (uint64_t)ptr );
MemWrite( &item->messageFat.size, (uint16_t)size );