Remove unused code & refactor and simplify event load timing

This commit is contained in:
Nik Bougalis
2017-01-17 15:20:24 -08:00
parent 8345475bc3
commit 15a30c745c
19 changed files with 97 additions and 665 deletions

View File

@@ -1558,11 +1558,6 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\beast\core\PlatformConfig.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\beast\core\RelativeTime.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\beast\core\RelativeTime.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\beast\core\SemanticVersion.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>

View File

@@ -2100,12 +2100,6 @@
<ClInclude Include="..\..\src\ripple\beast\core\PlatformConfig.h">
<Filter>ripple\beast\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\beast\core\RelativeTime.cpp">
<Filter>ripple\beast\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\beast\core\RelativeTime.h">
<Filter>ripple\beast\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\beast\core\SemanticVersion.cpp">
<Filter>ripple\beast\core</Filter>
</ClCompile>

View File

@@ -401,7 +401,8 @@ private:
void doWrite ()
{
LoadEvent::autoptr event (app_.getJobQueue ().getLoadEventAP (jtDISK, "ValidationWrite"));
auto event = app_.getJobQueue ().getLoadEventAP (jtDISK, "ValidationWrite");
std::string insVal ("INSERT INTO Validations "
"(InitialSeq, LedgerSeq, LedgerHash,NodePubKey,SignTime,RawData) "
"VALUES (:initialSeq, :ledgerSeq, :ledgerHash,:nodePubKey,:signTime,:rawData);");

View File

@@ -181,7 +181,7 @@ private:
bool convert_all_;
std::shared_ptr <ReadView const> mLedger;
LoadEvent::pointer m_loadEvent;
std::shared_ptr<LoadEvent> m_loadEvent;
std::shared_ptr<RippleLineCache> mRLCache;
STPathElement mSource;

View File

@@ -130,8 +130,8 @@ std::string DoSustain ()
while (checkChild (pChild, 0))
sleep(sleepBetweenWaits);
auto pc = std::to_string (pChild);
rename ("core", ("core." + pc).c_str ());
(void)rename ("core",
("core." + std::to_string(pChild)).c_str());
}
}
}

View File

@@ -1,291 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Portions of this file are from JUCE.
Copyright (c) 2013 - Raw Material Software Ltd.
Please visit http://www.juce.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/beast/core/RelativeTime.h>
namespace beast {
RelativeTime::RelativeTime (const RelativeTime::value_type secs) noexcept
: numSeconds (secs)
{
}
RelativeTime::RelativeTime (const RelativeTime& other) noexcept
: numSeconds (other.numSeconds)
{
}
RelativeTime::~RelativeTime() noexcept {}
//==============================================================================
RelativeTime RelativeTime::milliseconds (const int milliseconds) noexcept
{
return RelativeTime (milliseconds * 0.001);
}
RelativeTime RelativeTime::milliseconds (const std::int64_t milliseconds) noexcept
{
return RelativeTime (milliseconds * 0.001);
}
RelativeTime RelativeTime::seconds (RelativeTime::value_type s) noexcept
{
return RelativeTime (s);
}
RelativeTime RelativeTime::minutes (const RelativeTime::value_type numberOfMinutes) noexcept
{
return RelativeTime (numberOfMinutes * 60.0);
}
RelativeTime RelativeTime::hours (const RelativeTime::value_type numberOfHours) noexcept
{
return RelativeTime (numberOfHours * (60.0 * 60.0));
}
RelativeTime RelativeTime::days (const RelativeTime::value_type numberOfDays) noexcept
{
return RelativeTime (numberOfDays * (60.0 * 60.0 * 24.0));
}
RelativeTime RelativeTime::weeks (const RelativeTime::value_type numberOfWeeks) noexcept
{
return RelativeTime (numberOfWeeks * (60.0 * 60.0 * 24.0 * 7.0));
}
//==============================================================================
std::int64_t RelativeTime::inMilliseconds() const noexcept
{
return (std::int64_t) (numSeconds * 1000.0);
}
RelativeTime::value_type RelativeTime::inMinutes() const noexcept
{
return numSeconds / 60.0;
}
RelativeTime::value_type RelativeTime::inHours() const noexcept
{
return numSeconds / (60.0 * 60.0);
}
RelativeTime::value_type RelativeTime::inDays() const noexcept
{
return numSeconds / (60.0 * 60.0 * 24.0);
}
RelativeTime::value_type RelativeTime::inWeeks() const noexcept
{
return numSeconds / (60.0 * 60.0 * 24.0 * 7.0);
}
//==============================================================================
RelativeTime& RelativeTime::operator= (const RelativeTime& other) noexcept { numSeconds = other.numSeconds; return *this; }
RelativeTime RelativeTime::operator+= (RelativeTime t) noexcept
{
numSeconds += t.numSeconds; return *this;
}
RelativeTime RelativeTime::operator-= (RelativeTime t) noexcept
{
numSeconds -= t.numSeconds; return *this;
}
RelativeTime RelativeTime::operator+= (const RelativeTime::value_type secs) noexcept
{
numSeconds += secs; return *this;
}
RelativeTime RelativeTime::operator-= (const RelativeTime::value_type secs) noexcept
{
numSeconds -= secs; return *this;
}
RelativeTime operator+ (RelativeTime t1, RelativeTime t2) noexcept
{
return t1 += t2;
}
RelativeTime operator- (RelativeTime t1, RelativeTime t2) noexcept
{
return t1 -= t2;
}
bool operator== (RelativeTime t1, RelativeTime t2) noexcept
{
return t1.inSeconds() == t2.inSeconds();
}
bool operator!= (RelativeTime t1, RelativeTime t2) noexcept
{
return t1.inSeconds() != t2.inSeconds();
}
bool operator> (RelativeTime t1, RelativeTime t2) noexcept
{
return t1.inSeconds() > t2.inSeconds();
}
bool operator< (RelativeTime t1, RelativeTime t2) noexcept
{
return t1.inSeconds() < t2.inSeconds();
}
bool operator>= (RelativeTime t1, RelativeTime t2) noexcept
{
return t1.inSeconds() >= t2.inSeconds();
}
bool operator<= (RelativeTime t1, RelativeTime t2) noexcept
{
return t1.inSeconds() <= t2.inSeconds();
}
}
#if BEAST_WINDOWS
#include <windows.h>
namespace beast {
namespace detail {
static double monotonicCurrentTimeInSeconds()
{
return GetTickCount64() / 1000.0;
}
}
}
#elif BEAST_MAC || BEAST_IOS
#include <mach/mach_time.h>
#include <mach/mach.h>
namespace beast {
namespace detail {
static double monotonicCurrentTimeInSeconds()
{
struct StaticInitializer
{
StaticInitializer ()
{
double numerator;
double denominator;
mach_timebase_info_data_t timebase;
(void) mach_timebase_info (&timebase);
if (timebase.numer % 1000000 == 0)
{
numerator = timebase.numer / 1000000.0;
denominator = timebase.denom * 1000.0;
}
else
{
numerator = timebase.numer;
// VFALCO NOTE I don't understand this code
//denominator = timebase.denom * (std::uint64_t) 1000000 * 1000.0;
denominator = timebase.denom * 1000000000.0;
}
ratio = numerator / denominator;
}
double ratio;
};
static StaticInitializer const data;
return mach_absolute_time() * data.ratio;
}
}
}
#else
#include <time.h>
namespace beast {
namespace detail {
static double monotonicCurrentTimeInSeconds()
{
timespec t;
clock_gettime (CLOCK_MONOTONIC, &t);
return t.tv_sec + t.tv_nsec / 1000000000.0;
}
}
}
#endif
namespace beast {
namespace detail {
// Records and returns the time from process startup
static double getStartupTime()
{
struct StaticInitializer
{
StaticInitializer ()
{
when = beast::detail::monotonicCurrentTimeInSeconds();
}
double when;
};
static StaticInitializer const data;
return data.when;
}
// Used to call getStartupTime as early as possible
struct StartupTimeStaticInitializer
{
StartupTimeStaticInitializer ()
{
getStartupTime();
}
};
static StartupTimeStaticInitializer startupTimeStaticInitializer;
}
RelativeTime RelativeTime::fromStartup ()
{
return RelativeTime (
detail::monotonicCurrentTimeInSeconds() - detail::getStartupTime());
}
}

View File

@@ -1,190 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Portions of this file are from JUCE.
Copyright (c) 2013 - Raw Material Software Ltd.
Please visit http://www.juce.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CHRONO_RELATIVETIME_H_INCLUDED
#define BEAST_CHRONO_RELATIVETIME_H_INCLUDED
#include <ripple/beast/core/Config.h>
#include <string>
#include <sstream>
namespace beast {
//==============================================================================
/** A relative measure of time.
The time is stored as a number of seconds, at double-precision floating
point accuracy, and may be positive or negative.
If you need an absolute time, (i.e. a date + time), see the Time class.
*/
class RelativeTime
{
public:
//==============================================================================
/** The underlying data type used by RelativeTime.
If you need to get to the underlying time and manipulate it
you can use this to declare a type that is guaranteed to
work cleanly.
*/
using value_type = double;
//==============================================================================
/** Creates a RelativeTime.
@param seconds the number of seconds, which may be +ve or -ve.
@see milliseconds, minutes, hours, days, weeks
*/
explicit RelativeTime (value_type seconds = 0.0) noexcept;
/** Copies another relative time. */
RelativeTime (const RelativeTime& other) noexcept;
/** Copies another relative time. */
RelativeTime& operator= (const RelativeTime& other) noexcept;
/** Destructor. */
~RelativeTime() noexcept;
bool isZero() const
{ return numSeconds == 0; }
bool isNotZero() const
{ return numSeconds != 0; }
/** Returns the amount of time since the process was started. */
static RelativeTime fromStartup ();
//==============================================================================
/** Creates a new RelativeTime object representing a number of milliseconds.
@see seconds, minutes, hours, days, weeks
*/
static RelativeTime milliseconds (int milliseconds) noexcept;
/** Creates a new RelativeTime object representing a number of milliseconds.
@see seconds, minutes, hours, days, weeks
*/
static RelativeTime milliseconds (std::int64_t milliseconds) noexcept;
/** Creates a new RelativeTime object representing a number of seconds.
@see milliseconds, minutes, hours, days, weeks
*/
static RelativeTime seconds (value_type seconds) noexcept;
/** Creates a new RelativeTime object representing a number of minutes.
@see milliseconds, hours, days, weeks
*/
static RelativeTime minutes (value_type numberOfMinutes) noexcept;
/** Creates a new RelativeTime object representing a number of hours.
@see milliseconds, minutes, days, weeks
*/
static RelativeTime hours (value_type numberOfHours) noexcept;
/** Creates a new RelativeTime object representing a number of days.
@see milliseconds, minutes, hours, weeks
*/
static RelativeTime days (value_type numberOfDays) noexcept;
/** Creates a new RelativeTime object representing a number of weeks.
@see milliseconds, minutes, hours, days
*/
static RelativeTime weeks (value_type numberOfWeeks) noexcept;
//==============================================================================
/** Returns the number of milliseconds this time represents.
@see milliseconds, inSeconds, inMinutes, inHours, inDays, inWeeks
*/
std::int64_t inMilliseconds() const noexcept;
/** Returns the number of seconds this time represents.
@see inMilliseconds, inMinutes, inHours, inDays, inWeeks
*/
value_type inSeconds() const noexcept { return numSeconds; }
/** Returns the number of minutes this time represents.
@see inMilliseconds, inSeconds, inHours, inDays, inWeeks
*/
value_type inMinutes() const noexcept;
/** Returns the number of hours this time represents.
@see inMilliseconds, inSeconds, inMinutes, inDays, inWeeks
*/
value_type inHours() const noexcept;
/** Returns the number of days this time represents.
@see inMilliseconds, inSeconds, inMinutes, inHours, inWeeks
*/
value_type inDays() const noexcept;
/** Returns the number of weeks this time represents.
@see inMilliseconds, inSeconds, inMinutes, inHours, inDays
*/
value_type inWeeks() const noexcept;
template <typename Number>
RelativeTime operator+ (Number seconds) const noexcept
{ return RelativeTime (numSeconds + seconds); }
template <typename Number>
RelativeTime operator- (Number seconds) const noexcept
{ return RelativeTime (numSeconds - seconds); }
/** Adds another RelativeTime to this one. */
RelativeTime operator+= (RelativeTime timeToAdd) noexcept;
/** Subtracts another RelativeTime from this one. */
RelativeTime operator-= (RelativeTime timeToSubtract) noexcept;
/** Adds a number of seconds to this time. */
RelativeTime operator+= (value_type secondsToAdd) noexcept;
/** Subtracts a number of seconds from this time. */
RelativeTime operator-= (value_type secondsToSubtract) noexcept;
private:
value_type numSeconds;
};
//------------------------------------------------------------------------------
bool operator== (RelativeTime t1, RelativeTime t2) noexcept;
bool operator!= (RelativeTime t1, RelativeTime t2) noexcept;
bool operator> (RelativeTime t1, RelativeTime t2) noexcept;
bool operator< (RelativeTime t1, RelativeTime t2) noexcept;
bool operator>= (RelativeTime t1, RelativeTime t2) noexcept;
bool operator<= (RelativeTime t1, RelativeTime t2) noexcept;
//------------------------------------------------------------------------------
/** Adds two RelativeTimes together. */
RelativeTime operator+ (RelativeTime t1, RelativeTime t2) noexcept;
/** Subtracts two RelativeTimes. */
RelativeTime operator- (RelativeTime t1, RelativeTime t2) noexcept;
}
#endif

View File

@@ -192,7 +192,6 @@
#include <ripple/beast/core/SemanticVersion.cpp>
#include <ripple/beast/core/SystemStats.cpp>
#include <ripple/beast/core/RelativeTime.cpp>
#include <ripple/beast/core/Thread.cpp>
#include <ripple/beast/core/Time.cpp>
#include <ripple/beast/core/WaitableEvent.cpp>

View File

@@ -142,7 +142,7 @@ private:
JobType mType;
std::uint64_t mJobIndex;
std::function <void (Job&)> mJob;
LoadEvent::pointer m_loadEvent;
std::shared_ptr<LoadEvent> m_loadEvent;
std::string mName;
clock_type::time_point m_queue_time;
};

View File

@@ -150,11 +150,13 @@ public:
// VFALCO TODO Rename these to newLoadEventMeasurement or something similar
// since they create the object.
LoadEvent::pointer getLoadEvent (JobType t, std::string const& name);
std::shared_ptr<LoadEvent>
getLoadEvent (JobType t, std::string const& name);
// VFALCO TODO Why do we need two versions, one which returns a shared
// pointer and the other which returns an autoptr?
LoadEvent::autoptr getLoadEventAP (JobType t, std::string const& name);
std::unique_ptr <LoadEvent>
getLoadEventAP (JobType t, std::string const& name);
/** Add multiple load events.
*/

View File

@@ -20,8 +20,9 @@
#ifndef RIPPLE_CORE_LOADEVENT_H_INCLUDED
#define RIPPLE_CORE_LOADEVENT_H_INCLUDED
#include <ripple/beast/core/RelativeTime.h>
#include <chrono>
#include <memory>
#include <string>
namespace ripple {
@@ -34,52 +35,54 @@ class LoadMonitor;
//
class LoadEvent
{
public:
// VFALCO NOTE Why are these shared pointers? Wouldn't there be a
// piece of lifetime-managed calling code that can simply own
// the object?
//
// Why both kinds of containers?
//
using pointer = std::shared_ptr <LoadEvent>;
using autoptr = std::unique_ptr <LoadEvent>;
public:
// VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
LoadEvent (LoadMonitor& monitor,
std::string const& name,
bool shouldStart);
LoadEvent(LoadEvent const&) = delete;
~LoadEvent ();
std::string const& name () const;
double getSecondsWaiting() const;
double getSecondsRunning() const;
double getSecondsTotal() const;
std::string const&
name () const;
// The time spent waiting.
std::chrono::steady_clock::duration
waitTime() const;
// The time spent running.
std::chrono::steady_clock::duration
runTime() const;
// VFALCO TODO rename this to setName () or setLabel ()
void reName (std::string const& name);
// Start the measurement. The constructor calls this automatically if
// shouldStart is true. If the operation is aborted, start() can be
// called again later.
//
// Start the measurement. If already started, then
// restart, assigning the elapsed time to the "waiting"
// state.
void start ();
// Stops the measurement and reports the results. The time reported is
// measured from the last call to start.
//
// Stop the measurement and report the results. The
// time reported is measured from the last call to
// start.
void stop ();
private:
LoadMonitor& m_loadMonitor;
bool m_isRunning;
std::string m_name;
// VFALCO TODO Replace these with chrono
beast::RelativeTime m_timeStopped;
beast::RelativeTime m_timeStarted;
double m_secondsWaiting;
double m_secondsRunning;
LoadMonitor& monitor_;
// Represents our current state
bool running_;
// The name associated with this event, if any.
std::string name_;
// Represents the time we last transitioned states
std::chrono::steady_clock::time_point mark_;
// The time we spent waiting and running respectively
std::chrono::steady_clock::duration timeWaiting_;
std::chrono::steady_clock::duration timeRunning_;
};
} // ripple

View File

@@ -37,10 +37,6 @@ public:
explicit
LoadMonitor (beast::Journal j);
void addCount ();
void addLatency (int latency);
void addLoadSample (LoadEvent const& sample);
void addSamples (int count, std::chrono::milliseconds latency);
@@ -65,13 +61,9 @@ public:
bool isOver ();
private:
static std::string printElapsed (double seconds);
void update ();
using LockType = std::mutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
std::mutex mutex_;
std::uint64_t mCounts;
int mLatencyEvents;

View File

@@ -189,7 +189,7 @@ JobQueue::setThreadCount (int c, bool const standaloneMode)
m_workers.setNumberOfThreads (c);
}
LoadEvent::pointer
std::shared_ptr<LoadEvent>
JobQueue::getLoadEvent (JobType t, std::string const& name)
{
JobDataMap::iterator iter (m_jobData.find (t));
@@ -202,7 +202,7 @@ JobQueue::getLoadEvent (JobType t, std::string const& name)
std::ref (iter-> second.load ()), name, true);
}
LoadEvent::autoptr
std::unique_ptr<LoadEvent>
JobQueue::getLoadEventAP (JobType t, std::string const& name)
{
JobDataMap::iterator iter (m_jobData.find (t));

View File

@@ -21,79 +21,74 @@
#include <ripple/core/LoadEvent.h>
#include <ripple/core/LoadMonitor.h>
#include <cassert>
#include <iomanip>
namespace ripple {
LoadEvent::LoadEvent (LoadMonitor& monitor, std::string const& name, bool shouldStart)
: m_loadMonitor (monitor)
, m_isRunning (false)
, m_name (name)
, m_timeStopped (beast::RelativeTime::fromStartup())
, m_secondsWaiting (0)
, m_secondsRunning (0)
LoadEvent::LoadEvent (
LoadMonitor& monitor,
std::string const& name,
bool shouldStart)
: monitor_ (monitor)
, running_ (shouldStart)
, name_ (name)
, mark_ { std::chrono::steady_clock::now() }
, timeWaiting_ {}
, timeRunning_ {}
{
if (shouldStart)
start ();
}
LoadEvent::~LoadEvent ()
{
if (m_isRunning)
if (running_)
stop ();
}
std::string const& LoadEvent::name () const
{
return m_name;
return name_;
}
double LoadEvent::getSecondsWaiting() const
std::chrono::steady_clock::duration
LoadEvent::waitTime() const
{
return m_secondsWaiting;
return timeWaiting_;
}
double LoadEvent::getSecondsRunning() const
std::chrono::steady_clock::duration
LoadEvent::runTime() const
{
return m_secondsRunning;
}
double LoadEvent::getSecondsTotal() const
{
return m_secondsWaiting + m_secondsRunning;
return timeRunning_;
}
void LoadEvent::reName (std::string const& name)
{
m_name = name;
name_ = name;
}
void LoadEvent::start ()
{
beast::RelativeTime const currentTime (beast::RelativeTime::fromStartup());
auto const now = std::chrono::steady_clock::now();
// If we already called start, this call will replace the previous one.
if (m_isRunning)
{
m_secondsWaiting += (currentTime - m_timeStarted).inSeconds();
}
else
{
m_secondsWaiting += (currentTime - m_timeStopped).inSeconds();
m_isRunning = true;
}
m_timeStarted = currentTime;
// If we had already called start, this call will
// replace the previous one. Any time accumulated will
// be counted as "waiting".
timeWaiting_ += now - mark_;
mark_ = now;
running_ = true;
}
void LoadEvent::stop ()
{
assert (m_isRunning);
assert (running_);
m_timeStopped = beast::RelativeTime::fromStartup();
m_secondsRunning += (m_timeStopped - m_timeStarted).inSeconds();
auto const now = std::chrono::steady_clock::now();
m_isRunning = false;
m_loadMonitor.addLoadSample (*this);
timeRunning_ += now - mark_;
mark_ = now;
running_ = false;
monitor_.addLoadSample (*this);
}
} // ripple

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/UptimeTimer.h>
#include <ripple/beast/clock/chrono_util.h>
#include <ripple/core/LoadMonitor.h>
namespace ripple {
@@ -66,9 +67,6 @@ LoadMonitor::LoadMonitor (beast::Journal j)
void LoadMonitor::update ()
{
int now = UptimeTimer::getInstance ().getElapsedSeconds ();
// VFALCO TODO stop returning from the middle of functions.
if (now == mLastUpdate) // current
return;
@@ -104,73 +102,23 @@ void LoadMonitor::update ()
while (mLastUpdate < now);
}
void LoadMonitor::addCount ()
void LoadMonitor::addLoadSample (LoadEvent const& s)
{
ScopedLockType sl (mLock);
using namespace std::chrono;
update ();
++mCounts;
}
auto const total = s.runTime() + s.waitTime();
// Don't include "jitter" as part of the latency
auto const latency = total < 2ms ? 0ms : round<milliseconds>(total);
void LoadMonitor::addLatency (int latency)
{
// VFALCO NOTE Why does 1 become 0?
if (latency == 1)
latency = 0;
ScopedLockType sl (mLock);
update ();
++mLatencyEvents;
mLatencyMSAvg += latency;
mLatencyMSPeak += latency;
// Units are quarters of a millisecond
int const latencyPeak = mLatencyEvents * latency * 4;
if (mLatencyMSPeak < latencyPeak)
mLatencyMSPeak = latencyPeak;
}
std::string LoadMonitor::printElapsed (double seconds)
{
std::stringstream ss;
ss << (std::size_t (seconds * 1000 + 0.5)) << " ms";
return ss.str();
}
void LoadMonitor::addLoadSample (LoadEvent const& sample)
{
std::string const& name (sample.name());
beast::RelativeTime const latency (sample.getSecondsTotal());
if (latency.inSeconds() > 0.5)
if (latency > 500ms)
{
auto mj = latency.inSeconds() > 1.0 ? j_.warn() : j_.info();
JLOG (mj)
<< "Job: " << name << " ExecutionTime: " << printElapsed (sample.getSecondsRunning()) <<
" WaitingTime: " << printElapsed (sample.getSecondsWaiting());
auto mj = (latency > 1s) ? j_.warn() : j_.info();
JLOG (mj) << "Job: " << s.name() <<
" run: " << round<milliseconds>(s.runTime()).count() << "ms" <<
" wait: " << round<milliseconds>(s.waitTime()).count() << "ms";
}
// VFALCO NOTE Why does 1 become 0?
std::size_t latencyMilliseconds (latency.inMilliseconds());
if (latencyMilliseconds == 1)
latencyMilliseconds = 0;
ScopedLockType sl (mLock);
update ();
++mCounts;
++mLatencyEvents;
mLatencyMSAvg += latencyMilliseconds;
mLatencyMSPeak += latencyMilliseconds;
// VFALCO NOTE Why are we multiplying by 4?
int const latencyPeak = mLatencyEvents * latencyMilliseconds * 4;
if (mLatencyMSPeak < latencyPeak)
mLatencyMSPeak = latencyPeak;
addSamples (1, latency);
}
/* Add multiple samples
@@ -179,7 +127,7 @@ void LoadMonitor::addLoadSample (LoadEvent const& sample)
*/
void LoadMonitor::addSamples (int count, std::chrono::milliseconds latency)
{
ScopedLockType sl (mLock);
std::lock_guard<std::mutex> sl (mutex_);
update ();
mCounts += count;
@@ -207,7 +155,7 @@ bool LoadMonitor::isOverTarget (std::uint64_t avg, std::uint64_t peak)
bool LoadMonitor::isOver ()
{
ScopedLockType sl (mLock);
std::lock_guard<std::mutex> sl (mutex_);
update ();
@@ -221,7 +169,7 @@ LoadMonitor::Stats LoadMonitor::getStats ()
{
Stats stats;
ScopedLockType sl (mLock);
std::lock_guard<std::mutex> sl (mutex_);
update ();

View File

@@ -79,6 +79,7 @@ public:
cacheTargetSize, cacheTargetSeconds)
, m_readShut (false)
, m_readGen (0)
, fdlimit_ (0)
, m_storeCount (0)
, m_fetchTotalCount (0)
, m_fetchHitCount (0)

View File

@@ -494,16 +494,7 @@ nodeobject_compress (void const* in,
std::pair<void const*, std::size_t> result;
switch(type)
{
case 0: // uncompressed
{
result.second = vn + in_size;
std::uint8_t* p = reinterpret_cast<
std::uint8_t*>(bf(result.second));
result.first = p;
std::memcpy(p, vi.data(), vn);
std::memcpy(p + vn, in, in_size);
break;
}
// case 0 was uncompressed data; we always compress now.
case 1: // lz4
{
std::uint8_t* p;

View File

@@ -103,8 +103,6 @@ private:
AppBundle (beast::unit_test::suite& suite,
std::unique_ptr<Config> config);
AppBundle (beast::unit_test::suite& suite,
Application* app_);
~AppBundle();
};

View File

@@ -151,12 +151,6 @@ public:
//------------------------------------------------------------------------------
Env::AppBundle::AppBundle(beast::unit_test::suite&,
Application* app_)
: app(app_)
{
}
Env::AppBundle::AppBundle(beast::unit_test::suite& suite,
std::unique_ptr<Config> config)
{