[issue30014] Speedup DefaultSelectors.modify() by 1.5x

2017-04-07 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30014] Speedup DefaultSelectors.modify() by 1.5x

2017-04-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

> The idea is to reuse _BaseSelectorImpl.register() and
> _BaseSelectorImpl.unregister() to factorize the code.

You can't factorize the logic of modify() into those as they do two different 
things. I also don't like repeating the same thing 3 times but given how the 
module is organized I'm not sure how to do that as I need to pass 3 things 
around: the low-level selector (epoll, poll, whatever) and the read and write 
constants (POLLIN, EPOLLIN) which change depending on the selector being used.
The same thing applies to the devpoll class (http://bugs.python.org/issue18931).
I can write a second patch which to refactor the whole module if that is 
desirable but I prefer to do that in another PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30014] Speedup DefaultSelectors.modify() by 1.5x

2017-04-07 Thread STINNER Victor

STINNER Victor added the comment:

> Doesn't that mean doing 3 operations (unregister(), register(), modify()) 
> instead of the current 2 (unregister(), register())? I don't see how it can 
> be faster than a single modify() syscall.

The idea is to reuse _BaseSelectorImpl.register() and 
_BaseSelectorImpl.unregister() to factorize the code. These methods don't use 
syscall, they create the SelectorKey object and update _fd_to_key. So each 
class doesn't have to redo these things.

I don't insist to redo what I did, I'm just trying to explain my change because 
your change basically copy/paste the same code 3 times, and you forgot 
KqueueSelector, so you even may have to copy it a 4th time ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30014] Speedup DefaultSelectors.modify() by 1.5x

2017-04-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

> My patch calls generic unregister() and register() of the base
> classes, but it only uses one syscall per modify() call.

Doesn't that mean doing 3 operations (unregister(), register(), modify()) 
instead of the current 2 (unregister(), register())? I don't see how it can be 
faster than a single modify() syscall.

> Oh by the way, it seems like my patch changes KqueueSelector, 
> but your change doesn't. Am I right?

You are right but it looks like you end up doing the same thing as unregister() 
and register(). kqueue() has no modify() method so I don't think it can benefit 
from this change.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30014] Speedup DefaultSelectors.modify() by 1.5x

2017-04-07 Thread STINNER Victor

Changes by STINNER Victor :


--
title: Speedup DefaultSelectors.modify() by 2x -> Speedup 
DefaultSelectors.modify() by 1.5x

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com