Nice catch!
My 'shell' was tcsh and after changing it to /bin/sh (=bash) System() works
much better (only ~x2 slower than Job()). I probably wouldn't get into this
if I got these results in the first place.. still, I'm going to use the
above blocking version of job_start (it is as fast as Job()) since in RHEL
everything is slower by a factor of 10(!) anyway.

Thanks,
Ramel

2016-08-29 2:35 GMT+03:00 Dominique Pellé <[email protected]>:

> Ramel Eshed <[email protected]> wrote:
>
> > My problem is not with the channel, the problem is
> > that system() is slower than the equivalent job_start().
> > You can run and compare the results of Job() and System()
> > functions in the attached file. They are both doing the same
> > thing ('echo aaa') but System() is ~5 times slower than Job()
> > on Ubuntu and x10 slower on RHEL5.5. On RHEL
> > System() is extremely slow, it takes about 0.2 seconds
> > which cause Vim to hang.
>
> I just tried the script system.vim which you attached
> and measured x3 times on my laptop x86_64
> (xubuntu-14.04) using Vim-7.4.2290:
>
> :so system.vim
>
> :call Job()
> aaa:   0.004798
> :call Job()
> aaa:   0.002810
> call Job()
> aaa:   0.002988
>
> :call System()
> aaa:   0.007809
> :call System()
> aaa:   0.007768
> :call System()
> aaa:   0.007858
>
> So for me, System() is also slower than Job().
> However, the difference on my machine is not
> as large as yours.  I don't see system()
> taking 0.2 sec as you see on RHEL.
>
> I tried this with strace:
>
> $ strace -r -f -osystem.trace time ./vim -u NONE -N -S system.vim  -c
> 'call System()|q'
> $ strace -r -f -ojob.trace time ./vim -u NONE -N -S system.vim  -c
> 'call Job()|q'
>
> Looking at log files jobs.trace and system.trace,
> I saw that:
>
> In system.trace
>
> 8756  execve("/bin/bash", ["/bin/bash", "-c", "(echo aaa)
> >/tmp/vwA2O35/0 2>&1"], [/* 69 vars */] <unfinished ...>
>
> In job.trace:
>
> 8773  execve("/bin/sh", ["/bin/sh", "-c", "echo aaa"], [/* 72 vars */]
> <unfinished ...>
>
> Ah, it's not using the same shell! /bin/sh is a symlink
> to /bin/dash on my system, which is a simpler shell
> than /bin/bash.   system() also runs the command in a
> subshell which may make it slower.
>
> I then added this line in your script system.vim:
>
> set shell=/bin/sh
>
> And now system() is faster, still not as fast as Job() but
> getting closer:
>
> :call System()
> aaa:   0.004737
> :call System()
> aaa:   0.004920
> :call System()
> aaa:   0.004718
>
> What is the value of :echo &shell  for you?
> Can you try with set shell=/bin/sh ?
>
> Here is my modified system.vim:
>
> ===
> $ cat system.vim
>
> set shell=/bin/sh
> func! Job()
>     let g:output = []
>     let s:rt = reltime()
>     let g:job = job_start(['/bin/sh', '-c', 'echo aaa'], {'out_cb':
> function('s:out_cb'), 'close_cb': function('s:close_cb')})
> endfunc
>
> func! s:out_cb(channel, msg)
>     call add(g:output, a:msg)
> endfunc
>
> func! s:close_cb(channel)
>     echo g:output[0] . ': ' . reltimestr(reltime(s:rt))
> endfunc
>
> " compare with:
>
> func! System()
>     let s:rt = reltime()
>     let g:output = systemlist('echo aaa')
>     echo g:output[0] . ': ' . reltimestr(reltime(s:rt))
> endfunc
> ===
>
> Regards
> Dominique
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "vim_dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/vim_dev/PmNEtGLv6J0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui