defcvar access is much slower on SBCL than it could be
Bug #1560678 reported by
Attila Lendvai
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
CFFI |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
FTR, as reported by Stas on #sbcl:
(cffi:defcvar errno :int)
(defun foo () errno)
(time (loop repeat 1000000 do (foo)))
Evaluation took:
2.779 seconds of real time
2.864000 seconds of total run time (2.864000 user, 0.000000 system)
103.06% CPU
7,485,939,201 processor cycles
1 page fault
239,999,728 bytes consed
(defun foo2 () (sb-alien:
(time (loop repeat 1000000 do (foo2)))
Evaluation took:
0.005 seconds of real time
0.000000 seconds of total run time (0.000000 user, 0.000000 system)
0.00% CPU
11,885,253 processor cycles
0 bytes consed
The slowdown comes from CFFI using sb-sys: find-foreign- symbol- address whereas your FOO2 version uses the simpler sb-sys: foreign- symbol- sap. Alas, they don't seem to be interchangeable.