Github user jodersky commented on a diff in the pull request: https://github.com/apache/spark/pull/14359#discussion_r72322067 --- Diff: mllib/src/main/scala/org/apache/spark/ml/tree/impl/RandomForest.scala --- @@ -1110,4 +1124,40 @@ private[spark] object RandomForest extends Logging { } } + /** + * Class for queueing nodes to split on each iteration. + * This is a FILO queue. + */ + private[impl] class NodeQueue { + private var q: mutable.MutableList[(Int, LearningNode)] = + mutable.MutableList.empty[(Int, LearningNode)] + + /** Put (treeIndex, node) into queue. Constant time. */ + def put(treeIndex: Int, node: LearningNode): Unit = { + q += ((treeIndex, node)) + } + + /** Remove and return last inserted element. Linear time (unclear in Scala docs though) */ --- End diff -- How critical is this for performance? I know that `append` is O(1) for scala mutable lists but `dropRight(1)` is actually implemented in a parent class [1] of `MutableList` and therefores does not take advantage of the list's reference to its last element. All in all, from it's implementation it seems that `dropRight` is O(n) [1] https://github.com/scala/scala/blob/v2.11.8/src/library/scala/collection/LinearSeqOptimized.scala#L194-L204
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org