D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12245 - BinaryHeap exhibits quadratic performance in debug mode
Summary: BinaryHeap exhibits quadratic performance in debug mode
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-25 00:26 UTC by Sönke Ludwig
Modified: 2014-03-02 08:40 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Sönke Ludwig 2014-02-25 00:26:27 UTC
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 Ivan Kazmenko 2014-02-25 01:05:26 UTC
A similar issue with RedBlackTree container:

https://d.puremagic.com/issues/show_bug.cgi?id=12246
Comment 2 Ivan Kazmenko 2014-02-25 01:11:33 UTC
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 Peter Alexander 2014-03-02 08:38:05 UTC
I have put them in debug(BinaryHeap)

https://github.com/D-Programming-Language/phobos/pull/1976