SBufStatsAction.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#include "squid.h"
10#include "base/PackableStream.h"
11#include "ipc/Messages.h"
12#include "ipc/TypedMsgHdr.h"
13#include "mgr/Registration.h"
14#include "sbuf/Stats.h"
15#include "SBufStatsAction.h"
16
18static StatHist *
20 const auto stats = new StatHist;
21 stats->logInit(100, 30.0, 128000.0);
22 return stats;
23}
24
26static StatHist &
28{
29 static auto stats = makeDestructTimeHist();
30 return *stats;
31}
32
34static StatHist &
36{
37 static auto stats = makeDestructTimeHist();
38 return *stats;
39}
40
42static void
44{
45 collectSBufDestructTimeStats().count(static_cast<double>(sz));
46}
47
49static void
51{
52 collectMemBlobDestructTimeStats().count(static_cast<double>(sz));
53}
54
56 Action(cmd_)
57{ } //default constructor is OK for data member
58
61{
62 return new SBufStatsAction(cmd);
63}
64
65void
67{
68 sbdata += dynamic_cast<const SBufStatsAction&>(action).sbdata;
69 mbdata += dynamic_cast<const SBufStatsAction&>(action).mbdata;
72}
73
74void
76{
81}
82
83static void
84statHistSBufDumper(StoreEntry * sentry, int, double val, double size, int count)
85{
86 if (count == 0)
87 return;
88 storeAppendPrintf(sentry, "\t%d-%d\t%d\n", static_cast<int>(val), static_cast<int>(val+size), count);
89}
90
91void
93{
94 PackableStream ses(*entry);
95 ses << "\n\n\nThese statistics are experimental; their format and contents "
96 "should not be relied upon, they are bound to change as "
97 "the SBuf feature is evolved\n";
98 sbdata.dump(ses);
99 mbdata.dump(ses);
100 ses << "\n";
101 ses << "SBuf size distribution at destruct time:\n";
103 ses << "MemBlob capacity distribution at destruct time:\n";
105}
106
107void
109{
111 msg.putPod(sbdata);
112 msg.putPod(mbdata);
113}
114
115void
117{
119 msg.getPod(sbdata);
120 msg.getPod(mbdata);
121}
122
123void
125{
128 Mgr::RegisterAction("sbuf", "String-Buffer statistics", &SBufStatsAction::Create, 0, 1);
129}
130
int size
Definition: ModDevPoll.cc:75
static StatHist & collectMemBlobDestructTimeStats()
the MemBlob size-at-destruct-time histogram
static StatHist * makeDestructTimeHist()
creates a new size-at-destruct-time histogram
static StatHist & collectSBufDestructTimeStats()
the SBuf size-at-destruct-time histogram
static void statHistSBufDumper(StoreEntry *sentry, int, double val, double size, int count)
static void recordSBufSizeAtDestruct(const size_t sz)
record the size an SBuf had when it was destructed
static void recordMemBlobSizeAtDestruct(const size_t sz)
record the size a MemBlob had when it was destructed
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:35
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:118
void checkType(int aType) const
Definition: TypedMsgHdr.cc:94
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:128
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:100
std::ostream & dump(std::ostream &os) const
dumps class-wide statistics
Definition: MemBlob.cc:37
static const MemBlobStats & GetStats()
obtain a const view of class-wide statistics
Definition: MemBlob.cc:149
const CommandPointer cmd
the command that caused this action
Definition: Action.h:86
SBuf stats for cachemgr.
SBufStatsAction(const Mgr::CommandPointer &cmd)
virtual void unpack(const Ipc::TypedMsgHdr &msg)
unpack action info from the message received by Coordinator
MemBlobStats mbdata
virtual void add(const Mgr::Action &action)
incrementally merge in remote information (of the same action type)
StatHist sbsizesatdestruct
static void RegisterWithCacheManager(void)
virtual void dump(StoreEntry *entry)
virtual void pack(Ipc::TypedMsgHdr &msg) const
pack collected action info into a message to be sent to Coordinator
StatHist mbsizesatdestruct
static Pointer Create(const Mgr::CommandPointer &cmd)
Mgr::ClassActionCreationHandler for Mgr::RegisterAction()
virtual void collect()
calculate and keep local action-specific information
std::ostream & dump(std::ostream &os) const
Dump statistics to an ostream.
Definition: Stats.cc:65
static SizeRecorder SBufSizeAtDestructRecorder
collects statistics about SBuf sizes at SBuf destruction time
Definition: Stats.h:64
static SizeRecorder MemBlobSizeAtDestructRecorder
collects statistics about MemBlob capacity at MemBlob destruction time
Definition: Stats.h:66
static const SBufStats & GetStats()
gets global statistic information
Definition: SBuf.cc:494
void count(double val)
Definition: StatHist.cc:55
void dump(StoreEntry *sentry, StatHistBinDumper *bd) const
Definition: StatHist.cc:171
@ mtCacheMgrResponse
Definition: Messages.h:36
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
class Ping::pingStats_ stats
static bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
Definition: purge.cc:311
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:828
void const char int sz
Definition: stub_cbdata.cc:16

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors