[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11698: Change default THREASHOLD fr
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11698: Change default THREASHOLD from 50 to 64 (nicer number). |
Date: |
Wed, 16 Dec 2009 00:54:32 +0100 |
User-agent: |
Bazaar (2.0.2) |
------------------------------------------------------------
revno: 11698
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Wed 2009-12-16 00:54:32 +0100
message:
Change default THREASHOLD from 50 to 64 (nicer number).
Cleanup debugging prints so it gives better informations for stats.
Add some documentation in the ::collect method as a starting point to try at
improving the heuristic used to skip collection cycles.
Use typeName rather than typeid.
modified:
libbase/GC.cpp
libbase/GC.h
=== modified file 'libbase/GC.cpp'
--- a/libbase/GC.cpp 2009-12-15 22:49:29 +0000
+++ b/libbase/GC.cpp 2009-12-15 23:54:32 +0000
@@ -33,7 +33,7 @@
namespace gnash {
GC* GC::_singleton = NULL;
-unsigned int GC::maxNewCollectablesCount = 50;
+unsigned int GC::maxNewCollectablesCount = 64;
GC&
GC::init(GcRoot& root)
@@ -67,7 +67,7 @@
GC::~GC()
{
#ifdef GNASH_GC_DEBUG
- log_debug(_("GC %p deleted, deleting all managed resources - collector
run %d times"), (void*)this, _collectorRuns);
+ log_debug(_("GC deleted, deleting all managed resources - collector run
%d times"), _collectorRuns);
#endif
#if 1
@@ -84,7 +84,7 @@
size_t deleted = 0;
#if (GNASH_GC_DEBUG > 1)
- log_debug(_("GC %p: SWEEP SCAN"), (void*)this);
+ log_debug(_("GC: sweep scan started"));
#endif
for (ResList::iterator i=_resList.begin(), e=_resList.end(); i!=e; )
@@ -93,8 +93,8 @@
if ( ! res->isReachable() )
{
#if GNASH_GC_DEBUG > 1
- log_debug(_("GC %p: cleanUnreachable deleting object %p
(%s)"),
- (void*)this, (void*)res,
typeName(*res).c_str());
+ log_debug(_("GC: recycling object %p (%s)"),
+ res, typeName(*res).c_str());
#endif
++deleted;
delete res;
@@ -113,22 +113,54 @@
void
GC::collect()
{
- size_t curResSize = _resList.size(); // this is O(n) on GNU stdc++ lib !
- if ( curResSize < _lastResCount + maxNewCollectablesCount )
+ // Heuristic to decide wheter or not to run the collection cycle
+ //
+ //
+ // Things to consider:
+ //
+ // - Cost
+ // - Depends on the number of reachable collectables
+ // - Depends on the frequency of runs
+ //
+ // - Advantages
+ // - Depends on the number of unreachable collectables
+ //
+ // - Cheaply computable informations
+ // - Number of collectables (currently O(n) but can be optimized)
+ // - Total heap-allocated memory (currently unavailable)
+ //
+ // Current heuristic:
+ //
+ // - We run the cycle again if X new collectables were allocated
+ // since last cycle run. X defaults to maxNewCollectablesCount
+ // and can be changed by user (GNASH_GC_TRIGGER_THRESHOLD env
+ // variable).
+ //
+ // Possible improvements:
+ //
+ // - Adapt X (maxNewCollectablesCount) based on cost/advantage
+ // runtime analisys
+ //
+
+ size_t curResCount = _resList.size(); // this is O(n) on GNU stdc++ lib
!
+ if ( curResCount < _lastResCount + maxNewCollectablesCount )
{
#if GNASH_GC_DEBUG > 1
- log_debug(_("Garbage collection skipped since number of
collectables added since last run is too low (%d)"),
- curResSize - _lastResCount);
+ log_debug(_("GC: collection cycle skipped - %d/%d new resources
allocated since last run (from %d to %d)"), curResCount-_lastResCount,
maxNewCollectablesCount, _lastResCount, curResCount);
#endif // GNASH_GC_DEBUG
return;
}
+ //
+ // Collection cycle
+ //
+
#ifdef GNASH_GC_DEBUG
++_collectorRuns;
#endif
#ifdef GNASH_GC_DEBUG
- log_debug(_("GC %p Starting collector: %d collectables (from %d of last
run)"), (void *)this, curResSize, _lastResCount);
+ log_debug(_("GC: collection cycle started - %d/%d new resources
allocated since last run (from %d to %d)"), curResCount-_lastResCount,
maxNewCollectablesCount, _lastResCount, curResCount);
#endif // GNASH_GC_DEBUG
#ifndef NDEBUG
@@ -142,15 +174,15 @@
// clean unreachable resources, and mark the others as reachable again
size_t deleted = cleanUnreachable();
- _lastResCount = curResSize - deleted;
+ _lastResCount = curResCount - deleted;
#ifdef GNASH_GC_DEBUG
- log_debug(_("GC %p: cleanUnreachable deleted %d unreachable resources, "
- "leaving %d alive"),
- (void*)this, deleted, _lastResCount);
- assert(_lastResCount == _resList.size()); // again O(n)...
+ log_debug(_("GC: recycled %d unreachable resources - %d left"),
+ deleted, _lastResCount);
#endif
+ //assert(_lastResCount == _resList.size()); // again O(n)...
+
}
void
=== modified file 'libbase/GC.h'
--- a/libbase/GC.h 2009-06-07 22:10:39 +0000
+++ b/libbase/GC.h 2009-12-15 23:54:32 +0000
@@ -45,6 +45,7 @@
#ifdef GNASH_GC_DEBUG
# include "log.h"
+# include "utility.h"
# include <typeinfo>
#endif
@@ -112,7 +113,7 @@
{
#if GNASH_GC_DEBUG > 2
log_debug(_("Instance %p of class %s already reachable,
setReachable doing nothing"),
- (void*)this, typeid(*this).name());
+ (void*)this, typeName(*this));
#endif
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11698: Change default THREASHOLD from 50 to 64 (nicer number).,
Sandro Santilli <=