mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
Measure GC duration
This commit is contained in:
parent
54e1ac6102
commit
c6ff34bd86
2 changed files with 17 additions and 4 deletions
|
|
@ -3,6 +3,8 @@
|
||||||
#include "attr-set.hh"
|
#include "attr-set.hh"
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
GC gc;
|
GC gc;
|
||||||
|
|
@ -44,10 +46,11 @@ GC::GC()
|
||||||
|
|
||||||
GC::~GC()
|
GC::~GC()
|
||||||
{
|
{
|
||||||
printInfo("%d bytes in arenas, %d bytes allocated, %d bytes reclaimed by GC",
|
debug("%d bytes in arenas, %d bytes allocated, %d bytes reclaimed, in %d ms",
|
||||||
totalSize * WORD_SIZE,
|
totalSize * WORD_SIZE,
|
||||||
allTimeWordsAllocated * WORD_SIZE,
|
allTimeWordsAllocated * WORD_SIZE,
|
||||||
allTimeWordsFreed * WORD_SIZE);
|
allTimeWordsFreed * WORD_SIZE,
|
||||||
|
totalDurationMs);
|
||||||
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
for (Ptr<Object> * p = frontPtrSentinel->next; p != backPtrSentinel; p = p->next)
|
for (Ptr<Object> * p = frontPtrSentinel->next; p != backPtrSentinel; p = p->next)
|
||||||
|
|
@ -97,6 +100,10 @@ void GC::addToFreeList(Free * obj)
|
||||||
|
|
||||||
void GC::gc()
|
void GC::gc()
|
||||||
{
|
{
|
||||||
|
typedef std::chrono::time_point<std::chrono::steady_clock> steady_time_point;
|
||||||
|
|
||||||
|
auto before = steady_time_point::clock::now();
|
||||||
|
|
||||||
size_t marked = 0;
|
size_t marked = 0;
|
||||||
|
|
||||||
std::stack<Object *> stack;
|
std::stack<Object *> stack;
|
||||||
|
|
@ -253,10 +260,15 @@ void GC::gc()
|
||||||
totalWordsFreed += wordsFreed;
|
totalWordsFreed += wordsFreed;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("freed %d bytes in %d dead objects, keeping %d objects",
|
auto after = steady_time_point::clock::now();
|
||||||
totalWordsFreed * WORD_SIZE, totalObjectsFreed, marked);
|
|
||||||
|
auto durationMs = std::chrono::duration_cast<std::chrono::milliseconds>(after - before).count();
|
||||||
|
|
||||||
|
debug("freed %d bytes in %d dead objects, keeping %d objects, in %d ms",
|
||||||
|
totalWordsFreed * WORD_SIZE, totalObjectsFreed, marked, durationMs);
|
||||||
|
|
||||||
allTimeWordsFreed += totalWordsFreed;
|
allTimeWordsFreed += totalWordsFreed;
|
||||||
|
totalDurationMs += durationMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<size_t, size_t> GC::freeUnmarked(Arena & arena)
|
std::pair<size_t, size_t> GC::freeUnmarked(Arena & arena)
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ private:
|
||||||
|
|
||||||
size_t allTimeWordsAllocated = 0;
|
size_t allTimeWordsAllocated = 0;
|
||||||
size_t allTimeWordsFreed = 0;
|
size_t allTimeWordsFreed = 0;
|
||||||
|
uint64_t totalDurationMs = 0;
|
||||||
|
|
||||||
Object * allocObject(size_t size)
|
Object * allocObject(size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue