unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: trunk r116456: Improve dbus performance on synchronous calls
       [not found] <E1WFMaG-0002WV-8L@vcs.savannah.gnu.org>
@ 2014-02-17 16:06 ` Michael Albinus
  2014-02-17 16:17   ` Daniel Colascione
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2014-02-17 16:06 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: emacs-devel

Daniel Colascione <dan.colascione@gmail.com> writes:

>      (with-timeout ((if timeout (/ timeout 1000.0) 25))
>        (while (eq (gethash key dbus-return-values-table :ignore) :ignore)
> -	(let ((event (let ((inhibit-redisplay t) unread-command-events)
> -		       (read-event nil nil 0.1))))
> -	  (when (and event (not (ignore-errors (dbus-check-event event))))
> -	    (setq unread-command-events
> -		  (append unread-command-events (list event)))))))
> +        (let ((event (let ((inhibit-redisplay t) unread-command-events)
> +		       (read-event nil nil check-interval))))
> +          (when event
> +            (push event unread-command-events))
> +          (when (< check-interval 1)
> +            (setf check-interval (* check-interval 1.05))))))

Why `push'? It adds the event on top of `unread-command-events',
changing the event order when there are already events in that list.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: trunk r116456: Improve dbus performance on synchronous calls
  2014-02-17 16:06 ` trunk r116456: Improve dbus performance on synchronous calls Michael Albinus
@ 2014-02-17 16:17   ` Daniel Colascione
  2014-02-17 16:41     ` dancol
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Colascione @ 2014-02-17 16:17 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

On 02/17/2014 08:06 AM, Michael Albinus wrote:
> Daniel Colascione <dan.colascione@gmail.com> writes:
>
>>       (with-timeout ((if timeout (/ timeout 1000.0) 25))
>>         (while (eq (gethash key dbus-return-values-table :ignore) :ignore)
>> -	(let ((event (let ((inhibit-redisplay t) unread-command-events)
>> -		       (read-event nil nil 0.1))))
>> -	  (when (and event (not (ignore-errors (dbus-check-event event))))
>> -	    (setq unread-command-events
>> -		  (append unread-command-events (list event)))))))
>> +        (let ((event (let ((inhibit-redisplay t) unread-command-events)
>> +		       (read-event nil nil check-interval))))
>> +          (when event
>> +            (push event unread-command-events))
>> +          (when (< check-interval 1)
>> +            (setf check-interval (* check-interval 1.05))))))
>
> Why `push'? It adds the event on top of `unread-command-events',
> changing the event order when there are already events in that list.

Hrm. I was getting it from sit-for:

(let ((read (read-event nil t seconds)))
       (or (null read)
	  (progn
	    ;; If last command was a prefix arg, e.g. C-u, push this event onto
	    ;; unread-command-events as (t . EVENT) so it will be added to
	    ;; this-command-keys by read-key-sequence.
	    (if (eq overriding-terminal-local-map universal-argument-map)
		(setq read (cons t read)))
	    (push read unread-command-events)
	    nil)))

Speaking of which, shouldn't the dbus code just look like this?

(with-timeout ((if timeout (/ timeout 1000.0) 25))
       (while (eq (gethash key dbus-return-values-table :ignore) :ignore)
         (sit-for check-interval t)
         (when (< check-interval 1)
           (setf check-interval (* check-interval 1.05)))))




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: trunk r116456: Improve dbus performance on synchronous calls
  2014-02-17 16:17   ` Daniel Colascione
@ 2014-02-17 16:41     ` dancol
  2014-02-17 21:08       ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: dancol @ 2014-02-17 16:41 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Michael Albinus, emacs-devel

> On 02/17/2014 08:06 AM, Michael Albinus wrote:
>> Daniel Colascione <dan.colascione@gmail.com> writes:
>>
>>>       (with-timeout ((if timeout (/ timeout 1000.0) 25))
>>>         (while (eq (gethash key dbus-return-values-table :ignore)
>>> :ignore)
>>> -	(let ((event (let ((inhibit-redisplay t) unread-command-events)
>>> -		       (read-event nil nil 0.1))))
>>> -	  (when (and event (not (ignore-errors (dbus-check-event event))))
>>> -	    (setq unread-command-events
>>> -		  (append unread-command-events (list event)))))))
>>> +        (let ((event (let ((inhibit-redisplay t)
>>> unread-command-events)
>>> +		       (read-event nil nil check-interval))))
>>> +          (when event
>>> +            (push event unread-command-events))
>>> +          (when (< check-interval 1)
>>> +            (setf check-interval (* check-interval 1.05))))))
>>
>> Why `push'? It adds the event on top of `unread-command-events',
>> changing the event order when there are already events in that list.
>
> Hrm. I was getting it from sit-for:

Nope. You're right: fixed. Thanks for pointing that out.

> Speaking of which, shouldn't the dbus code just look like this?

No, that won't work. It's single-shot.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: trunk r116456: Improve dbus performance on synchronous calls
  2014-02-17 16:41     ` dancol
@ 2014-02-17 21:08       ` Michael Albinus
  2014-02-17 21:42         ` Daniel Colascione
  2014-02-18  0:00         ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Albinus @ 2014-02-17 21:08 UTC (permalink / raw)
  To: dancol; +Cc: emacs-devel

dancol@dancol.org writes:

>>> Why `push'? It adds the event on top of `unread-command-events',
>>> changing the event order when there are already events in that list.
>>
>> Hrm. I was getting it from sit-for:
>
> Nope. You're right: fixed. Thanks for pointing that out.

Maybe `sit-for' is wrong then as well? I haven't checked ever (and
situations, where `unread-command-events' contains more than one event
seem to be rare).



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: trunk r116456: Improve dbus performance on synchronous calls
  2014-02-17 21:08       ` Michael Albinus
@ 2014-02-17 21:42         ` Daniel Colascione
  2014-02-18  0:00         ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Colascione @ 2014-02-17 21:42 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

On 02/17/2014 01:08 PM, Michael Albinus wrote:
> dancol@dancol.org writes:
>
>>>> Why `push'? It adds the event on top of `unread-command-events',
>>>> changing the event order when there are already events in that list.
>>>
>>> Hrm. I was getting it from sit-for:
>>
>> Nope. You're right: fixed. Thanks for pointing that out.
>
> Maybe `sit-for' is wrong then as well? I haven't checked ever (and
> situations, where `unread-command-events' contains more than one event
> seem to be rare).

sit-for is right: it's reading one event, then immediately sticking it 
back on the queue. Push is exactly the right operation there.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: trunk r116456: Improve dbus performance on synchronous calls
  2014-02-17 21:08       ` Michael Albinus
  2014-02-17 21:42         ` Daniel Colascione
@ 2014-02-18  0:00         ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2014-02-18  0:00 UTC (permalink / raw)
  To: Michael Albinus; +Cc: dancol, emacs-devel

> Maybe `sit-for' is wrong then as well?

No, the `push' is right: if unread-command-events is non-nil at that
point, it means it holds events which `read-event' did not read yet
(and hence come *after* the event we just received).


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-18  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1WFMaG-0002WV-8L@vcs.savannah.gnu.org>
2014-02-17 16:06 ` trunk r116456: Improve dbus performance on synchronous calls Michael Albinus
2014-02-17 16:17   ` Daniel Colascione
2014-02-17 16:41     ` dancol
2014-02-17 21:08       ` Michael Albinus
2014-02-17 21:42         ` Daniel Colascione
2014-02-18  0:00         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).