GXS: remove the profiling probes from the optimised code paths

Requested in review: the instrumentation added by the first commit served
to measure the four defects and verify the fixes, but it should not stay
in the optimised code. The probes are removed from rsdataservice,
rsgenexchange and p3gxschannels; convertMsgItems() loses the two timing
out-parameters that only existed to feed them.

The profiler class itself (gxs/rsgxsprofiler.h) is kept, per review, for
future measurement work. Nothing includes it anymore.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jolavillette 2026-08-01 14:31:30 +02:00
parent 753481e6c5
commit 494ce38f11
4 changed files with 6 additions and 104 deletions

View File

@ -35,7 +35,6 @@
#endif
#include "rsdataservice.h"
#include "rsgxsprofiler.h"
#include "retroshare/rsgxsflags.h"
#include "util/rsstring.h"
@ -1180,11 +1179,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
int resultCount = 0;
#endif
RsGxsProfiler::Timer prof_timer;
uint32_t prof_queries = 0;
uint64_t prof_bytes = 0;
uint32_t prof_msgs = 0;
for(auto mit = reqIds.begin(); mit != reqIds.end(); ++mit)
{
@ -1199,7 +1193,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
RS_STACK_MUTEX(mDbMutex);
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
++prof_queries;
if(c)
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
@ -1244,7 +1237,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
selection += ")";
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, selection, "");
++prof_queries;
if(c)
{
@ -1259,14 +1251,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
resultCount += msgSet.size();
#endif
if(RsGxsProfiler::enabled())
{
prof_msgs += msgSet.size();
for(auto* m: msgSet)
prof_bytes += m->msg.bin_len;
}
msg[grpId] = msgSet;
msgSet.clear();
@ -1276,13 +1260,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
std::cerr << "RsDataService::retrieveNxsMsgs() " << mDbName << ", Requests: " << reqIds.size() << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
#endif
const long prof_ms = prof_timer.ms();
RS_GXS_PROF( prof_ms, "retrieveNxsMsgs db=" << mDbName
<< " groups=" << reqIds.size() << " msgs=" << prof_msgs
<< " sql_queries=" << prof_queries
<< " blob=" << (prof_bytes>>10) << "KB"
<< " in " << prof_ms << "ms" );
return 1;
}
@ -1322,9 +1299,6 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
int resultCount = 0;
#endif
RsGxsProfiler::Timer prof_timer;
uint32_t prof_metas = 0;
for(auto mit(reqIds.begin()); mit != reqIds.end(); ++mit)
{
@ -1392,9 +1366,6 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
std::cerr << mDbName << ": Retrieving Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl;
#endif
}
if(RsGxsProfiler::enabled())
prof_metas += msgMeta[grpId].size();
}
#ifdef RS_DATA_SERVICE_DEBUG_TIME
@ -1402,11 +1373,6 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
std::cerr << "RsDataService::retrieveGxsMsgMetaData() " << mDbName << ", Requests: " << reqIds.size() << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
#endif
const long prof_ms = prof_timer.ms();
RS_GXS_PROF( prof_ms, "retrieveGxsMsgMetaData db=" << mDbName
<< " groups=" << reqIds.size() << " metas=" << prof_metas
<< " in " << prof_ms << "ms" );
return 1;
}

View File

@ -36,7 +36,6 @@
#include "retroshare/rspeers.h"
#include "rsitems/rsnxsitems.h"
#include "rsgixs.h"
#include "rsgxsprofiler.h"
#include "rsgxsutil.h"
#include "rsserver/p3face.h"
#include "retroshare/rsevents.h"
@ -1569,18 +1568,11 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
bool RsGenExchange::getMsgData(uint32_t token, GxsMsgDataMap &msgItems)
{
RsGxsProfiler::Timer prof_timer;
uint32_t prof_msgs = 0;
RS_STACK_MUTEX(mGenMtx) ;
const long prof_lock_ms = prof_timer.lap();
NxsMsgDataResult msgResult;
bool ok = mDataAccess->getMsgData(token, msgResult);
const long prof_fetch_ms = prof_timer.lap();
if(ok)
{
NxsMsgDataResult::iterator mit = msgResult.begin();
@ -1605,7 +1597,6 @@ bool RsGenExchange::getMsgData(uint32_t token, GxsMsgDataMap &msgItems)
{
mItem->meta = *((*vit)->metaData); // get meta info from nxs msg
gxsMsgItems.push_back(mItem);
++prof_msgs;
}
else
{
@ -1624,15 +1615,6 @@ bool RsGenExchange::getMsgData(uint32_t token, GxsMsgDataMap &msgItems)
}
}
const long prof_deser_ms = prof_timer.ms();
const long prof_total_ms = prof_lock_ms + prof_fetch_ms + prof_deser_ms;
RS_GXS_PROF( prof_total_ms, "getMsgData msgs=" << prof_msgs
<< " mGenMtx_wait=" << prof_lock_ms << "ms"
<< " fetch=" << prof_fetch_ms << "ms"
<< " deserialise=" << prof_deser_ms << "ms"
<< " total=" << prof_total_ms << "ms" );
return ok;
}

View File

@ -21,7 +21,6 @@
* *
*******************************************************************************/
#include "services/p3gxschannels.h"
#include "gxs/rsgxsprofiler.h"
#include "rsitems/rsgxschannelitems.h"
#include "util/radix64.h"
#include "util/rsmemory.h"
@ -141,8 +140,7 @@ uint32_t p3GxsChannels::channelsAuthenPolicy()
/** Above this share of a channel's messages, reading them by explicit id costs
* more than scanning the group once, so getChannelAllContent() stops filtering
* out superseded post versions and falls back to reading everything. Tune with
* the RS_GXS_PROFILE output of getChannelAllContent(). */
* out superseded post versions and falls back to reading everything. */
static const uint32_t MAX_READ_RATIO_FOR_VERSION_FILTERING = 66; // percent
static const uint32_t GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
@ -618,11 +616,8 @@ bool p3GxsChannels::groupShareKeys(
bool p3GxsChannels::convertMsgItems( const uint32_t& token,
std::vector<RsGxsChannelPost>& msgs,
std::vector<RsGxsComment>& cmts,
std::vector<RsGxsVote>& vots,
long& getmsgdata_ms, long& convert_ms )
std::vector<RsGxsVote>& vots )
{
RsGxsProfiler::Timer prof_timer;
GxsMsgDataMap msgData;
if(!RsGenExchange::getMsgData(token, msgData))
{
@ -630,8 +625,6 @@ bool p3GxsChannels::convertMsgItems( const uint32_t& token,
return false;
}
getmsgdata_ms = prof_timer.lap();
GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); ++mit)
@ -704,8 +697,6 @@ bool p3GxsChannels::convertMsgItems( const uint32_t& token,
}
}
convert_ms = prof_timer.ms();
return true;
}
@ -717,25 +708,11 @@ bool p3GxsChannels::getPostData( const uint32_t& token, std::vector<RsGxsChannel
RsDbg() << __PRETTY_FUNCTION__ << std::endl;
#endif
long prof_getmsgdata_ms = 0, prof_convert_ms = 0;
if(!convertMsgItems(token, msgs, cmts, vots, prof_getmsgdata_ms, prof_convert_ms))
if(!convertMsgItems(token, msgs, cmts, vots))
return false;
RsGxsProfiler::Timer prof_timer;
sortPosts(msgs,cmts); // stores old versions in the right place.
const long prof_sort_ms = prof_timer.ms();
const long prof_total_ms = prof_getmsgdata_ms + prof_convert_ms + prof_sort_ms;
RS_GXS_PROF( prof_total_ms, "getPostData posts=" << msgs.size()
<< " comments=" << cmts.size() << " votes=" << vots.size()
<< " getMsgData=" << prof_getmsgdata_ms << "ms"
<< " toChannelPost=" << prof_convert_ms << "ms"
<< " sortPosts=" << prof_sort_ms << "ms"
<< " total=" << prof_total_ms << "ms" );
return true;
}
@ -1557,8 +1534,6 @@ bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
std::vector<RsGxsComment>& comments,
std::vector<RsGxsVote>& votes )
{
RsGxsProfiler::Timer prof_timer;
// A channel keeps every version of every edited post. Only the latest
// version of each is ever displayed: sortPosts() used to read them all and
// throw the superseded ones away, after their whole payload -- thumbnail
@ -1612,8 +1587,6 @@ bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
version_to_latest[version_id] = latest_meta.mMsgId;
}
const long prof_versions_ms = prof_timer.lap();
// An empty id set means "every message of the group" to the data store, so
// an empty channel must not be turned into a request at all.
if(wanted_msgs.empty())
@ -1644,11 +1617,7 @@ bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
|| waitToken(token,std::chrono::milliseconds(60000)) != RsTokenService::COMPLETE )
return false;
const long prof_wait_ms = prof_timer.lap();
long prof_getmsgdata_ms = 0, prof_convert_ms = 0;
if(!convertMsgItems(token, posts, comments, votes, prof_getmsgdata_ms, prof_convert_ms))
if(!convertMsgItems(token, posts, comments, votes))
return false;
if(worth_filtering)
@ -1656,19 +1625,6 @@ bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
else
sortPosts(posts, comments);
const long prof_read_ms = prof_timer.ms();
const long prof_total_ms = prof_versions_ms + prof_wait_ms + prof_read_ms;
RS_GXS_PROF( prof_total_ms, "getChannelAllContent grp=" << channelId
<< " metas=" << metas.size()
<< " read_msgs=" << (worth_filtering ? wanted_msgs.size() : metas.size())
<< " skipped_versions=" << (worth_filtering ? (metas.size() - wanted_msgs.size()) : 0)
<< " filtered=" << (worth_filtering ? "yes" : "no")
<< " versions=" << prof_versions_ms << "ms"
<< " token_wait=" << prof_wait_ms << "ms"
<< " read=" << prof_read_ms << "ms"
<< " total=" << prof_total_ms << "ms" );
return true;
}

View File

@ -244,13 +244,11 @@ protected: // made protected because it's all deprecated
/** Turn the message items of a completed request into posts, comments and
* votes. Shared by getPostData() and by getChannelAllContent(), which
* resolves post versions itself. The two long& outputs report timings to
* the caller so that it can emit a single profiling line. */
* resolves post versions itself. */
bool convertMsgItems( const uint32_t& token,
std::vector<RsGxsChannelPost>& msgs,
std::vector<RsGxsComment>& cmts,
std::vector<RsGxsVote>& vots,
long& getmsgdata_ms, long& convert_ms );
std::vector<RsGxsVote>& vots );
/** What resolving a post's version chain on its metas yields, for the one
* version that is actually kept and read from the database. */