Commit Graph

53948 Commits

Author SHA1 Message Date
Tomasz Grabiec
0141171dae build: make ninja.build depend on configure.py 2014-09-24 15:11:34 +03:00
Gleb Natapov
736b07b2b6 Run http with smp
This patches shows what change is needed for http to run with multiple
event loops. This is not very useful still because actual work is not
yet distributed.
2014-09-24 13:12:38 +03:00
Gleb Natapov
074bc17c71 Stop all smp thread on SIGINT
Execute stop function on all threads on SIGINT. Join them all before
exit.
2014-09-24 13:12:37 +03:00
Gleb Natapov
6253166d0b Extend inter_thread_work_queue to support messaged without return value 2014-09-24 13:12:35 +03:00
Gleb Natapov
0a93385a4d Add smp support
This patch adds an ability to specify how much threads seastart should
spawn. Each thread run its own instance of event loop. Separate
communication channel is created between each pair of threads.
2014-09-24 13:12:33 +03:00
Gleb Natapov
0c7d511858 Allow creation of readable_eventfd from writeable_eventfd and vice-versa
It is needed for two seastart threads to get two sided of the same file
for communication.
2014-09-24 13:12:29 +03:00
Gleb Natapov
a452ede21e Remove unneeded friend declaration 2014-09-24 13:12:24 +03:00
Gleb Natapov
cfbfce3d6d Separate inter_thread_work_queue from thread_pool
Currently thread_pool implements cross-thread communication channel
 internally. Separate communication logic into its own class to
 reuse it for smp communication in later patches.
2014-09-24 13:12:16 +03:00
Asias He
236418d262 net: Support TCP checksum offload
It gives ~5% httpd improvements on monster.

csum-offload option is added, e.g., to disable:

./httpd --network-stack native --csum-offload off
2014-09-24 11:03:39 +03:00
Avi Kivity
0fb796a6c4 tcp: don't store empty packets on unacknowledged queue 2014-09-24 10:54:32 +03:00
Avi Kivity
d7737b34d7 tcp: optimize get_transmit_packets()
Simplify it for the many possible states of the unsent queue:

- empty: return an empty packet
- one small packet: dequeue and return
- one large packet at head: split and return
- many packets, starting with a small one: merge first, split last
2014-09-24 10:52:22 +03:00
Avi Kivity
a1f3708fab packet: optimize sharing
Move reference counting into the deleter core, instead of relegating it
to a shared_deleter (which has to be allocated) and an external reference
counted (also allocated).  This dramatically reduces dynamic allocations.
2014-09-23 18:57:11 +03:00
Avi Kivity
26d713e341 Remove internal_deleter 2014-09-23 18:10:10 +03:00
Avi Kivity
9994e09792 temporary_buffer: stop using internal_deleter
Not much point now since packet doesn't use it.
2014-09-23 18:08:46 +03:00
Avi Kivity
75f07adb69 packet: store header data inside packet itself
Instead of using internal_deleter, which is unwieldy, store the
header data inside packet::impl which we're allocating anyway.

This adds some complication when we need to reallocate impl (if
the number of fragments overflows), but usually saves two allocations:
one for the internal_deleter and one for the data itself.
2014-09-23 18:02:18 +03:00
Avi Kivity
e223f748ec core: great deleter rename
deleter::share() is causing massive amounts of allocation.  First,
since usually a packet's deleter is not a shared_deleter, we need to
allocate that shared_deleter.  Second, we need an external reference
count which requires yet another allocation.

Making reference counting part of the deleter class would solve both of
these problems, but we cannot easily do that, since users hold
std::unique_ptr<deleter> which is clearly not sharable.

We could do a massive s/unique_ptr/shared_ptr/ here, but that would have
the side effect of making sharing "too easy" - you simply copy the pointer.
We'd like to keep it explicit.

So to make the change easier, rename the existing unique_ptr<deleter> as
plain "deleter", whereas the old "deleter" becomes deleter::impl:

  old name              new name
  --------              --------
  deleter               deleter::impl
  unique_ptr<deleter>   deleter

with exactly the same semantics.  A later patch can then add explicit sharing.
2014-09-23 11:15:31 +03:00
Avi Kivity
c096787c8c net: specialize single-fragment data_sink::put() for native stack
Saves a vector allocation and some loops.
2014-09-23 10:37:56 +03:00
Avi Kivity
bca61c198f core: add non-vectored data_sink::put() specialization
Often the caller doesn't have a vector, just a single buffer, so allow
the implementation to optimize for that.
2014-09-23 10:37:56 +03:00
Avi Kivity
e76328b2c9 packet: add zero-copy single-fragment constructor
Useful for converting a temporary_buffer<> into a packet.
2014-09-23 10:37:56 +03:00
Avi Kivity
bddbb3d938 temporary_buffer: add release() method
This allows the caller to take responsibility for deleting the data.

Useful when different data structures use the deleter infrastructure.
2014-09-23 10:37:56 +03:00
Avi Kivity
96cc1440a8 build: disable lto
Too unstable.
2014-09-23 10:37:56 +03:00
Tomasz Grabiec
9816422a67 core: fix SIGSEGV in future::then()
This fixes SIGSEGV which happens when a promise gets resolved and
dies before the callback is registerred via then(). The latter assumes
that _promise must not be nullptr if the state is not resolved
yet. The dying promise should move the resolved state into the
future's local state.
2014-09-22 23:11:13 +03:00
Tomasz Grabiec
ef03d2957f core: make complete_epoll_event() cancel out the right event.
Led to hangs if the client interleaved readable() with writable()
2014-09-22 23:11:12 +03:00
Avi Kivity
d131b4cce3 packet: optimize appending to an empty packet
The tcp does this quite often, so optimize this trivial append by
moving the packet in.
2014-09-22 17:57:18 +03:00
Avi Kivity
f131492695 tcp: fix harmless struct/class mismatch 2014-09-22 17:19:44 +03:00
Avi Kivity
907792fe26 net: ipv4: remove unused field to please clang 2014-09-22 17:19:15 +03:00
Avi Kivity
195ee5c82f bitset: make functions inline to please compiler 2014-09-22 17:18:46 +03:00
Avi Kivity
46402831ae httpd: remove unused fields to make clang happy 2014-09-22 17:18:06 +03:00
Pekka Enberg
0dfdd3e548 Use braces around subobject initialization
There seems to be some issue with std::array initialization brace elision with Clang:

  http://stackoverflow.com/questions/16985687/brace-elision-in-stdarray-initialization

Sprinkle enough braces to make Clang happy.
2014-09-22 16:37:00 +03:00
Pekka Enberg
4550632738 Make count_leading_zeros() an inline function
Mark the function as inline to avoid Clang complaining about unused function.
2014-09-22 16:36:56 +03:00
Avi Kivity
6dc0e9ba79 packet: fix allocation failure path
Since we allocate impl with a custom allocator, we must provide a
custom deallocator in case the constructor throws.

Found by Pekka and clang.
2014-09-22 15:53:04 +03:00
Avi Kivity
9501601727 tcp: checksum incoming packets
Will be obsoleted by checksum offload, but good for completeness.
2014-09-22 15:46:43 +03:00
Avi Kivity
abbc62588b net: checksum incoming ipv4 packets 2014-09-22 15:46:35 +03:00
Avi Kivity
969892d66e tcp: fix ntoh/hton mixup
No effect on code, but clears a mental wtf.
2014-09-22 15:46:16 +03:00
Avi Kivity
7f7a550f98 net: extend packet by doubling fragment vector size
Avoid quadratic behavior
2014-09-22 14:26:34 +03:00
Avi Kivity
4ca2d67406 tcp_test: terminate on connection closed 2014-09-22 14:22:17 +03:00
Avi Kivity
280bf1a5c8 tcp: wait_for_data() should return immediately if data is available 2014-09-22 14:21:43 +03:00
Avi Kivity
4c10d9c270 packet: fix early free when extending packet
If the fragment vector runs out of space, we extend it, but we forgot
to move the deleter, resulting in an early free.  Flagged by address
sanitizer.
2014-09-22 14:14:37 +03:00
Avi Kivity
dd88f66825 tcp: fix sequence number when we have unacknowledged data
We kept sending _send.unacknowledged, so we sent the sequence number for
the previous packet.

Use _send.next instead.
2014-09-22 12:57:07 +03:00
Avi Kivity
4ce192c3e0 net: drop 'dropping packet' message
No longer useful.
2014-09-22 11:55:37 +03:00
Avi Kivity
313768654a net: remove queuing from l2->l3 rx path
Use a subscription instead.  Queueing should be implemented at the highest
possible level (e.g. tcp), to avoid double-queueing.
2014-09-22 11:28:35 +03:00
Avi Kivity
bc8df09984 virtio-net: remove internal rx queue 2014-09-22 11:28:35 +03:00
Avi Kivity
4738f3f05c net: switch device rx to stream<packet>
Still have that internal rx queue.
2014-09-22 11:27:47 +03:00
Avi Kivity
af1c015526 core: add stream/subscription abstraction
The future/promise pair is for single-shot use only, which makes it
less useful for repetitive processing.

Add a stream/subscription abstraction, where a stream can produce data
which is repetitively consumed by the subscription.  End-or-stream (or
error condition) is provided by a future.

Inspired by Dart's Stream class.
2014-09-22 11:25:54 +03:00
Avi Kivity
3b1d37ff2f future: implement available()
As the whole point of future/promise is to decouple the producer from the
consumer, available() is not generally useful.  However it can still be
useful in special cases when we want to know who got there first.

One of them is deciding when to drop packets -- if the consumer is not
ready, and no queue space is available, we should just drop the packet
instead of waiting for the consumer.
2014-09-22 11:25:54 +03:00
Avi Kivity
1d11ecfbcd future: implement move assignment 2014-09-22 11:25:54 +03:00
Avi Kivity
64ce457053 future: fix move constructor
If we're no longer tracking the promise (either gone, or never existed),
we shouldn't update it.
2014-09-22 11:25:54 +03:00
Asias He
4dc70e95c7 virtio: Add --event-index option
Virtio net options:
  --event-index arg (=on) Enable event_index feature (on / off)

By default, --event-index is enable. To disable, e.g.:

   $ ./httpd --network-stack native --event-index off
2014-09-22 11:22:59 +03:00
Asias He
1472e8f282 virtio: Add event-index support 2014-09-22 11:22:58 +03:00
Gleb Natapov
588fe22a8b README: add libasan to prerequisites 2014-09-21 13:39:48 +03:00