Skip to content

Conversation

k-okada
Copy link
Member

@k-okada k-okada commented Aug 29, 2014

k-okada added a commit that referenced this pull request Aug 30, 2014
- enable set-dispatch-macro-character for integer
@k-okada k-okada merged commit 27b647e into euslisp:master Aug 30, 2014
@k-okada k-okada deleted the fix_47 branch August 30, 2014 08:31
@snozawa
Copy link
Contributor

snozawa commented Sep 4, 2014

This PR has side-effect for my environment.
After this PR, reading from #i(xxxxx ...) vector get slow.

  • How to reproduce (just for our ROS-based environment)
# dump integer vector
eusgl
$ (progn (setq *b* (fill (instantiate integer-vector 50000) 1000)) (dump-loadable-structure "/tmp/test1.l" *b*) (exit))

# case 1 for current revision (after this PR)
irteusgl # sorry for using irteusgl
$ (bench (load "/tmp/test1.l"))
$ (exit)

# case 2 before this PR
roscd euslisp/jskeus
make clean
make
# comment out (set-dispatch-macro-character #\# #\I 'read-integer-array)
irteusgl
$ (bench (load "/tmp/test1.l"))
$ (exit)

In my PC, case1 was

;; time -> 0.030877[s] 

, and case2 was

;; time -> 4.43546[s] 

Case2 was about 150times slower than case1.

I found this problem in loading euscollada robot model file, which has too many vertices for body.

@k-okada
Copy link
Member Author

k-okada commented Sep 4, 2014

Humm, so, before this patch, #i(1 2 3) can be read, with out defining set-dispatch-macro-character,
If this is correct, which code actually read this vector?

@snozawa
Copy link
Contributor

snozawa commented Sep 4, 2014

Oh, that's curious.

In my checking of isint(macrofunc) result in https://github.com/euslisp/EusLisp/blob/master/lisp/c/reader.c#L642 (before this PR):

YoheiKakiuchi added a commit to YoheiKakiuchi/EusLisp that referenced this pull request Sep 5, 2014
@YoheiKakiuchi
Copy link
Member

here is original function, and it is overwritten by set-dispatch-macro-character.
https://github.com/euslisp/EusLisp/blob/master/lisp/c/reader.c#L1058

What is difference between float-vector and integer-vector while reading macro.

This part took much time. So, We should change this part.

(fill-initial-contents (instantiate integer-vector (length list)) 0 (list (length list)) list)
(defun read-float-array (strm char num)
   (let ((list (read strm t t t)))
       (if (= num 0)
           (apply 'float-vector list)
           (make-array (list-dimensions list)
                        :element-type :float
                        :initial-contents list))))
(defun read-integer-array (strm char num)
   (let ((list (read strm t t t)))
      (if (= num 0)
          (fill-initial-contents (instantiate integer-vector (length list))
                                 0 (list (length list)) list)
          (make-array (list-dimensions list)
                        :element-type :integer
                        :initial-contents list))))

@snozawa
Copy link
Contributor

snozawa commented Sep 5, 2014

I tested your PR (#61)
and I confirmed my euscollada model can be loaded successfully (as fast as previous revision).

k-okada added a commit that referenced this pull request Feb 9, 2015
- enable set-dispatch-macro-character for integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integerの行列のリードが失敗する
3 participants