tests/testLookupTable.cc \
tests/testLookupTable.h
nodist_tests_testLookupTable_SOURCES = \
- tests/stub_SBufDetailedStats.cc \
base/LookupTable.h \
tests/stub_debug.cc \
tests/stub_libmem.cc
ResolvedPeers.h \
tests/testRock.cc \
tests/testRock.h \
- tests/stub_SBufDetailedStats.cc \
StatCounters.cc \
StatCounters.h \
tests/stub_StatHist.cc \
RemovalPolicy.cc \
RequestFlags.cc \
RequestFlags.h \
- tests/stub_SBufDetailedStats.cc \
StatCounters.cc \
StatCounters.h \
StatHist.cc \
RemovalPolicy.cc \
RequestFlags.cc \
RequestFlags.h \
- tests/stub_SBufDetailedStats.cc \
StatCounters.cc \
StatCounters.h \
StatHist.cc \
RequestFlags.h \
ResolvedPeers.cc \
ResolvedPeers.h \
- tests/stub_SBufDetailedStats.cc \
StatCounters.cc \
StatCounters.h \
tests/stub_StatHist.cc \
RequestFlags.h \
ResolvedPeers.cc \
ResolvedPeers.h \
- tests/stub_SBufDetailedStats.cc \
SquidMath.cc \
SquidMath.h \
StatCounters.cc \
MemBuf.cc \
MemBuf.h \
tests/stub_MemObject.cc \
- tests/stub_SBufDetailedStats.cc \
String.cc \
tests/stub_cache_cf.cc \
cache_cf.h \
MemBuf.h \
Notes.cc \
Notes.h \
- tests/stub_SBufDetailedStats.cc \
SquidString.h \
SquidTime.h \
StatCounters.cc \
RequestFlags.h \
ResolvedPeers.cc \
ResolvedPeers.h \
- tests/stub_SBufDetailedStats.cc \
SquidMath.cc \
SquidMath.h \
StatCounters.cc \
RequestFlags.h \
ResolvedPeers.cc \
ResolvedPeers.h \
- tests/stub_SBufDetailedStats.cc \
SquidMath.cc \
SquidMath.h \
StatCounters.cc \
tests/stub_HelperChildConfig.cc \
tests/stub_MemBuf.cc \
tests/stub_MemObject.cc \
- tests/stub_SBufDetailedStats.cc \
StatHist.cc \
tests/testStatHist.cc \
StatHist.h \
#include "ipc/Messages.h"
#include "ipc/TypedMsgHdr.h"
#include "mgr/Registration.h"
-#include "sbuf/DetailedStats.h"
+#include "sbuf/Stats.h"
#include "SBufStatsAction.h"
+/// creates a new size-at-destruct-time histogram
+static StatHist *
+makeDestructTimeHist() {
+ const auto stats = new StatHist;
+ stats->logInit(100, 30.0, 128000.0);
+ return stats;
+}
+
+/// the SBuf size-at-destruct-time histogram
+static StatHist &
+collectSBufDestructTimeStats()
+{
+ static auto stats = makeDestructTimeHist();
+ return *stats;
+}
+
+/// the MemBlob size-at-destruct-time histogram
+static StatHist &
+collectMemBlobDestructTimeStats()
+{
+ static auto stats = makeDestructTimeHist();
+ return *stats;
+}
+
+/// record the size an SBuf had when it was destructed
+static void
+recordSBufSizeAtDestruct(const size_t sz)
+{
+ collectSBufDestructTimeStats().count(static_cast<double>(sz));
+}
+
+/// record the size a MemBlob had when it was destructed
+static void
+recordMemBlobSizeAtDestruct(const size_t sz)
+{
+ collectMemBlobDestructTimeStats().count(static_cast<double>(sz));
+}
+
SBufStatsAction::SBufStatsAction(const Mgr::CommandPointer &cmd_):
Action(cmd_)
{ } //default constructor is OK for data member
void
SBufStatsAction::RegisterWithCacheManager()
{
+ SBufStats::MemBlobSizeAtDestructRecorder = &recordMemBlobSizeAtDestruct;
+ SBufStats::SBufSizeAtDestructRecorder = &recordSBufSizeAtDestruct;
Mgr::RegisterAction("sbuf", "String-Buffer statistics", &SBufStatsAction::Create, 0, 1);
}
tests/stub_fd.cc \
tests/stub_HelperChildConfig.cc \
tests/stub_libmem.cc \
- tests/stub_SBuf.cc \
tests/STUB.h \
time.cc
pinger_LDADD=\
libicmpcore.la \
$(top_builddir)/src/ip/libip.la \
+ $(top_builddir)/src/sbuf/libsbuf.la \
$(top_builddir)/src/debug/libdebug.la \
$(top_builddir)/src/base/libbase.la \
$(COMPAT_LIB) \
tests/stub_libmem.cc: $(top_srcdir)/src/tests/stub_libmem.cc | tests
cp $(top_srcdir)/src/tests/stub_libmem.cc $@
-tests/stub_SBuf.cc: $(top_srcdir)/src/tests/stub_SBuf.cc | tests
- cp $(top_srcdir)/src/tests/stub_SBuf.cc $@
-
tests/STUB.h: $(top_srcdir)/src/tests/STUB.h | tests
cp $(top_srcdir)/src/tests/STUB.h $@
+++ /dev/null
-/*
- * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#include "squid.h"
-#include "sbuf/DetailedStats.h"
-#include "StatHist.h"
-
-/*
- * Implementation note: the purpose of this construct is to avoid adding
- * external dependencies to the SBuf code
- */
-
-static StatHist *
-newStatHist() {
- StatHist *stats = new StatHist;
- stats->logInit(100, 30.0, 128000.0);
- return stats;
-}
-
-StatHist &
-collectSBufDestructTimeStats()
-{
- static StatHist *stats = newStatHist();
- return *stats;
-}
-
-StatHist &
-collectMemBlobDestructTimeStats()
-{
- static StatHist *stats = newStatHist();
- return *stats;
-}
-
-void
-recordSBufSizeAtDestruct(SBuf::size_type sz)
-{
- collectSBufDestructTimeStats().count(static_cast<double>(sz));
-}
-
-void
-recordMemBlobSizeAtDestruct(SBuf::size_type sz)
-{
- collectMemBlobDestructTimeStats().count(static_cast<double>(sz));
-}
-
+++ /dev/null
-/*
- * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef SQUID_SBUFDETAILEDSTATS_H
-#define SQUID_SBUFDETAILEDSTATS_H
-
-#include "sbuf/SBuf.h"
-
-class StatHist;
-
-/// Record the size a SBuf had when it was destructed
-void recordSBufSizeAtDestruct(SBuf::size_type sz);
-
-/// the SBuf size-at-destruct-time histogram
-StatHist &collectSBufDestructTimeStats();
-
-/// Record the size a MemBlob had when it was destructed
-void recordMemBlobSizeAtDestruct(MemBlob::size_type sz);
-
-/// the MemBlob size-at-destruct-time histogram
-StatHist &collectMemBlobDestructTimeStats();
-
-#endif /* SQUID_SBUFDETAILEDSTATS_H */
-
libsbuf_la_SOURCES = \
Algorithms.cc \
Algorithms.h \
- DetailedStats.cc \
- DetailedStats.h \
List.cc \
List.h \
MemBlob.cc \
#include "squid.h"
#include "base/TextException.h"
#include "debug/Stream.h"
-#include "sbuf/DetailedStats.h"
#include "sbuf/MemBlob.h"
+#include "sbuf/Stats.h"
#include <iostream>
memFreeString(capacity,mem);
Stats.liveBytes -= capacity;
--Stats.live;
- recordMemBlobSizeAtDestruct(capacity);
+ SBufStats::RecordMemBlobSizeAtDestruct(capacity);
debugs(MEMBLOB_DEBUGSECTION,9, "destructed, this="
<< static_cast<void*>(this) << " id=" << id
#include "base/Raw.h"
#include "base/RefCount.h"
#include "debug/Stream.h"
-#include "sbuf/DetailedStats.h"
#include "sbuf/SBuf.h"
#include "util.h"
{
debugs(24, 8, id << " destructed");
--stats.live;
- recordSBufSizeAtDestruct(len_);
+ SBufStats::RecordSBufSizeAtDestruct(len_);
}
MemBlob::Pointer
#include <iostream>
+SBufStats::SizeRecorder SBufStats::SBufSizeAtDestructRecorder = nullptr;
+SBufStats::SizeRecorder SBufStats::MemBlobSizeAtDestructRecorder = nullptr;
+
+void
+SBufStats::RecordSBufSizeAtDestruct(const size_t sz)
+{
+ if (SBufSizeAtDestructRecorder)
+ SBufSizeAtDestructRecorder(sz);
+}
+
+void
+SBufStats::RecordMemBlobSizeAtDestruct(const size_t sz)
+{
+ if (MemBlobSizeAtDestructRecorder)
+ MemBlobSizeAtDestructRecorder(sz);
+}
+
SBufStats&
SBufStats::operator +=(const SBufStats& ss)
{
SBufStats& operator +=(const SBufStats&);
+ /// Record the size a SBuf had when it was destructed
+ static void RecordSBufSizeAtDestruct(size_t);
+
+ /// Record the size a MemBlob had when it was destructed
+ static void RecordMemBlobSizeAtDestruct(size_t);
+
public:
uint64_t alloc = 0; ///<number of calls to SBuf constructors
uint64_t allocCopy = 0; ///<number of calls to SBuf copy-constructor
uint64_t cowJustAlloc = 0; ///< number of cow() calls requiring just a new empty buffer
uint64_t cowAllocCopy = 0; ///< number of cow() calls requiring copying into a new buffer
uint64_t live = 0; ///<number of currently-allocated SBuf
+
+ /// function for collecting detailed size-related statistics
+ using SizeRecorder = void (*)(size_t);
+ /// collects statistics about SBuf sizes at SBuf destruction time
+ static SizeRecorder SBufSizeAtDestructRecorder;
+ /// collects statistics about MemBlob capacity at MemBlob destruction time
+ static SizeRecorder MemBlobSizeAtDestructRecorder;
};
#endif /* SQUID_SBUF_STATS_H */
tests/stub_Port.cc \
tests/stub_redirect.cc \
tests/stub_SBuf.cc \
- tests/stub_SBufDetailedStats.cc \
tests/stub_stat.cc \
tests/stub_StatHist.cc \
tests/stub_stmem.cc \
const SBuf::size_type SBuf::npos;
const SBuf::size_type SBuf::maxSize;
+SBufStats::SizeRecorder SBufStats::SBufSizeAtDestructRecorder = nullptr;
+SBufStats::SizeRecorder SBufStats::MemBlobSizeAtDestructRecorder = nullptr;
std::ostream& SBufStats::dump(std::ostream &os) const STUB_RETVAL(os)
SBufStats& SBufStats::operator +=(const SBufStats&) STUB_RETVAL(*this)
+++ /dev/null
-/*
- * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#include "squid.h"
-#include "sbuf/DetailedStats.h"
-#include "sbuf/SBuf.h"
-#include "StatHist.h"
-
-#define STUB_API "sbuf/DetailedStats.cc"
-#include "tests/STUB.h"
-
-static StatHist s;
-
-void recordSBufSizeAtDestruct(SBuf::size_type) {} // STUB_NOP
-StatHist &collectSBufDestructTimeStats() STUB_RETVAL(s)
-void recordMemBlobSizeAtDestruct(SBuf::size_type) {} // STUB_NOP
-StatHist &collectMemBlobDestructTimeStats() STUB_RETVAL(s)
-