Bug 12245 – BinaryHeap exhibits quadratic performance in debug mode

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-25T00:26:00Z
Last change time
2014-03-02T08:40:09Z
Assigned to
nobody
Creator
sludwig
See also
https://d.puremagic.com/issues/show_bug.cgi?id=12246

Comments

Comment #0 by sludwig — 2014-02-25T00:26:27Z
BinaryHeap.insert, conditionalInsert and replaceFront all call assertValid, which goes through the complete heap to check for correct structure. This results in unusable performance in debug mode due to the quadratic run time. Arguably, such costly algorithm validation should be left for a unit test instead.
Comment #1 by gassa — 2014-02-25T01:05:26Z
A similar issue with RedBlackTree container: https://d.puremagic.com/issues/show_bug.cgi?id=12246
Comment #2 by gassa — 2014-02-25T01:11:33Z
I think implying "unittest => slow but checked containers" is not the way to go, either. Imagine a module making heavy use of containers and just wishing to run the module's own unittests. With such implication, there would be no fast way to do that. Or is there a way to import the generic container from std.container without propagating the "-unittest" flag? It's a generic after all, so it can't be compiled separately, right? A better way would be to (create and) mention a version flag needed for container debugging in the documentation for the respective container.
Comment #3 by peter.alexander.au — 2014-03-02T08:38:05Z
Comment #4 by github-bugzilla — 2014-03-02T08:39:32Z