ry / ebb fork watch download tarball
public this repo is viewable by everyone
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
allocate memory on demand. set ebb_rails to use seq.processing

the first few requests will be a bit slower, but this will change will 
make
ebb only allocate request buffer on demand. (then it keeps them around for

later use.)
Ryan Dahl (author)
2 months ago
commit  53f3e7f84e2c6571b6c97d6ccab3dfc4902253f6
tree    1387a92ddefcfa91d716e69fe93cb8daadaaead2
parent  85f82048ed23e90fe8209ac83cdf6724da8636e9
...
15
16
17
18
 
 
 
 
19
20
21
...
15
16
17
 
18
19
20
21
22
23
24
0
@@ -15,7 +15,10 @@ Ebb::Runner.new('ebb_rails') do
0
     # defaults for ebb_rails
0
     options.update(
0
       :environment => 'development',
0
- :port => 3000
0
+ :port => 3000,
0
+ # rails has a massive mutex lock around each request - threaded processing
0
+ # will only slow things down
0
+ :threaded_processing => false
0
     )
0
     
0
     parser.on("-e", "--env ENV",
...
318
319
320
 
 
 
321
322
323
...
391
392
393
 
394
395
396
...
318
319
320
321
322
323
324
325
326
...
394
395
396
397
398
399
400
0
@@ -318,6 +318,9 @@ static client_init(ebb_server *server, ebb_client *client)
0
   client->read = client->nread_from_body = 0;
0
   client->response_buffer->len = 0; /* see note in ebb_client_close */
0
   client->content_length = 0;
0
+ if(client->request_buffer == NULL) {
0
+ client->request_buffer = (char*)malloc(EBB_BUFFERSIZE);
0
+ }
0
   
0
   client->status_written = FALSE;
0
   client->headers_written = FALSE;
0
@@ -391,6 +394,7 @@ void ebb_server_init( ebb_server *server
0
 {
0
   int i;
0
   for(i=0; i < EBB_MAX_CLIENTS; i++) {
0
+ server->clients[i].request_buffer = NULL;
0
     server->clients[i].response_buffer = g_string_new("");
0
     server->clients[i].open = FALSE;
0
     server->clients[i].in_use = FALSE;
...
58
59
60
61
 
62
63
64
...
58
59
60
 
61
62
63
64
0
@@ -58,7 +58,7 @@ struct ebb_client {
0
   ebb_server *server;
0
   http_parser parser;
0
   
0
- char request_buffer[EBB_BUFFERSIZE];
0
+ char *request_buffer;
0
   ev_io read_watcher;
0
   size_t read, nread_from_body;
0
   
...
56
57
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
60
 
61
62
 
 
 
 
63
64
65
...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
74
75
76
77
78
79
80
81
82
83
0
@@ -56,10 +56,28 @@ oneshot_timeout (struct ev_loop *loop, struct ev_timer *w, int revents) {;}
0
 
0
 VALUE server_process_connections(VALUE _)
0
 {
0
+ /* This function is super hacky. The libev loop is called for one iteration
0
+ * this means that any pending events are handled. If no events exist then
0
+ * the function blocks. We want blocking so that the while loop in ruby
0
+ * doesn't race away - however there is a need to continue to process other
0
+ * ruby threads which are running. While this function is being called
0
+ * other ruby threads cannot execute.
0
+ * So we set this timeout event which breaks the block after 0.1 seconds.
0
+ * Additionally we make sure that other threads get enough processing time
0
+ * by calling rb_thread_schedule() many times.
0
+ *
0
+ * Instead we should probably use rb_thread_select on server->fd when no
0
+ * clients are in_use? Whatever happens here, one should make sure the
0
+ * 'wait' benchmark is running as quickly with Ebb as it does with mongrel.
0
+ */
0
   ev_timer timeout;
0
- ev_timer_init (&timeout, oneshot_timeout, 0.01, 0.);
0
+ ev_timer_init (&timeout, oneshot_timeout, 0.1, 0.);
0
   ev_timer_start (loop, &timeout);
0
   ev_loop(loop, EVLOOP_ONESHOT);
0
+
0
+ /* remove the timeout event so that it isn't called immediately the next
0
+ * time around (since 0.1 seconds will have passed)
0
+ */
0
   ev_timer_stop(loop, &timeout);
0
   
0
   /* Call rb_thread_schedule() proportional to the number of rb threads running */

Comments

    No one has commented yet.