Lurking CPU eater in Transience
Bug #143268 reported by
Evan Simpson
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Invalid
|
Medium
|
Chris McDonough |
Bug Description
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.
To post a comment you must log in.
> 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?