Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed 1.7.0-rc2 #3757

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions src/ripple/nodestore/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ namespace NodeStore {
class Backend
{
public:
template <typename T>
struct Counters
{
std::atomic<std::uint64_t> writeDurationUs{0};
std::atomic<std::uint64_t> writeRetries{0};
std::atomic<std::uint64_t> writesDelayed{0};
std::atomic<std::uint64_t> readRetries{0};
std::atomic<std::uint64_t> readErrors{0};
Counters() = default;
Counters(Counters const&) = default;

template <typename U>
Counters(Counters<U> const& other)
: writeDurationUs(other.writeDurationUs)
, writeRetries(other.writeRetries)
, writesDelayed(other.writesDelayed)
, readRetries(other.readRetries)
, readErrors(other.readErrors)
{
}

T writeDurationUs = {};
T writeRetries = {};
T writesDelayed = {};
T readRetries = {};
T readErrors = {};
};

/** Destroy the backend.
Expand Down Expand Up @@ -143,8 +157,16 @@ class Backend
virtual int
fdRequired() const = 0;

virtual Counters const&
counters() const = 0;
/** Returns read and write stats.

@note The Counters struct is specific to and only used
by CassandraBackend.
*/
virtual std::optional<Counters<std::uint64_t>>
counters() const
{
return std::nullopt;
}

/** Returns true if the backend uses permanent storage. */
bool
Expand Down
20 changes: 11 additions & 9 deletions src/ripple/nodestore/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#ifndef RIPPLE_NODESTORE_DATABASE_H_INCLUDED
#define RIPPLE_NODESTORE_DATABASE_H_INCLUDED

#include <ripple/basics/KeyCache.h>
#include <ripple/basics/TaggedCache.h>
#include <ripple/core/Stoppable.h>
#include <ripple/nodestore/Backend.h>
#include <ripple/nodestore/NodeObject.h>
Expand Down Expand Up @@ -178,9 +176,6 @@ class Database : public Stoppable
virtual void
sweep() = 0;

virtual Backend&
getBackend() = 0;

/** Gather statistics pertaining to read and write activities.
*
* @param obj Json object reference into which to place counters.
Expand Down Expand Up @@ -258,10 +253,6 @@ class Database : public Stoppable
storeSz_ += sz;
}

// Called by the public asyncFetch function
void
asyncFetch(uint256 const& hash, std::uint32_t ledgerSeq);

// Called by the public import function
void
importInternal(Backend& dstBackend, Database& srcDB);
Expand Down Expand Up @@ -322,6 +313,17 @@ class Database : public Stoppable
virtual void
for_each(std::function<void(std::shared_ptr<NodeObject>)> f) = 0;

/** Retrieve backend read and write stats.

@note The Counters struct is specific to and only used
by CassandraBackend.
*/
virtual std::optional<Backend::Counters<std::uint64_t>>
getCounters() const
{
return std::nullopt;
}

void
threadEntry();
};
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/nodestore/backend/CassandraFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ class CassandraBackend : public Backend
return 0;
}

Counters const&
std::optional<Counters<std::uint64_t>>
counters() const override
{
return counters_;
Expand Down
7 changes: 0 additions & 7 deletions src/ripple/nodestore/backend/MemoryFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,6 @@ class MemoryBackend : public Backend
{
return 0;
}

Counters const&
counters() const override
{
static Counters counters;
return counters;
}
};

//------------------------------------------------------------------------------
Expand Down
7 changes: 0 additions & 7 deletions src/ripple/nodestore/backend/NuDBFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,6 @@ class NuDBBackend : public Backend
{
return 3;
}

Counters const&
counters() const override
{
static Counters counters;
return counters;
}
};

//------------------------------------------------------------------------------
Expand Down
7 changes: 0 additions & 7 deletions src/ripple/nodestore/backend/NullFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ class NullBackend : public Backend
return 0;
}

Counters const&
counters() const override
{
static Counters counters;
return counters;
}

private:
};

Expand Down
7 changes: 0 additions & 7 deletions src/ripple/nodestore/backend/RocksDBFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,6 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback
{
return fdRequired_;
}

Counters const&
counters() const override
{
static Counters counters;
return counters;
}
};

//------------------------------------------------------------------------------
Expand Down
15 changes: 9 additions & 6 deletions src/ripple/nodestore/impl/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,15 @@ Database::getCountsJson(Json::Value& obj)
obj[jss::node_written_bytes] = std::to_string(storeSz_);
obj[jss::node_read_bytes] = std::to_string(fetchSz_);
obj[jss::node_reads_duration_us] = std::to_string(fetchDurationUs_);
auto const& c = getBackend().counters();
obj[jss::node_read_errors] = std::to_string(c.readErrors);
obj[jss::node_read_retries] = std::to_string(c.readRetries);
obj[jss::node_write_retries] = std::to_string(c.writeRetries);
obj[jss::node_writes_delayed] = std::to_string(c.writesDelayed);
obj[jss::node_writes_duration_us] = std::to_string(c.writeDurationUs);

if (auto c = getCounters())
{
obj[jss::node_read_errors] = std::to_string(c->readErrors);
obj[jss::node_read_retries] = std::to_string(c->readRetries);
obj[jss::node_write_retries] = std::to_string(c->writeRetries);
obj[jss::node_writes_delayed] = std::to_string(c->writesDelayed);
obj[jss::node_writes_duration_us] = std::to_string(c->writeDurationUs);
}
}

} // namespace NodeStore
Expand Down
13 changes: 7 additions & 6 deletions src/ripple/nodestore/impl/DatabaseNodeImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef RIPPLE_NODESTORE_DATABASENODEIMP_H_INCLUDED
#define RIPPLE_NODESTORE_DATABASENODEIMP_H_INCLUDED

#include <ripple/basics/TaggedCache.h>
#include <ripple/basics/chrono.h>
#include <ripple/nodestore/Database.h>

Expand Down Expand Up @@ -133,12 +134,6 @@ class DatabaseNodeImp : public Database
void
sweep() override;

Backend&
getBackend() override
{
return *backend_;
};

private:
// Cache for database objects. This cache is not always initialized. Check
// for null before using.
Expand All @@ -157,6 +152,12 @@ class DatabaseNodeImp : public Database
{
backend_->for_each(f);
}

std::optional<Backend::Counters<std::uint64_t>>
getCounters() const override
{
return backend_->counters();
}
};

} // namespace NodeStore
Expand Down
7 changes: 7 additions & 0 deletions src/ripple/nodestore/impl/DatabaseRotatingImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ DatabaseRotatingImp::storeLedger(std::shared_ptr<Ledger const> const& srcLedger)
return Database::storeLedger(*srcLedger, backend);
}

void
DatabaseRotatingImp::sync()
{
std::lock_guard lock(mutex_);
writableBackend_->sync();
}

void
DatabaseRotatingImp::store(
NodeObjectType type,
Expand Down
18 changes: 1 addition & 17 deletions src/ripple/nodestore/impl/DatabaseRotatingImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,14 @@ class DatabaseRotatingImp : public DatabaseRotating
override;

void
sync() override
{
writableBackend_->sync();
}
sync() override;

bool
storeLedger(std::shared_ptr<Ledger const> const& srcLedger) override;

void
sweep() override;

Backend&
getBackend() override
{
return *writableBackend_;
}

private:
std::shared_ptr<Backend> writableBackend_;
std::shared_ptr<Backend> archiveBackend_;
Expand All @@ -102,13 +93,6 @@ class DatabaseRotatingImp : public DatabaseRotating
std::shared_ptr<Backend> const& archiveBackend;
};

Backends
getBackends() const
{
std::lock_guard lock(mutex_);
return Backends{writableBackend_, archiveBackend_};
}

std::shared_ptr<NodeObject>
fetchNodeObject(
uint256 const& hash,
Expand Down
6 changes: 0 additions & 6 deletions src/ripple/nodestore/impl/DatabaseShardImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,6 @@ DatabaseShardImp::importShard(
return true;
}

Backend&
DatabaseShardImp::getBackend()
{
return app_.getNodeStore().getBackend();
}

std::shared_ptr<Ledger>
DatabaseShardImp::fetchLedger(uint256 const& hash, std::uint32_t ledgerSeq)
{
Expand Down
3 changes: 0 additions & 3 deletions src/ripple/nodestore/impl/DatabaseShardImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ class DatabaseShardImp : public DatabaseShard
void
sweep() override;

Backend&
getBackend() override;

private:
enum class PathDesignation : uint8_t {
none, // No path specified
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/overlay/impl/OverlayImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ OverlayImpl::Timer::on_timer(error_code ec)
overlay_.sendEndpoints();
overlay_.autoConnect();

if ((overlay_.timer_count_ % Tuning::checkIdlePeers) == 0)
if ((++overlay_.timer_count_ % Tuning::checkIdlePeers) == 0)
overlay_.deleteIdlePeers();

timer_.expires_from_now(std::chrono::seconds(1));
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace BuildInfo {
// and follow the format described at http://semver.org/
//------------------------------------------------------------------------------
// clang-format off
char const* const versionString = "1.7.0-rc1"
char const* const versionString = "1.7.0-rc2"
// clang-format on

#if defined(DEBUG) || defined(SANITIZER)
Expand Down