[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/gui.cpp libbase/GC.cpp libb...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog gui/gui.cpp libbase/GC.cpp libb... |
Date: |
Mon, 02 Jul 2007 22:48:21 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/07/02 22:48:21
Modified files:
. : ChangeLog
gui : gui.cpp
libbase : GC.cpp GC.h
Log message:
* libbase/GC.{cpp,h}: Implement an heuristic to reduce
the number of collector runs. It is based on the number
of newly registered collectables since last run.
The threshold is set to 10 with a static const member
of the GC class. See
http://gnashdev.org/wiki/index.php/ProfilingGC
for more informations.
* gui/gui.cpp (fpsCounterTick): don't report an initial FPS of
0.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3641&r2=1.3642
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/GC.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/GC.h?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3641
retrieving revision 1.3642
diff -u -b -r1.3641 -r1.3642
--- ChangeLog 2 Jul 2007 22:10:16 -0000 1.3641
+++ ChangeLog 2 Jul 2007 22:48:20 -0000 1.3642
@@ -1,5 +1,15 @@
2007-07-02 Sandro Santilli <address@hidden>
+ * libbase/GC.{cpp,h}: Implement an heuristic to reduce
+ the number of collector runs. It is based on the number
+ of newly registered collectables since last run.
+ The threshold is set to 10 with a static const member
+ of the GC class. See http://gnashdev.org/wiki/index.php/ProfilingGC
+ for more informations.
+ * gui/gui.cpp (fpsCounterTick): don't report an initial FPS of 0.
+
+2007-07-02 Sandro Santilli <address@hidden>
+
* gui/NullGui.{h,cpp}: implement quit(), for clean shutdown.
* gui/gui.cpp (advance_movie): use quit() to exit
Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- gui/gui.cpp 2 Jul 2007 22:10:16 -0000 1.84
+++ gui/gui.cpp 2 Jul 2007 22:48:20 -0000 1.85
@@ -573,7 +573,7 @@
void
Gui::fpsCounterTick()
{
- GNASH_REPORT_FUNCTION;
+ // GNASH_REPORT_FUNCTION;
// increment this *before* the early return so that
// frame count on exit is still valid
@@ -585,8 +585,13 @@
}
uint64_t current_timer = tu_timer::get_ticks();
+
+ // TODO: keep fps_timer_interval in milliseconds to avoid the multiplication
+ // at each fpsCounterTick call...
uint64_t interval_ms = (uint64_t)(fps_timer_interval * 1000.0);
+ if (fps_counter_total==1) fps_timer = current_timer;
+
++fps_counter;
if (current_timer - fps_timer >= interval_ms) {
Index: libbase/GC.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/GC.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libbase/GC.cpp 1 Jul 2007 10:54:06 -0000 1.3
+++ libbase/GC.cpp 2 Jul 2007 22:48:20 -0000 1.4
@@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: GC.cpp,v 1.3 2007/07/01 10:54:06 bjacques Exp $ */
+/* $Id: GC.cpp,v 1.4 2007/07/02 22:48:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -25,6 +25,9 @@
#include "GC.h"
#include "builtin_function.h"
+#ifdef GNASH_GC_DEBUG
+# include "log.h"
+#endif
namespace gnash {
@@ -56,7 +59,7 @@
GC::~GC()
{
#ifdef GNASH_GC_DEBUG
- log_debug(_("GC %p deleted, deleting all managed resources"),
(void*)this);
+ log_debug(_("GC %p deleted, deleting all managed resources - collector
run " SIZET_FMT " times"), (void*)this, _collectorRuns);
#endif
#if 1
@@ -102,6 +105,40 @@
#endif
}
+void
+GC::collect()
+{
+ if ( (_resList.size() - _lastResCount) < maxNewCollectablesCount )
+ {
+#if GNASH_GC_DEBUG > 1
+ log_debug(_("Garbage collection skipped since number of
collectables added since last run is too low (" SIZET_FMT ")"),
+ _resList.size() - _lastResCount);
+#endif // GNASH_GC_DEBUG
+ return;
+ }
+
+#ifdef GNASH_GC_DEBUG
+ ++_collectorRuns;
+#endif
+
+#ifdef GNASH_GC_DEBUG
+ log_debug(_("Starting collector: " SIZET_FMT " collectables"),
_resList.size());
+#endif // GNASH_GC_DEBUG
+
+#ifndef NDEBUG
+ boost::thread self;
+ assert(self == mainThread);
+#endif
+
+ // Mark all resources as reachable
+ markReachable();
+
+ // clean unreachable resources, and mark them others as reachable again
+ cleanUnreachable();
+
+ _lastResCount = _resList.size();
+}
+
} // end of namespace gnash
Index: libbase/GC.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/GC.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libbase/GC.h 2 Jul 2007 03:20:33 -0000 1.12
+++ libbase/GC.h 2 Jul 2007 22:48:20 -0000 1.13
@@ -220,7 +220,8 @@
assert(self == mainThread);
assert(item);
assert(! item->isReachable());
- assert(std::find(_resList.begin(), _resList.end(), item) ==
_resList.end());
+ // The following assertion is expensive ...
+ //assert(std::find(_resList.begin(), _resList.end(), item) ==
_resList.end());
#endif
_resList.push_back(item);
@@ -234,31 +235,23 @@
//
/// Find all reachable collectables, destroy all the others.
///
- void collect()
- {
-#ifdef GNASH_GC_DEBUG
- log_debug(_("Starting collector: " SIZET_FMT " collectables"),
_resList.size());
-#endif // GNASH_GC_DEBUG
-
-#ifndef NDEBUG
- boost::thread self;
- assert(self == mainThread);
-#endif
-
- // Mark all resources as reachable
- markReachable();
-
- // clean unreachable resources, and mark them others as
reachable again
- cleanUnreachable();
-
- }
+ void collect();
private:
+ /// Number of newly registered collectable since last collection run
+ /// triggering next collection.
+ /// Should be made a parameter ?
+ static const unsigned int maxNewCollectablesCount = 10;
+
/// Create a garbage collector, using the given root
GC(GcRoot& root)
:
- _root(root)
+ _root(root),
+ _lastResCount(0)
+#ifdef GNASH_GC_DEBUG
+ , _collectorRuns(0)
+#endif
{
#ifdef GNASH_GC_DEBUG
log_debug(_("GC %p created"), (void*)this);
@@ -295,6 +288,15 @@
/// and to register collectable objects
boost::thread mainThread;
#endif
+
+ /// Number of resources in collectable list at end of last
+ /// collect() call.
+ ResList::size_type _lastResCount;
+
+#ifdef GNASH_GC_DEBUG
+ /// Number of times the collector runs (stats/profiling)
+ size_t _collectorRuns;
+#endif
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog gui/gui.cpp libbase/GC.cpp libb...,
Sandro Santilli <=