bugGnash - The GNU Flash player - Bugs: bug #22461, GC preformance: increasing CPU...


bug #22461: GC preformance: increasing CPU usage

Submitted by:  Sandro Santilli <strk>
Submitted on:  Mon 03 Mar 2008 11:18:54 AM UTC  
Category:  core Severity:  3 - Normal
Release:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Thu 06 Mar 2008 03:33:20 PM UTC, comment #7:

permances are much more acceptable now, but still
the growing number of movieclips (over 2000 after a minute or so)
bring with them about double as much managed generic_character (I guess they are shapes...) which make GC still suffering.

Also, moving the mouse makes CPU jump up to 100%, and it's expected
given the high number of movies that need to be queried for mouse handlers..

Sandro Santilli <strk>
Project Member
Thu 06 Mar 2008 02:55:33 PM UTC, comment #6:

Committed a patch to head greatly reducing number of GC-managed objects. number of builtin_function objects in particular, are now stable, and the CPU problem isn't that much noticeable anymore.

Just a note: generic_character keeps growing, these are likely drawables of sprites, we might likely do better there too..

Sandro Santilli <strk>
Project Member
Wed 05 Mar 2008 04:05:41 PM UTC, comment #5:

Adding support for C function pointer getter/setter fixed this
problem. Profiling with that enabled is:

Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
13.35 0.49 0.49 1088225 0.00 0.00 gnash::PropertyList::setReachable() const
8.17 0.79 0.30 4485112 0.00 0.00 gnash::PropertyList::getProperty(unsigned int, unsigned int)
5.72 1.00 0.21 7245936 0.00 0.00 gnash::Property::setReachable() const
5.31 1.20 0.20 670490 0.00 0.00 gnash::sprite_instance::getBounds() const
4.63 1.37 0.17 697934 0.00 0.00 gnash::DisplayList::get_character_by_name_i(std::string const&)
3.54 1.50 0.13 1191 0.11 1.03 gnash::GC::collect()

You can see that GC::collect() itself gets down from 13.6% to 3.6% of total time spent (sample of 100 seconds runtime).

Number of builtin_function objects managed by the GC keeps constant from the start around 202 (vs. 10000 and growing in the original case).

Will cleanup and commit the new code.

Sandro Santilli <strk>
Project Member
Wed 05 Mar 2008 03:10:57 PM UTC, comment #4:

The builtin_function objects are getter-setter properties attached to each and every MovieClip instance. There's actually no need
for those to be full-featured builtin_functions (which is an as_function, which is an as_object and so a GcResource).

There are 22 of them for each instance, so 33 for getter and setter + any as_function and as_object overhead.

These properties don't need a property list, no inheritance, no memory management, no nothing. So I belive the way to go would
be just support C function entry points for getter-setters (in addition to the user-provided ones).

I'm trying that now...

Just for reference, every 'dot' (red and blue) on the screen is a MovieClip instance, created trought attachMovie.

After about 6 bounces on the wall, managed builtin_functions
are about 10000.

Sandro Santilli <strk>
Project Member
Wed 05 Mar 2008 11:39:14 AM UTC, comment #3:

Added some debugging in the GC, and found that there is an increasing number of builtin_function GC-managed objects.
I wouldn't expect builtin functions to increase at all...

Sandro Santilli <strk>
Project Member
Wed 05 Mar 2008 10:57:03 AM UTC, comment #2:

This seems GC-related too:

Flat profile:

Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
21.31 2.50 2.50 17271046 0.00 0.00 gnash::PropertyList::setReachable() const
13.66 4.10 1.60 1189 1.35 8.00 gnash::GC::collect()
11.96 5.50 1.40 46348188 0.00 0.00 gnash::Property::setReachable() const
10.50 6.73 1.23 1187 1.04 1.04 gnash::GC::cleanUnreachable()
7.00 7.55 0.82 14827718 0.00 0.00 gnash::as_accessors::markReachableResources() const
4.10 8.03 0.48 49040668 0.00 0.00 gnash::as_value::setReachable() const
2.82 8.36 0.33 5935 0.06 1.09 gnash::sprite_instance::markReachableResources() const

Sandro Santilli <strk>
Project Member
Mon 03 Mar 2008 11:21:36 AM UTC, comment #1:

Each of the dots left by the two balls is a MovieClip, this
means that the global instance list linearly grows as the
simulation goes on. 2 new entries every advance at 12 FPS, which
gives 24 new entries every second, with consequent increase in
garbage collection cost.

Sandro Santilli <strk>
Project Member
Mon 03 Mar 2008 11:18:54 AM UTC, original submission:

version: 6
md5: 687d4cbe2a2c38a58fd39de04353ca25

As the movie plays (a physics simulation), CPU usage keeps increasing linearly.

Sandro Santilli <strk>
Project Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


   task dependencies.

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by strk (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    Thu 06 Mar 2008 03:52:28 PM UTC strk StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    Thu 06 Mar 2008 02:55:33 PM UTC strk StatusIn Progress => Ready For Test
        Assigned tostrk => None
    Wed 05 Mar 2008 04:05:41 PM UTC strk StatusNone => In Progress
        Assigned toNone => strk
    Wed 05 Mar 2008 10:59:04 AM UTC strk Dependencies- => Depends on task #7831
    Wed 05 Mar 2008 10:57:03 AM UTC strk CategoryNone => core
        Summaryincreasing CPU usage => GC preformance: increasing CPU usage

    Back to the top

    Powered by Savane 3.3