Musings /Scratch Pad¶
Scratch pad of design ideas and considerations (needs pruning!)
Contents
Misc¶
⬜ Python ASGI
⬜ Use ecb.h?
⬜ Timed-idle watchers — do stuff at least-so often, if not sooner.
⬜ Dynamic loader for pluggable protocols
⬜ add support for edge-triggered IO (i.e. keep recv’ing until block)?
- ⬜ Move “server” code - socket(), bind(), etc - into optional server
functionality. i.e. The library should just provide the IO, for the most part.
⬜ where appropriate utilize feature test macros
Network IO¶
Polling¶
[x] libev (current)
[ ] libapr_poll_t (why?)
[ ] nanomsg (why?)
SIGPIPE¶
- Globally (signal/sigaction):
use signal/sigaction
most ubiquitious/easiest
least friendly to user code
possibly slowest?
Thread-wide (pthread_sigmask)
At the socket level,
POSIX
-style (fcntl w/F_GETNOSIGPIPE
/F_SETNOSIGPIPE
)At the socket level, BSD-style (setsockopt w/
SO_NOSIGPIPE
)At the socket level, SysV-style (no possible via ioctl???)
- At read/write time (
MSG_NOSIGNAL
) requires send/recv/sendmsg/recvmsg over write/read/writev/readv
not portable?
- At read/write time (
Notes¶
on Darwin
F_SETNOSIGPIPE
invokes setsockopt w/SO_NOSIGPIPE
under the covers- the file-level
O_NONBLOCK
flag is used by the kernel to setMSG_DONTWAIT
at send/recv time!! (see net/socket.c)
- the file-level
- the
FIONBIO
ioctl call results inO_NONBLOCK
fd-level flag being set (see fs/ioctl.c)
- the
- Mac OS X does have
MSG_DONTWAIT
, etc. It’s only forDARWIN
or Non-POSIX
sources.
- Mac OS X does have
- Also, look into xnu and linux sources for other goodies such as:
MSG_NBIO
FNONBLOCK
O_NDELAY
etc
- All relevant non-blocking flags, to date:
FIONBIO
FNONBLOCK
MSG_NBIO
MSG_DONTWAIT
O_NDELAY
O_NONBLOCK
- Sending files:
Use sendfile, where available
Use mmqp + write, otherwise
Flow control¶
TCP_NODELAY
for urgent packets (when/why?)TCP_CORK
for manual packet coalescing (when/why?)
Performance¶
Use computed goto’s instead of switch statements?
- NO: Consider page locking to prevent the most common page faults (that’s super
rude, though…)
NO: Consider interacting with the scheduler via sched.h