Skip to content

Commit c403a67

Browse files
committed
Log transaction set acquisition details.
1 parent 397e1cb commit c403a67

File tree

6 files changed

+63
-4
lines changed

6 files changed

+63
-4
lines changed

src/test/app/LedgerReplay_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ struct TestPeerSet : public PeerSet
419419
return emptyPeers;
420420
}
421421

422+
std::string
423+
to_string() const override {
424+
return "";
425+
}
426+
422427
LedgerReplayMsgHandler& local;
423428
LedgerReplayMsgHandler& remote;
424429
std::shared_ptr<TestPeer> dummyPeer;

src/xrpld/app/ledger/detail/TransactionAcquire.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ TransactionAcquire::TransactionAcquire(
5252
app.journal("TransactionAcquire"))
5353
, mHaveRoot(false)
5454
, mPeerSet(std::move(peerSet))
55+
, startTime_(std::chrono::steady_clock::now())
5556
{
5657
mMap = std::make_shared<SHAMap>(
5758
SHAMapType::TRANSACTION, hash, app_.getNodeFamily());
@@ -65,11 +66,21 @@ TransactionAcquire::done()
6566

6667
if (failed_)
6768
{
68-
JLOG(journal_.debug()) << "Failed to acquire TX set " << hash_;
69+
JLOG(journal_.debug()) << "ACQUIRE done Failed to acquire TX set " << hash_
70+
<< " duration " << to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(
71+
std::chrono::steady_clock::now() - startTime_).count()) << "ns total nodes " << nodeCount_
72+
<< " total peers " << mPeerSet->getPeerIds().size()
73+
<< " peers " << mPeerSet->to_string();
74+
6975
}
7076
else
7177
{
72-
JLOG(journal_.debug()) << "Acquired TX set " << hash_;
78+
JLOG(journal_.debug()) << "ACQUIRE done Acquired TX set " << hash_
79+
<< " duration " << to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(
80+
std::chrono::steady_clock::now() - startTime_).count()) << "ns total nodes " << nodeCount_
81+
<< " total peers " << mPeerSet->getPeerIds().size()
82+
<< " peers " << mPeerSet->to_string();
83+
7384
mMap->setImmutable();
7485

7586
uint256 const& hash(hash_);
@@ -101,6 +112,8 @@ TransactionAcquire::onTimer(bool progress, ScopedLockType& psl)
101112
trigger(nullptr);
102113

103114
addPeers(1);
115+
JLOG(journal_.debug()) << "ACQUIRE onTimer " << hash_ << " num peers: " << mPeerSet->getPeerIds().size()
116+
<< " peers " << mPeerSet->to_string();
104117
}
105118

106119
std::weak_ptr<TimeoutCounter>
@@ -137,6 +150,7 @@ TransactionAcquire::trigger(std::shared_ptr<Peer> const& peer)
137150

138151
*(tmGL.add_nodeids()) = SHAMapNodeID().getRawString();
139152
mPeerSet->sendRequest(tmGL, peer);
153+
JLOG(journal_.debug()) << "ACQUIRE trigger " << hash_ << " no root sending to: " << peer.get()->id();
140154
}
141155
else if (!mMap->isValid())
142156
{
@@ -171,6 +185,9 @@ TransactionAcquire::trigger(std::shared_ptr<Peer> const& peer)
171185
*tmGL.add_nodeids() = node.first.getRawString();
172186
}
173187
mPeerSet->sendRequest(tmGL, peer);
188+
nodeCount_ += nodes.size();
189+
JLOG(journal_.debug()) << "ACQUIRE trigger " << hash_ << " need " << nodes.size()
190+
<< " nodes sending to: " << peer.get()->id();
174191
}
175192
}
176193

@@ -225,6 +242,8 @@ TransactionAcquire::takeNodes(
225242

226243
trigger(peer);
227244
progress_ = true;
245+
JLOG(journal_.debug()) << "ACQUIRE takeNodes " << hash_ << " got " << data.size()
246+
<< " nodes from " << peer.get()->id();
228247
return SHAMapAddNode::useful();
229248
}
230249
catch (std::exception const& ex)
@@ -251,6 +270,8 @@ TransactionAcquire::init(int numPeers)
251270
ScopedLockType sl(mtx_);
252271

253272
addPeers(numPeers);
273+
JLOG(journal_.debug()) << "ACQUIRE init " << hash_ << " num peers: " << mPeerSet->getPeerIds().size()
274+
<< " peers " << mPeerSet->to_string();
254275

255276
setTimer(sl);
256277
}

src/xrpld/app/ledger/detail/TransactionAcquire.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <xrpld/app/main/Application.h>
2424
#include <xrpld/overlay/PeerSet.h>
2525
#include <xrpld/shamap/SHAMap.h>
26+
#include <chrono>
27+
#include <sstream>
2628

2729
namespace ripple {
2830

@@ -58,6 +60,10 @@ class TransactionAcquire final
5860
bool mHaveRoot;
5961
std::unique_ptr<PeerSet> mPeerSet;
6062

63+
std::chrono::steady_clock::time_point startTime_;
64+
std::atomic<std::size_t> nodeCount_;
65+
std::stringstream ss_;
66+
6167
void
6268
onTimer(bool progress, ScopedLockType& peerSetLock) override;
6369

src/xrpld/app/main/Application.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ class ApplicationImp : public Application, public BasicApp
258258
if ((cores == 1) || ((config.NODE_SIZE == 0) && (cores == 2)))
259259
return 1;
260260

261-
// Otherwise, prefer two threads.
262-
return 2;
261+
// Otherwise, prefer six threads.
262+
return 6;
263263
#endif
264264
}
265265

src/xrpld/overlay/PeerSet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class PeerSet
7575
/** get the set of ids of previously added peers */
7676
virtual const std::set<Peer::id_t>&
7777
getPeerIds() const = 0;
78+
79+
virtual std::string
80+
to_string() const = 0;
7881
};
7982

8083
class PeerSetBuilder

src/xrpld/overlay/detail/PeerSet.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <xrpld/core/JobQueue.h>
2222
#include <xrpld/overlay/Overlay.h>
2323
#include <xrpld/overlay/PeerSet.h>
24+
#include <sstream>
2425

2526
namespace ripple {
2627

@@ -45,6 +46,9 @@ class PeerSetImpl : public PeerSet
4546
const std::set<Peer::id_t>&
4647
getPeerIds() const override;
4748

49+
std::string
50+
to_string() const override;
51+
4852
private:
4953
// Used in this class for access to boost::asio::io_service and
5054
// ripple::Overlay.
@@ -123,6 +127,20 @@ PeerSetImpl::getPeerIds() const
123127
return peers_;
124128
}
125129

130+
std::string
131+
PeerSetImpl::to_string() const {
132+
std::stringstream ss;
133+
bool first = true;
134+
for (auto const& peer : peers_) {
135+
if (first)
136+
first = false;
137+
else
138+
ss << ',';
139+
ss << peer;
140+
}
141+
return ss.str();
142+
}
143+
126144
class PeerSetBuilderImpl : public PeerSetBuilder
127145
{
128146
public:
@@ -179,6 +197,12 @@ class DummyPeerSet : public PeerSet
179197
return emptyPeers;
180198
}
181199

200+
std::string
201+
to_string() const override {
202+
return "DummyPeerSet to_string should not be called";
203+
}
204+
205+
182206
private:
183207
beast::Journal j_;
184208
};

0 commit comments

Comments
 (0)