cs161 2004 Lecture 4 (non traditional, faster, I/O) We've been talking about being careful about I/O. Under what circumstances will we still be CPU bound? Look at code, find the inefficiencies. int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); fixed size, copy all, scan all int poll(struct pollfd *ufds, unsigned int nfds, int timeout); copy all, scan all (redo work for each fd for each call) /dev/poll sys_epoll (epoll_create, epoll_ctl, epoll_wait) edge vs level If level, you must register and deregister more often If edge, you must track more on your own If you "miss an event" you're in trouble. Likely? Remaining problems? Unifying event sources (signals vs aio vs timers vs poll vs futexes (locks)) Zero-copy Small frames or packets: TCP_CORK, ACK+data Behave under overload (Seda, livelock) io-lite background files: buffer cache / vm net: mbufs new primitives: immutable buffers, page aligned mutable "buffer aggregates" - ordered list of pairs what happens with a IOL_read, followed by IOL_write in another process? optimizations get rid of copies (memory IO and cpu caching effects) get rid of redundant buffers (more room for memory caches) cross-layer (checksums) buffer control (Greedy Dual Size) Assign a value of cost/size to each cached resource. Add value of lowest resources to the value of an accessed resource made faster: disk i/o? no (mmap) IPC? yes (no copy) caveat: decide ahead of time who you will send to net? yes (copyless, and readless when repeated (chksum)) WAN is particularly nice, memory savings what wouldn't be helped? ssl server very small I/Os (VM ops cost more than small copies) compressed content? (if there are dynamic pieces, can't cache the rest) new bug? - unintentended sharing (mmu is page level) Actually, ACL must be predeclared So, rather than the bug, IOL forces a copy in that situation But one common case, CGIs is analogous to user/kernel. Just trust. A case that isn't? Databases stdio? Can pipe work transparently? Seems to need ACL. So what does?