[ZCM] [ZC] 1633/ 3 Comment "Lurking CPU eater in Transience"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Mon Dec 20 13:54:43 EST 2004
Issue #1633 Update (Comment) "Lurking CPU eater in Transience"
Status Accepted, Zope/bug+solution medium
To followup, visit:
http://collector.zope.org/Zope/1633
==============================================================
= Comment - Entry #3 by evan on Dec 20, 2004 1:54 pm
Inserting or deleting elements or replacing a slice that spans the current element in a for-loop is generally a bad idea. Changing the value of a list element is fine.
________________________________________
= Comment - Entry #2 by mcdonc on Dec 20, 2004 1:10 pm
> This was due to it inserting tens of thousands of elements into the head
> of an empty list, one at a time. While I learned my lesson, and bumped
> the resolution up to match the timeout, I also decided to fix
> getTimeslices. A patch is attached.
Cool, thanks! I'm wondering, though, I've always heard it was bad to mutate a list while iterating over it. Does that only matter if you change the size of the list while doing so?
________________________________________
= Request - Entry #1 by evan on Dec 20, 2004 12:02 pm
Status: Pending => Accepted
Supporters added: chrism
Uploaded: "p"
- http://collector.zope.org/Zope/1633/p/view
I foolishly set the timeout of a Transient Object Container to a very high value while leaving the timeout resolution at 20. Subsequent profiling revealed that Transience.py's getTimeslices was using 100% CPU for more than a second every time it was called, which was frequently. This was due to it inserting tens of thousands of elements into the head of an empty list, one at a time. While I learned my lesson, and bumped the resolution up to match the timeout, I also decided to fix getTimeslices. A patch is attached.
==============================================================
More information about the Zope-Collector-Monitor
mailing list