Re: [patch] improve ended-job check

2016-10-26 Fir de Conversatie Ozaki Kiichi
Additionally;

https://github.com/vim/vim/blob/46fceaa/runtime/doc/channel.txt#L601

> Vim checks about every 10 seconds for jobs that ended.

Maybe we can drop this line :)

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] improve ended-job check

2016-10-22 Fir de Conversatie Ozaki Kiichi
There is another problem on unix environment:

When a job is unreferenced, detection of job-completed is delayed.

[repro steps]

test.vim

fu! ExitCb(job, status)
  echom 'exited' reltimestr(reltime(s:elapsed))
endfu
let s:elapsed = reltime()
call job_start('sleep 1', {'exit_cb': 'ExitCb'})


vim -Nu NONE -S test.vim

exited   4.008510

Delay is about 4sec ~ 6sec.

[cause]

https://github.com/vim/vim/blob/7756e74/src/os_unix.c#L425-L435
https://github.com/vim/vim/blob/7756e74/src/os_unix.c#L496-L504

Generally, job-channel EOF makes WaitForChar return and detect job-completed 
promptly.
An unreferenced job loses own channel, so vim can't detect job-channel EOF.

[patch]

https://gist.github.com/ichizok/c7daad6267816173ac5c38f4c8848dd2

- Check job-completed every 100msec (same as on Windows) when has_pending_job() 
is TRUE.

- Change has_pending_job(); checks whether there is any job which is running,
has exit_cb, and doesn't have own job-channel or useful-channel
(channel_still_useful() is FALSE).

- Add test helper functions: Standby() and Resume() to shared.vim.
Standby() keep process waiting by getchar(), Resume() resumes process by
feedkeys(). Resume() must be called in callback.
# bacause... command-:sleep checks job-completed every 100msec, it inhibits
# test failing before applying fix.

Thank you.
- Ozaki Kiichi

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] improve ended-job check

2016-10-15 Fir de Conversatie Bram Moolenaar

Ozaki Kiichi wrote:

> I updated patch.
> 
> - remove JOB_WAITED
> - separate job_cleanup process from job_status
> - get off jv_status check from job_still_useful, and new job_still_alive 
> checks
> jv_status and job_still_useful (i.e. job_still_alive is original 
> job_still_useful)

Thanks!

> > Does that fix #1155?
> 
> Unfortunately not. But I will post a fix-patch soon.

-- 
There is no right or wrong, there is only your personal opinion.
 (Bram Moolenaar)

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] improve ended-job check

2016-10-15 Fir de Conversatie Ozaki Kiichi
I updated patch.

- remove JOB_WAITED
- separate job_cleanup process from job_status
- get off jv_status check from job_still_useful, and new job_still_alive checks
jv_status and job_still_useful (i.e. job_still_alive is original 
job_still_useful)


> Does that fix #1155?

Unfortunately not. But I will post a fix-patch soon.

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] improve ended-job check

2016-10-14 Fir de Conversatie LCD 47
On 14 October 2016, Bram Moolenaar  wrote:
> 
> Ozaki Kiichi wrote:
> 
> > Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
> > 10 seconds at the maximum.
> > 
> > I propose the following:
> > 
> > https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db
> > 
> > os_unix: check by waitpid(-1, _, WNOHANG).
> > os_win32: check by WaitForMultipleObjects(),
> > "the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.
> > 
> > They suppress the count of calling syscall to be nearly constant regardless
> > of the number of active jobs.
> > 
> > # I set MAX_ENDED_JOB_COUNT (the maximum number of detections
> > # in job_check_ended()) to 8, but this may require consideration.
> 
> Looks useful.
>
> The JOB_WAITED value does not have a clear meaning.  It looks like we
> know the job has ended, but has not been cleaned up yet.  Perhaps call
> it JOB_EXITED ?

On a side note: a Vim function job_wait() that would do a blocking
wait for a given job would be useful, too.

/lcd

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] improve ended-job check

2016-10-14 Fir de Conversatie Bram Moolenaar

Ozaki Kiichi wrote:

> Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
> 10 seconds at the maximum.
> 
> I propose the following:
> 
> https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db
> 
> os_unix: check by waitpid(-1, _, WNOHANG).
> os_win32: check by WaitForMultipleObjects(),
> "the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.
> 
> They suppress the count of calling syscall to be nearly constant regardless
> of the number of active jobs.
> 
> # I set MAX_ENDED_JOB_COUNT (the maximum number of detections
> # in job_check_ended()) to 8, but this may require consideration.

Looks useful.

The JOB_WAITED value does not have a clear meaning.  It looks like we
know the job has ended, but has not been cleaned up yet.  Perhaps call
it JOB_EXITED ?

-- 
Permission is granted to read this message out aloud on Kings Cross Road,
London, under the condition that the orator is properly dressed.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] improve ended-job check

2016-10-14 Fir de Conversatie Christian Brabandt
Hi Ozaki!

On Fr, 14 Okt 2016, Ozaki Kiichi wrote:

> Hi.
> 
> Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
> 10 seconds at the maximum.
> 
> I propose the following:
> 
> https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db
> 
> os_unix: check by waitpid(-1, _, WNOHANG).
> os_win32: check by WaitForMultipleObjects(),
> "the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.
> 
> They suppress the count of calling syscall to be nearly constant regardless
> of the number of active jobs.
> 
> # I set MAX_ENDED_JOB_COUNT (the maximum number of detections
> # in job_check_ended()) to 8, but this may require consideration.
> 
> Thank you.

Does that fix #1155?

Best,
Christian
-- 
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn
jedermann ist überzeugt, daß er genug davon habe.
-- René Descartes (1596-1650) 

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[patch] improve ended-job check

2016-10-14 Fir de Conversatie Ozaki Kiichi
Hi.

Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
10 seconds at the maximum.

I propose the following:

https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db

os_unix: check by waitpid(-1, _, WNOHANG).
os_win32: check by WaitForMultipleObjects(),
"the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.

They suppress the count of calling syscall to be nearly constant regardless
of the number of active jobs.

# I set MAX_ENDED_JOB_COUNT (the maximum number of detections
# in job_check_ended()) to 8, but this may require consideration.

Thank you.
- Ozaki Kiichi

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.