Performance bogs down with huge sequences
Created by: genworks
Huge sequence will bog performance because of list operations during dependency tracking.
(in-package :gdl-user)
;;
;; Submitted by Hermen de Jong of KE-works
;;
(define-object huge-boxes-sequence (base-object)
:input-slots
((number-of-boxes 100 :settable))
:computed-slots
((wall-width (floor (sqrt (the number-of-boxes)))))
:objects
((boxes :type 'box
:sequence (:size (the number-of-boxes))
:height 10
:width 20
:length 30
:display-controls (list :color :red :transparency .5)
:center (translate (make-point 0 0 0)
:right (* (rem (the-child index)
(the wall-width))
(the-child width))
:top (* (floor (the-child index)
(the wall-width))
(the-child height))))))
gdl-user> (make-self 'huge-boxes-sequence)
#<huge-boxes-sequence @ #x25ab80da>
gdl-user> (the (set-slot! :number-of-boxes 20000))
nil
gdl-user> (time (progn (mapsend (the boxes) :center) nil))
; While compiling #'(:internal (:anonymous-lambda 51) 0) at top level:
Warning: Free reference to undeclared variable self assumed special.
; cpu time (non-gc) 11.716732 sec user, 0.000000 sec system
; cpu time (gc) 0.676043 sec user, 0.000000 sec system
; cpu time (total) 12.392775 sec user, 0.000000 sec system
; real time 11.031462 sec (112.3%)
; space allocation:
; 1,680,343 cons cells, 27,958,896 other bytes, 0 static bytes
; Page Faults: major: 0 (gc: 2585), minor: 4786 (gc: 2585)
nil
gdl-user>
Imported comments:
By genworks on 2013-02-01 03:14:08 UTC
Fixed with more efficient data structure in place of large dependency tracking lists:
gdl-user> (make-self 'huge-boxes-sequence)
#<huge-boxes-sequence @ #x2527a892>
gdl-user> (the (set-slot! :number-of-boxes 20000))
nil
gdl-user> (time (progn (mapsend (the boxes) :center) nil))
; While compiling #'(:internal (:anonymous-lambda 52) 0) at top level:
Warning: Free reference to undeclared variable self assumed special.
; cpu time (non-gc) 1.288081 sec user, 0.000000 sec system
; cpu time (gc) 0.744046 sec user, 0.000000 sec system
; cpu time (total) 2.032127 sec user, 0.000000 sec system
; real time 1.843707 sec (110.2%)
; space allocation:
; 1,604,168 cons cells, 35,065,232 other bytes, 0 static bytes
; Page Faults: major: 0 (gc: 599), minor: 1041 (gc: 599)
nil
gdl-user>