Skip to content

The test suite spends 20% of it's time in gc.collect() #6705

Closed

Description

@Kojoley
Thu Jul 07 14:33:31 2016    matplotlib_cProfile_fulltest.pstat

         192634679 function calls (182051956 primitive calls) in 345.231 seconds

   Ordered by: internal time
   List reduced from 9374 to 3 due to restriction <3>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     2986   75.105    0.025   75.107    0.025 {gc.collect}
     1250   19.139    0.015   19.139    0.015 {matplotlib._png.write_png}
     2257    9.801    0.004    9.801    0.004 {matplotlib._png.read_png_int}

Mostly this is due to this call

Python is very memory effective because of reference counting (object is freed when refcount drops to zero even with gc.disable) and gc.collect only forces him to run cyclic garbage collector immediately. If it is not acceptable to to remove this call, can we have option to tuning this?

Activity

  1. tacaswell commented on Jul 8, 2016

    @tacaswell
    Member

    👍 on removing that line.

    That line went in in 42fa2b6 where @mdboom notes it makes debugging memory usage easier. However, I am willing to trade 20% on the tests for inflicting pain on the dev who does memory debugging 😈 .

  2. Kojoley commented on Jul 8, 2016

    @Kojoley
    MemberAuthor

    We can add turnable plugin for this case.

        class EnforcedGC(Plugin):
            def afterTest(self, test):
                gc.collect()
  3. added this to the milestone on Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions