Skip to content

Commit

Permalink
add logging for constant memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
amitiuttarwar committed Nov 7, 2023
1 parent fcf8401 commit a71105f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,11 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
pnode->AddRef();
m_msgproc->InitializeNode(*pnode, nodeServices);

if(ABCDBool) {
ABCDBool = false;
LogPrintf("ABCD CNode::ConstantMemoryUsage - %d \n", pnode->ConstantMemoryUsage());
}

LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToStringAddrPort());

{
Expand Down
2 changes: 2 additions & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,8 @@ class CConnman
*/
std::atomic_bool m_start_extra_block_relay_peers{false};

bool ABCDBool{true};

/**
* A vector of -bind=<address>:<port>=onion arguments each of which is
* an address and port that are designated for incoming Tor connections.
Expand Down
6 changes: 6 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ class PeerManagerImpl final : public PeerManager
* on extra block-relay-only peers. */
bool m_initial_sync_finished GUARDED_BY(cs_main){false};

bool ABCDBool{true};

/** Protects m_peer_map. This mutex must not be locked while holding a lock
* on any of the mutexes inside a Peer object. */
mutable Mutex m_peer_mutex;
Expand Down Expand Up @@ -1547,6 +1549,10 @@ void PeerManagerImpl::InitializeNode(CNode& node, ServiceFlags our_services)
assert(m_txrequest.Count(nodeid) == 0);
}
PeerRef peer = std::make_shared<Peer>(nodeid, our_services);
if(ABCDBool) {
ABCDBool = false;
LogPrintf("ABCD Peer::ConstantMemoryUsage - %d \n", peer->ConstantMemoryUsage());
}
{
LOCK(m_peer_mutex);
m_peer_map.emplace_hint(m_peer_map.end(), nodeid, peer);
Expand Down

0 comments on commit a71105f

Please sign in to comment.