xo-alloc: + timing stats + timeseries tooltips
This commit is contained in:
parent
df9ad3b855
commit
78195b0218
5 changed files with 110 additions and 40 deletions
|
|
@ -132,6 +132,7 @@ namespace xo {
|
|||
public:
|
||||
using CallbackId = xo::fn::CallbackId;
|
||||
using GcCopyCallbackSet = xo::fn::UpCallbackSet<GcCopyCallback>;
|
||||
using nanos = decltype(xo::qty::qty::nanosecond);
|
||||
|
||||
public:
|
||||
/** create new GC instance with configuration @p config **/
|
||||
|
|
@ -224,6 +225,8 @@ namespace xo {
|
|||
* as number of calls to @ref disable_gc.
|
||||
**/
|
||||
void enable_gc();
|
||||
/** same as @c this->enable_gc() followed by @c this->disable_gc() **/
|
||||
void enable_gc_once();
|
||||
|
||||
// inherited from IAlloc..
|
||||
|
||||
|
|
@ -279,7 +282,7 @@ namespace xo {
|
|||
/** begin GC now **/
|
||||
void execute_gc(generation g);
|
||||
/** cleanup phase. aux function for @ref execute_gc **/
|
||||
void cleanup_phase(generation g);
|
||||
void cleanup_phase(generation g, nanos dt);
|
||||
/** swap roles of From/To spaces for nursery generation **/
|
||||
void swap_nursery();
|
||||
/** swap roles of From/To spaces for tenured generation **/
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#include "generation.hpp"
|
||||
#include "CircularBuffer.hpp"
|
||||
#include "xo/reflect/TypeDescr.hpp"
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include "xo/unit/quantity_iostream.hpp"
|
||||
#include "xo/indentlog/print/pretty.hpp"
|
||||
#include <ostream>
|
||||
#include <array>
|
||||
|
|
@ -60,6 +62,13 @@ namespace xo {
|
|||
public:
|
||||
GcStatistics() = default;
|
||||
|
||||
/** update statistics at beginning of a GC cycle
|
||||
* @param upto. nursery -> incremental collection; tenured -> full collection
|
||||
* @param alloc_z. new allocations (since preceding GC)
|
||||
**/
|
||||
void begin_gc(generation upto,
|
||||
std::size_t alloc_z);
|
||||
|
||||
/** update statistics after a GC cycle
|
||||
* @param upto. nursery -> incremental collection; tenured -> full collection
|
||||
* @param alloc_z. new allocations (since preceding GC)
|
||||
|
|
@ -74,6 +83,9 @@ namespace xo {
|
|||
**/
|
||||
void update_snapshot(generation upto, std::size_t after_z);
|
||||
|
||||
/** number of collection cycles, whether full or incremental **/
|
||||
std::size_t n_gc() const { return gen_v_[gen2int(generation::nursery)].n_gc_; }
|
||||
|
||||
/** @param os. write stats on this output stream **/
|
||||
void display(std::ostream & os) const;
|
||||
|
||||
|
|
@ -136,31 +148,54 @@ namespace xo {
|
|||
* @brief info we want to record over time (won't have cumulative things in it)
|
||||
**/
|
||||
class GcStatisticsHistoryItem {
|
||||
public:
|
||||
using nanos = xo::qty::type::nanoseconds<std::int64_t>;
|
||||
|
||||
public:
|
||||
GcStatisticsHistoryItem() = default;
|
||||
GcStatisticsHistoryItem(generation upto,
|
||||
std::size_t new_alloc_z,
|
||||
std::size_t survive_z,
|
||||
std::size_t promote_z,
|
||||
std::size_t persist_z,
|
||||
std::size_t effort_z,
|
||||
std::size_t garbage0_z,
|
||||
std::size_t garbage1_z,
|
||||
std::size_t garbageN_z)
|
||||
: upto_{upto},
|
||||
new_alloc_z_{new_alloc_z},
|
||||
survive_z_{survive_z},
|
||||
promote_z_{promote_z},
|
||||
persist_z_{persist_z},
|
||||
effort_z_{effort_z},
|
||||
garbage0_z_{garbage0_z},
|
||||
garbage1_z_{garbage1_z},
|
||||
garbageN_z_{garbageN_z}
|
||||
{}
|
||||
constexpr GcStatisticsHistoryItem(std::size_t gc_seq,
|
||||
generation upto,
|
||||
std::size_t new_alloc_z,
|
||||
std::size_t survive_z,
|
||||
std::size_t promote_z,
|
||||
std::size_t persist_z,
|
||||
std::size_t effort_z,
|
||||
std::size_t garbage0_z,
|
||||
std::size_t garbage1_z,
|
||||
std::size_t garbageN_z,
|
||||
nanos dt) : gc_seq_{gc_seq},
|
||||
upto_{upto},
|
||||
new_alloc_z_{new_alloc_z},
|
||||
survive_z_{survive_z},
|
||||
promote_z_{promote_z},
|
||||
persist_z_{persist_z},
|
||||
effort_z_{effort_z},
|
||||
garbage0_z_{garbage0_z},
|
||||
garbage1_z_{garbage1_z},
|
||||
garbageN_z_{garbageN_z},
|
||||
dt_{dt} {}
|
||||
constexpr GcStatisticsHistoryItem(const GcStatisticsHistoryItem &) = default;
|
||||
|
||||
GcStatisticsHistoryItem & operator=(const GcStatisticsHistoryItem & x) {
|
||||
gc_seq_ = x.gc_seq_;
|
||||
upto_ = x.upto_;
|
||||
new_alloc_z_ = x.new_alloc_z_;
|
||||
survive_z_ = x.survive_z_;
|
||||
promote_z_ = x.promote_z_;
|
||||
persist_z_ = x.persist_z_;
|
||||
effort_z_ = x.effort_z_;
|
||||
garbage0_z_ = x.garbage0_z_;
|
||||
garbage1_z_ = x.garbage1_z_;
|
||||
garbageN_z_ = x.garbageN_z_;
|
||||
this->dt_.scale_ = x.dt_.scale_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @param os. write stats on this output stream **/
|
||||
void display(std::ostream & os) const;
|
||||
|
||||
/** sequence number for collection being reported **/
|
||||
std::size_t gc_seq_ = 0;
|
||||
/** type of GC that generated this record **/
|
||||
generation upto_;
|
||||
/** #of bytes new allocation **/
|
||||
|
|
@ -181,6 +216,8 @@ namespace xo {
|
|||
std::size_t garbage1_z_ = 0;
|
||||
/** #of bytes garbage from T (i.e. survived 2+ GCs) **/
|
||||
std::size_t garbageN_z_ = 0;
|
||||
/** elapsed time for this GC (see @ref GC::execute_gc) **/
|
||||
nanos dt_;
|
||||
};
|
||||
|
||||
inline std::ostream & operator<< (std::ostream & os, const GcStatisticsHistoryItem & x) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue