Low performance of (concatenate 'string ...).
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hello, I have not an idea why builtin (concatenate 'string ) so slow, I am newbie in CL.
I had test string stream vs concatenate performance and got results below:
"Test string output stream"
189993
Evaluation took:
0.013 seconds of real time
0.012293 seconds of total run time (0.008819 user, 0.003474 system)
92.31% CPU
39,345,984 processor cycles
6,588,160 bytes consed
"Test concatenate"
190008
Evaluation took:
3.480 seconds of real time
3.464029 seconds of total run time (3.059003 user, 0.405026 system)
[ Real times consist of 0.280 seconds GC time, and 3.200 seconds non-GC time. ]
[ Run times consist of 0.289 seconds GC time, and 3.176 seconds non-GC time. ]
99.54% CPU
11,123,607,584 processor cycles
38,009,081,712 bytes consed
=== Test code ===
(defconstant *count* 100000)
(print "Test string output stream")
(defparameter out-stream (make-string-
(time
(progn
(dotimes (i *count*)
(let (
(result (get-output-
(print (length result))
)))
(print "Test concatenate")
(defparameter out-string nil)
(time
(progn
(dotimes (i *count*)
(setq out-string
(print (length out-string))
))
-----
The result above displays how (make-string-
I had write own simple implementation (concatenate-
(defun concatenate-string (&rest args)
(let ((stream (make-string-
(dolist (arg args)
(if (stringp arg)
arg
stream))
(get-output-
This issue published for help to improve performance of SBCL.
Maybe using (make-string-
Thanks.
description: | updated |
description: | updated |
Changed in sbcl: | |
status: | Won't Fix → Invalid |
Your tests are not at all equivalent. In the "Test concatenate" example you are producing as many intermediate strings as there are loop iterations, and each intermediate string is a newly made string containing the entire contents of all prior loop iterations.