Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIP] Intent to implement epoll()/kqueue() support for sockets on Linux/FreeBSD #14

Open
lalbornoz opened this issue Nov 22, 2016 · 11 comments

Comments

@lalbornoz
Copy link

lalbornoz commented Nov 22, 2016

Nov 23 4:30 PM:
epoll() support on Linux in the event loop (tclUnixNotfy.c) implemented; some testing done.
Nov 23 6:04 PM:
kqueue/kevent() support on FreeBSD in the event loop (tclUnixNotfy.c): code written, compiles.
Nov 23 7:52 PM:
Cleanup; refactored code into four subroutines. Now commencing testing/bugfixing.
Nov 24 12:16 PM:
Code review; will contact tcl-core tomorrow.
Nov 24 4:19 PM:
Preliminarily pushed to https://github.com/lalbornoz/tcl (`epoll' branch.)
Nov 25 1:51 PM:
Initial tcl-core contact.
Nov 25 5:18 PM:
http://www.tcl.tk/cgi-bin/tct/tip/458.html
Dec 6 7:33 PM:
Supports DragonFly/Free/Net/OpenBSD and Linux; running relevant tests/* on those platforms and fixing bugs that come up.

@dkfellows
Copy link

@lalbornoz lalbornoz changed the title Intent to implement epoll()/kqueue() support for sockets on Linux/FreeBSD [TIP] Intent to implement epoll()/kqueue() support for sockets on Linux/FreeBSD Nov 26, 2016
@lalbornoz
Copy link
Author

lalbornoz commented Dec 11, 2016

tests/* now all complete successfully on FreeBSD and Linux as of <96b5aa3016ee4e41b81534fbcccbab168d1a9338>,
with a small number of tests that fail on Tcl v8.6.6 as well as w/ the new code. The output logs of $ make test w/ Tcl v8.6.6 and HEAD on both FreeBSD and Linux can be found in tcl*_tests.log in the Github repository.
The specific issue on FreeBSD appears to be that Linux returns EINPROGRESS for a connect(2) to an address that can synchronously be completed w/ ECONNREFUSED, whereas FreeBSD always returns ECONNREFUSED. This causes TcpConnect() to return TCL_ERROR instead of TCL_OK; the tests however expect either TCL_OK or TCL_RETURN and thus fail.
FYI: the code now lives in the `tip458' branch of https://github.com/lalbornoz/tcl/.

@lalbornoz
Copy link
Author

Awaiting feedback/vote/...

@lehenbauer
Copy link
Collaborator

OK, we are testing this.

@lalbornoz
Copy link
Author

My new code was just committed: http://core.tcl.tk/tcl/info/858569fb0484a15478f8583287a263ac6215f20c. Assuming there are no remaining concerns, I'd like to claim the bounty.

@nijtmans
Copy link

TIP vote is done (accepted), and implementation is on trunk (8.7) now. Congratuations!

@bll123
Copy link

bll123 commented Oct 26, 2017

FYI: The new epoll() code does not work correctly.
https://core.tcl.tk/tcl/tktview?name=1a6a36d901

@lalbornoz
Copy link
Author

lalbornoz commented Oct 26, 2017

I've pushed a fix concerning epoll_wait() timeout calculation in lalbornoz/tcl@7249454.
Can you confirm that this reduces CPU usage down to expected values w/ both the busyWait as well as the disconnected sockets tests?

@bll123
Copy link

bll123 commented Oct 26, 2017

Looks much better.
I ran the busy-wait test, use of dbus package test.

I don't have a specific test built for the disconnected socket, but I pulled up an older copy of my application and it seems ok.

With the patch (busy-wait test):
bll-tecra:bll$ time $HOME/local87/bin/tclsh8.7 t.tcl
^C

real 0m7.413s
user 0m0.029s
sys 0m0.005s

@dkfellows
Copy link

Let me guess from the patch; the timeout was meant to be in ms, yet was being fed seconds?

@lalbornoz
Copy link
Author

Precisely; the kqueue(2)-based notifier correctly converts between struct time{val,spec} and thus only Linux was/is affected.

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

No branches or pull requests

5 participants