Steel Bank Common Lisp

make-array with non-constant :element-type '(unsigned-byte 8) is too slow

Reported by Stelian Ionescu on 2012-05-25
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

Using 1.057 on Linux/x86_64, with *features*:
:SB-BSD-SOCKETS-ADDRINFO :ASDF2 :ASDF :ASDF-UNICODE :SB-AFTER-XC-CORE :SB-CORE-COMPRESSION :SB-XREF-FOR-INTERNALS :ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-LDB :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :OS-PROVIDES-POLL :OS-PROVIDES-GETPROTOBY-R :OS-PROVIDES-SUSECONDS-T :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-PUTWC :OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN :LITTLE-ENDIAN :MULTIPLY-HIGH-VOPS :MEMORY-BARRIER-VOPS :INLINE-CONSTANTS :FLOAT-EQL-VOPS :COMPLEX-FLOAT-VOPS :CYCLE-COUNTER :ALIEN-CALLBACKS :STACK-ALLOCATABLE-FIXED-OBJECTS :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS :STACK-ALLOCATABLE-CLOSURES :RAW-INSTANCE-INIT-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :COMPARE-AND-SWAP-VOPS :LINKAGE-TABLE :C-STACK-IS-CONTROL-STACK :STACK-GROWS-DOWNWARD-NOT-UPWARD :GENCGC :LARGEFILE :SB-FUTEX :SB-THREAD :LINUX :ELF :UNIX :X86-64

(defun mkar/nonconst (size external-format)
  (declare (optimize (speed 3) (safety 0) (debug 1))
           (type (unsigned-byte 16) size))
  (make-array size :element-type (if external-format
                                     'character
                                     '(unsigned-byte 8))))

NIL
OS> (time (dotimes (i 10000000) (mkar/nonconst 5 nil)))
Evaluation took:
  24.890 seconds of real time
  24.933558 seconds of total run time (24.933558 user, 0.000000 system)
  [ Run times consist of 1.004 seconds GC time, and 23.930 seconds non-GC time. ]
  100.18% CPU
  39,723,365,896 processor cycles
  5,280,018,416 bytes consed

NIL
OS> (time (dotimes (i 10000000) (mkar/nonconst 5 t)))
Evaluation took:
  1.151 seconds of real time
  1.156073 seconds of total run time (1.156073 user, 0.000000 system)
  [ Run times consist of 0.164 seconds GC time, and 0.993 seconds non-GC time. ]
  100.43% CPU
  1,836,654,675 processor cycles
  800,007,280 bytes consed

NIL

Paul Khuong (pvk) wrote :

sb!impl::%vector-widetag-and-n-bits and %complex-vector-widetag punt to SUBTYPEP when adding a set of EQUAL tests would catch nearly all cases. The use of CASE instead of lookup tables for the fast (non-subtypep) paths is also questionable, but any difference is probably marginal.

Changed in sbcl:
status: New → Confirmed
importance: Undecided → Low
Paul Khuong (pvk) on 2012-05-25
tags: added: easy optimization
Stas Boukarev (stassats) on 2014-01-02
summary: - make-array with non-constant :element-type '(unsigned-byte 8) conses a
- lot
+ make-array with non-constant :element-type '(unsigned-byte 8) is too
+ slow
Stas Boukarev (stassats) wrote :

Fixed in 0c3bbfaa2286626a2d915c8810f690aefc702661.

Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers