Commit Graph

53948 Commits

Author SHA1 Message Date
Gleb Natapov
01a1c1c3c2 smp: delete non existent function declaration listen_one() 2014-10-26 10:30:48 +02:00
Avi Kivity
bb522a5592 Revert "keep_doing: fix memory leak"
This reverts commit 5a3e4f20e3.  After
74ac65a491 ("core: optimize future::forward_to()"), it is no longer
needed.
2014-10-24 22:25:46 +03:00
Avi Kivity
734b758470 Merge branch 'tcp-include'
Reduce #includes of tcp.hh.
2014-10-24 22:24:40 +03:00
Avi Kivity
9fbd13175b net: move mechanics of listening to a tcp connection to tcp.cc
Removes an include of tcp.hh.
2014-10-24 22:18:54 +03:00
Avi Kivity
e18b77d5cd udp: add missing include 2014-10-24 22:18:54 +03:00
Avi Kivity
04db837450 net: move native stack implementation classes to new header file
This will allow us to instantiate them for tcp in tcp.cc, reducing
compile times.
2014-10-24 22:18:54 +03:00
Avi Kivity
332cd6424b ip: use indirection to access tcp
This reduces the number of files that include tcp.hh.
2014-10-24 22:18:46 +03:00
Avi Kivity
ec7b5eeed2 tcp: move ipv4_tcp implementation into tcp.cc
First step in isolating tcp from the rest of the stack.
2014-10-24 21:45:20 +03:00
Avi Kivity
6b23750255 Merge branch 'avi/distributed' of github.com:cloudius-systems/seastar-dev
"Often, a function we wish to execute on another cpu will not be able to
complete immediatley.  This patchset allows it to return a future; the caller
will not be resumed until that future is ready."
2014-10-24 19:46:59 +03:00
Avi Kivity
658d52589e Merge branch 'asias/tcp' of github.com:cloudius-systems/seastar-dev 2014-10-24 19:43:57 +03:00
Tomasz Grabiec
0cf6564097 tests: add tests for future::forward_to() 2014-10-24 19:40:48 +03:00
Tomasz Grabiec
74ac65a491 core: optimize future::forward_to()
We can avoid extra allocation and chaining by linking the current
future's promise with the target promise's future, as if the target
promise was moved into the current future's promise.
2014-10-24 19:40:48 +03:00
Asias He
c08879edea tcp: Do not advertise zero window when ACK remote FIN
Follow Linux's behavior.
2014-10-24 16:27:00 +08:00
Asias He
fb0123ec61 tcp: Ack data and FIN in a single packet 2014-10-24 16:25:35 +08:00
Asias He
cbc5e9392f tcp: Send <ACK> packet to ack data only when data is present 2014-10-24 16:24:06 +08:00
Asias He
6018b27bab tcp: Add comments for SYN 2014-10-24 16:23:25 +08:00
Asias He
4717d0bc48 net: Rename stack -> native-stack 2014-10-24 09:14:16 +08:00
Asias He
d251f33123 net: Remove unnecessary include of "stack.hh" 2014-10-24 09:10:23 +08:00
Avi Kivity
5a3e4f20e3 keep_doing: fix memory leak
keep_doing() keeps chaining futures until it stops, usually never, resulting
in a de-facto memory leak (even though all the memory is still reachable).

Fix by avoiding the chainining, re-using the same promise over and over again.
2014-10-23 19:24:29 +03:00
Avi Kivity
7428717be9 keep_doing: cosmetics 2014-10-23 16:57:36 +03:00
Avi Kivity
1f80f7ee14 memory: fix realloc()
Because memcpy() is declared by gcc as receiving non-null attributes, gcc
assumes that ptr != null, as it is passed into memcpy() (though with a size
of zero).  As a result it ignores the null pointer check in ::free(), and
calls memory::free() directly, which does not expect a null pointer.

Fix by only calling memcpy() when the ptr is non-null.
2014-10-23 15:59:52 +03:00
Avi Kivity
6b84f666f7 smp: move smp::listen_one() into smp_message_queue class
All it does is access its internals.
2014-10-23 13:16:50 +03:00
Avi Kivity
1bdc2a1f6c smp: asynchronous functions
Allow functions run on another cpu to return a future.  In that case, the
result (or exception) is only returned when the future is resolved.

Note this has the potential for livelocks:

A: smp::submit_to(B, [] {
       ...
       return smp::submit_to(A, [] {
           ...
       });
    });

If this and its mirror image (B sending to A) happen concurrently, and if
both the A->B and B->A queue become full, the system will not be able to
make forward progress.  This can be fixed by making the inner submit_to()
use a different queue.
2014-10-23 13:04:52 +03:00
Asias He
e2c2580e81 tcp: Fix ACK with both data and FIN
local  send: <FIN>
remote send: <ACK>

In response to local <FIN> packet, remote can send <ACK> packet acking
both data and FIN.

Avoid consuming extra one byte in data handling.
2014-10-23 12:57:33 +03:00
Asias He
c3d225eb5f httpd: Support close initiated on server side
This makes ab work:

$ ab -n 1000 http://ip:10000/
2014-10-23 12:57:32 +03:00
Asias He
d12e495653 tcp: Support close initiated on server side 2014-10-23 12:57:32 +03:00
Tomasz Grabiec
cec8b6c5de core: fix SIGSEGV in packet::packet(fragment frag, packet&& x)
We move from x._impl in the initializer list, so it will hold nullptr
later.
2014-10-23 11:31:03 +03:00
Asias He
502ecb8485 Ignore cscope files 2014-10-23 10:46:55 +03:00
Asias He
0b3fc256b6 httpd: Drop dead code 2014-10-23 10:30:40 +03:00
Asias He
b7ab4621fe httpd: Allow tune the http server port 2014-10-23 10:30:40 +03:00
Asias He
9aaaded894 app template: Put options for application in app options group
E.g.:

App options:
  --help                                show help message
  --port arg (=10000)                   HTTP Server port
2014-10-23 10:30:40 +03:00
Avi Kivity
1f34dc4b2a syscall_work_queue: remove submit<void>
Not used with syscalls - they almost always return a result.
2014-10-23 10:19:55 +03:00
Avi Kivity
4b020f3874 smp: split inter_thread_work_queue
inter_thread_work_queue now serves two purposes: a minimal work queue
for running blocking syscalls in a thread context outside the main reactor,
and for passing messages between reactors on different threads.

In order to evolve the inter_thread_work_queue's second task, without harming
the first, split it into two classes, syscall_work_queue and
smp_message_queue. Currently they are exactly equivalent.
2014-10-23 10:13:56 +03:00
Tomasz Grabiec
a8828fdf8c core: use standard hash for sstring
Turns out that the current hash implementation yields very bad
hashes. This change improves memcache throughput by 70% on
muninn/huginn.
2014-10-22 18:51:55 +03:00
Gleb Natapov
544a990f80 timer_set: fix expired time cancellation
Expired timer cancellation is broken since timer_set assumes that a
timer that is being canceled is not expired yet. This patch fixes the
problem by moving expired timers management outside timer_set and
letting the code that uses it to managed cancellation of expired timers.
In memcached it can never happen, in core each queued timer gets expired
flag that tells if timer is queued in a timer set or in expired timer
list.
2014-10-22 18:27:00 +03:00
Tomasz Grabiec
a8c64386b2 memcache: enable hash caching and hash comparison
std::unordred_map does it by default for std::string. We switched to
boost::intrusive::unordered_set<>, which does not do it by default for
any key. I see ~4% improvement in throughput with this.
2014-10-22 17:41:57 +03:00
Asias He
aa06198f0a tcp: Remove tcb from tcbs when connection is closed
Currently tcb are inserted but never removed from tcbs.

This patch also removes an unnecessary <ACK> packet (packet #5 below) to
the client.

1) client: <FIN>
2) server: <ACK>
3) server: <FIN>
4) client: <ACK>
5) server: <ACK>
2014-10-22 16:39:49 +03:00
Avi Kivity
05effc0b2d array_map: fix initialization
Force value initialization of the array, rather than the default (default
initialization) which does nothing for primitive types such as pointers.
2014-10-22 16:37:36 +03:00
Calle Wilund
40db2c0ba1 Collectd 'daemon' module
Per-cpu value list registry with polling -> udp send

- Allows registration of metric values associated with
  collectd id path (plugin/[plugin-inst/]type[/type-instance]).
- Values are broadcast/sent at periodic intervals. (config)
- Config through seastar.conf / app-template.
- Value registration can be revoked safely, either manually or
  through anchor.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2014-10-22 12:01:16 +03:00
Asias He
8b737c95e5 core: Add use_count for shared_ptr
This is useful when debugging shared_ptr.
2014-10-22 11:40:18 +03:00
Asias He
6561bde964 net: Add TCP option support
Maximum segment size and Window scale option are supported currently.
2014-10-22 10:28:06 +03:00
Asias He
5d19306435 httpd: Delete connection when client closes
When client closes the connection in one direction, make httpd close the
other direction too. This way, httpd will send back a <FIN> packet to
client after receiving client's <FIN> packet.
2014-10-22 10:27:27 +03:00
Avi Kivity
3ce9762fcd Merge branch 'memcache' of github.com:cloudius-systems/seastar-dev
"memcache: implement memory reclamation" from Tomasz.
2014-10-21 18:02:51 +03:00
Tomasz Grabiec
1d439ec2b6 memcache: try to handle hashtable resize failure
Big hashtables may fail to resize. Let's not crash when this happens
but evict some items and continue.
2014-10-21 16:58:35 +02:00
Tomasz Grabiec
137d465b72 memcache: hook up memory reclaimer
It implements a very simple reclaimer. When triggered tries to free
around 5 MB of data. This assumes that this amount is more than anyone
would want to allocate between low-memory event is detected and the
reclaimer task runs. This amount was chosen arbitrarily and I am not
sure if this amount is right.
2014-10-21 16:58:35 +02:00
Tomasz Grabiec
9478601abf core: introduce units.hh 2014-10-21 16:58:35 +02:00
Tomasz Grabiec
1a84e3560c core: implement "reclaimer" instance methods when running with default allocator 2014-10-21 16:43:09 +02:00
Tomasz Grabiec
bd31ea1f6a memcache: add stats for expired items 2014-10-21 16:43:09 +02:00
Tomasz Grabiec
0f1c499154 memcache: track items in an LRU list 2014-10-21 16:43:09 +02:00
Tomasz Grabiec
658fe77afa memcache: switch cache to use boost::intrusive::unordered_set
This will allow us to have LRU evictions and removal of expired items
which don't involve key lookups.
2014-10-21 16:43:09 +02:00