Commit Graph

51 Commits

Author SHA1 Message Date
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
Avi Kivity
216ac3cdf0 no need to move() in return stmt 2014-08-17 09:38:42 +03:00
Avi Kivity
1ee08b01ab switch pollable_fd to move semantics 2014-08-15 14:50:46 +03:00
Avi Kivity
c539cdcbee short-circuit then() if future is ready 2014-08-15 01:13:08 +03:00
Avi Kivity
cec55519fe future chaining in httpd (reduces perf?) 2014-08-15 00:35:32 +03:00
Avi Kivity
c7a2417c98 allow futures to be chained: fut.then(...).then(...); 2014-08-15 00:35:11 +03:00
Avi Kivity
3140f14697 future::then() callbacks no longer accept a future 2014-08-14 23:55:11 +03:00
Avi Kivity
1c66118a72 wip 2014-08-14 18:05:11 +03:00
Avi Kivity
b6c91052e2 works 2014-08-14 11:07:17 +03:00
Avi Kivity
7ea696c29e checkpoint 2014-08-14 09:20:03 +03:00
Avi Kivity
919e9c4214 checkpoint 2014-08-12 23:52:23 +03:00
Avi Kivity
c3292aeb63 checkpoint 2014-08-12 22:10:20 +03:00
Avi Kivity
96dab351d4 checkpoin 2014-08-12 18:51:17 +03:00
Avi Kivity
ebc58c56c3 checkpoint 2014-08-12 17:06:18 +03:00
Avi Kivity
1b05c9ab9c checkpoint 2014-08-11 17:59:46 +03:00
Avi Kivity
30b73db070 checkpoint 2014-08-10 19:26:30 +03:00