Commit Graph

66 Commits

Author SHA1 Message Date
Avi Kivity
a7930ffcaa net: rework packet class
1. Replace the completion promise<> with a custom deleter class; this
   is lighter weight, and we don't really need the destructor to be
   executed by the scheduler.
2. Add lots of consuctors for composing packets from existing packet,
   by appending or prepending packets
3. Over-allocate in some cases to accomodate for the common practice of
   prepending protocol headers.
2014-08-28 17:29:27 +03:00
Avi Kivity
e697091201 build: link with libtcmalloc
~14% improvement.
2014-08-27 20:25:53 +03:00
Tomasz Grabiec
9813207ed2 build: fix the build on Ubuntu
The build fails for me like this:

/tmp/ccOUUuiH.ltrans0.ltrans.o: In function `reactor::reactor()':
/home/tgrabiec/src/seastar/build/release/../../reactor.cc:41: undefined reference to `io_setup'
/tmp/ccOUUuiH.ltrans1.ltrans.o: In function `reactor::process_io()':
/home/tgrabiec/src/seastar/build/release/../../reactor.cc:133: undefined reference to `io_getevents'
collect2: error: ld returned 1 exit status
../../build.mk:27: recipe for target 'seastar' failed

The workaround was taken from
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
[avi: move to separate line with comment to justify the ugliness]
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-08-27 19:56:25 +03:00
Avi Kivity
b957650a03 build: simplify link rules 2014-08-27 19:17:03 +03:00
Avi Kivity
64c8302f39 Move more posix functions to posix.hh
This simplifies checking for errors, especially in constructors.
2014-08-27 18:26:54 +03:00
Avi Kivity
268d24170d Make posix.hh independent of reactor.hh
Move throw_system_error_on() and friends into it.
2014-08-27 17:37:10 +03:00
Tomasz Grabiec
34667e8dfe reactor: fix io_setup() failure
_io_context must be set to 0, otherwise io_setup fails with -EINVAL.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-08-27 17:32:39 +03:00
Avi Kivity
462a285dc1 Add simple virtio test
Able to reply to broadcase ping (ping -b 192.168.122.2)
2014-08-27 17:25:42 +03:00
Avi Kivity
67952a24d4 Add IPv4 definitions and helpers 2014-08-27 17:25:19 +03:00
Avi Kivity
bdd0125116 build: don't unconditionally build with -flto
mode=release will do it itself.
2014-08-27 17:24:29 +03:00
Avi Kivity
888298778a build: pass mode to sub-make 2014-08-27 17:24:17 +03:00
Avi Kivity
5b27163071 Add rudimentary virtio support
Supported:
 - basic virtio ring pump
 - basic virtio-net driver (most features missing)
 - vhost interface (running as a privileged user process, not guest)
2014-08-27 17:22:13 +03:00
Avi Kivity
6b265e9c33 Add network stack interface definitions 2014-08-27 17:21:41 +03:00
Avi Kivity
85e3645866 Extend semaphore with try_wait() 2014-08-27 17:21:12 +03:00
Avi Kivity
1cfa018243 Add helper for creating structures ending with variable-length arrays 2014-08-27 17:20:34 +03:00
Avi Kivity
90b766db2e Add C++ wrappers of common posix functionality 2014-08-27 17:20:06 +03:00
Avi Kivity
344a4fe4bc Add Linux virtio interface definitions
The Linux virtio/vhost headers are too polluted to be included from C++
code, so create a local copy.
2014-08-27 17:18:38 +03:00
Avi Kivity
68a66b3c14 Add .gitignore 2014-08-25 09:28:55 +03:00
Avi Kivity
f7da882a40 build: generate objects in build directory 2014-08-25 09:26:53 +03:00
Avi Kivity
53dcf701b9 Encapsulate eventfd into classes
Typically one side (read or write) of the eventfd is used within the
framework, and the other side is used by an external process, so two
classes are provided, depending on which side is used in the framework.

The new classes are used with the thread pool.
2014-08-24 19:44:52 +03:00
Avi Kivity
745a420aea Move pollable_fd around for later reuse 2014-08-24 19:44:22 +03:00
Avi Kivity
7899894643 httpd: handle errors 2014-08-24 18:08:38 +03:00
Avi Kivity
547756ce95 Exception handling support
- If a .then() clause, whose chained function returns a future, throws an
  exception, then the returned future will contain the exception.  A chain
  of .then() clauses will propagae the exception until the end.
- Add a .rescue() clause that can be used to catch the exception
2014-08-24 15:52:18 +03:00
Avi Kivity
fedb0d787f fileiotest: flush after completing the test 2014-08-24 11:05:05 +03:00
Avi Kivity
754a245d59 Implement file::flush() 2014-08-24 11:04:59 +03:00
Avi Kivity
2bec091b9e Fix future chaining with 0-argument futures 2014-08-24 11:04:42 +03:00
Avi Kivity
3f1c383e46 Fix is_future<> for non-single-argument futures
is_future<> did not support zero-argument (future<>) and multiple argument
futures.
2014-08-24 11:03:27 +03:00
Avi Kivity
239f76c342 Implement open_file_dma() using the thread pool 2014-08-24 10:42:12 +03:00
Avi Kivity
ebd10bf349 Add a thread pool to augment kernel support for aio
Some operations cannot be done either non-blockingly or asynchronously, so
add a thread pool to execute them in.

Currently the thread pool has just one thread.
2014-08-24 10:42:10 +03:00
Avi Kivity
7f609a1959 fileiotest: limit concurrency
Otherwise, all of the writes are submitted at once, consuming tons of memory,
and preventing reads from happening in parallel to writes.

Add a semaphore to limit the amount of parallel I/O.
2014-08-24 10:30:54 +03:00
Avi Kivity
91f10b8a9c Add asynchronous I/O test
- launch 10,000 concurrent writes
 - when any one of these complete, launch a read for the same offset
 - compare read/write data
 - when all reads complete, terminate
2014-08-21 14:01:51 +03:00
Avi Kivity
ec7b440a99 Add asynchronous file I/O
- add dma read/write operations
 - open() is presently synchronous
2014-08-21 14:01:22 +03:00
Avi Kivity
f05e31dfc8 Asynchronous I/O infrastructure
Add integration with the Linux libaio framework:

 - an I/O context is initialized
 - all asynchronous I/Os request that the kernel notify an eventfd
 - a semaphore is used to guard access to the I/O context, so as not to
   exceed the maximum parallelism
 - an internal function submit_io() is used to submit I/O to the kernel,
   returning a future representing completion
 - an internal loop running process_io() is used to consume completions
   when the eventfd is signalled
2014-08-21 13:58:19 +03:00
Avi Kivity
cfeec3799e Add a an asynchronous semaphore class 2014-08-21 13:52:14 +03:00
Avi Kivity
f96b0d5b53 Move pollable_fd_state around
Allows using it inside class reactor.
2014-08-21 13:52:04 +03:00
Avi Kivity
10695644d7 Get rid of regex in http parser
It's slow.  Replacing it doubles throughput to 110K req/s.
2014-08-20 16:37:11 +03:00
Avi Kivity
26527252c5 Remove accept_result 2014-08-20 11:31:01 +03:00
Avi Kivity
b9148304b6 Make future<> and friends a variadic template
This removes the need to create a structure if a future has multiple
return values, and has the nice side effect of removing the specialization
future<void> (replacing it with future<>).
2014-08-20 11:24:32 +03:00
Avi Kivity
8b3690af80 Add apply(func, tuple)
Helper that calls a function with the tuple's components as arguments.
2014-08-20 11:18:23 +03:00
Avi Kivity
2207e8e5f3 Add make_ready_future() helper when no async work needs to be done
Use where applicable.
2014-08-18 16:59:25 +03:00
Avi Kivity
ccb052a418 Speculate epoll results
In many cases, we can guess the result of an epoll_wait() before it happens:
 - if a read() or write() consumes the entire buffer, a following call
   will likely succeed (and if it doesn't, it likely won't)
 - after an accept() completes, a write() will likely succeed

Speculatively add these events to events_known; if we mispredict and
fail with EAGAIN, all we need to do is retry.
2014-08-18 15:52:52 +03:00
Avi Kivity
b9ebc652cb Extract epoll completion handling into a helper 2014-08-18 14:46:02 +03:00
Avi Kivity
96b813fbfc Lazy epoll management
Reduce calls to epoll_ctl() by allowing epoll events that are not
requested by the user, but have still not been satisfied by the system,
to remain installed in epoll.  We may get a spurious wakeup later, but if
we do, we remember it so that when the user does want the event, it will be
ready without a syscall.
2014-08-18 13:04:44 +03:00
Avi Kivity
784b2bf3ed Extract common parts of reactor::readable() and reactore::writeable() into a helper 2014-08-18 12:36:01 +03:00
Avi Kivity
b10da4fa1d Switch epoll_add_int()/epoll_add_out() to future<void>
This integrates better with the rest of the framework, and allows
adding specializations such as likely_readable() easily.
2014-08-18 10:56:36 +03:00
Avi Kivity
c8e04c8cd9 Implement missing future<void> specializations 2014-08-18 10:56:09 +03:00
Avi Kivity
22f0721a39 Implement missing promise<> move assignment 2014-08-18 10:55:43 +03:00
Avi Kivity
ecf989901f future<void> specialization 2014-08-18 00:23:55 +03:00
Avi Kivity
acdf96947c fix promise deleted copy constructor 2014-08-18 00:23:55 +03:00
Avi Kivity
ef749bf26c fix assigning exception to future 2014-08-18 00:23:55 +03:00