refactor: HTTP memstreams (#363)

* feat: response body memstream

* feat: auto_buf response header

* chore: format nit

* feat: request memstream

* removed zombie http-req-size from README files

* fix panic typos

* Update parser structure with the new http_body start address when buffer is moved by memstream

* fix case when header_length is zero at the beginning

Co-authored-by: emil <emil916@gmail.com>
master
Sean McBride 3 years ago committed by GitHub
parent 92ac9b056f
commit 56f32ec44b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,8 +86,6 @@ An SLEdge serverless function consists of a shared library (\*.so) and a JSON co
"port": 10000, "port": 10000,
"expected-execution-us": 600, "expected-execution-us": 600,
"relative-deadline-us": 2000, "relative-deadline-us": 2000,
"http-req-size": 1024,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
``` ```

@ -132,8 +132,6 @@ The `sledgert` runtime is invoked with an argument containing the path to a JSON
"relative-deadline-us" "relative-deadline-us"
"expected-execution-us" "expected-execution-us"
"admissions-percentile" "admissions-percentile"
"http-req-size"
"http-resp-size"
"http-resp-content-type" "http-resp-content-type"
The path to the JSON file is passed to `module_alloc_from_json`, which uses the Jasmine library to parse the JSON, performs validation, and passes the resulting specification to `module_alloc` for each module definition found. `module_alloc` allocated heap memory for a `struct module` and then calls `module_init`. `module_init` calls `sledge_abi_symbols_init`, which calls `dlopen` on the _.so file at the path specified in the JSON and then calls `dlsym` to resolve symbols within the _.so module. The path to the JSON file is passed to `module_alloc_from_json`, which uses the Jasmine library to parse the JSON, performs validation, and passes the resulting specification to `module_alloc` for each module definition found. `module_alloc` allocated heap memory for a `struct module` and then calls `module_init`. `module_init` calls `sledge_abi_symbols_init`, which calls `dlopen` on the _.so file at the path specified in the JSON and then calls `dlsym` to resolve symbols within the _.so module.

@ -0,0 +1,43 @@
#pragma once
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
struct auto_buf {
FILE *handle;
char *data;
size_t size;
};
static inline int
auto_buf_init(struct auto_buf *buf)
{
FILE *res = open_memstream(&buf->data, &buf->size);
if (res == NULL) return errno;
buf->handle = res;
return 0;
}
static inline int
auto_buf_flush(struct auto_buf *buf)
{
return fflush(buf->handle);
}
static inline void
auto_buf_deinit(struct auto_buf *buf)
{
if (likely(buf->handle != NULL)) {
fclose(buf->handle);
buf->handle = NULL;
}
if (likely(buf->data != NULL)) {
free(buf->data);
buf->data = NULL;
}
buf->size = 0;
}

@ -13,57 +13,59 @@
#define HTTP_MAX_QUERY_PARAM_COUNT 16 #define HTTP_MAX_QUERY_PARAM_COUNT 16
#define HTTP_MAX_QUERY_PARAM_LENGTH 32 #define HTTP_MAX_QUERY_PARAM_LENGTH 32
#define HTTP_RESPONSE_200_TEMPLATE \ #define HTTP_RESPONSE_CONTENT_TYPE "Content-Type: %s\r\n"
"HTTP/1.1 200 OK\r\n" \ #define HTTP_RESPONSE_CONTENT_LENGTH "Content-Length: %lu\r\n"
"Server: SLEdge\r\n" \ #define HTTP_RESPONSE_TERMINATOR "\r\n"
"Connection: close\r\n" \ #define HTTP_RESPONSE_TERMINATOR_LENGTH 2
"Content-Type: %s\r\n" \
"Content-Length: %lu\r\n" \
"\r\n"
/* The sum of format specifier characters in the template above */ #define HTTP_RESPONSE_200_OK \
#define HTTP_RESPONSE_200_TEMPLATE_FORMAT_SPECIFIER_LENGTH 5 "HTTP/1.1 200 OK\r\n" \
"Server: SLEdge\r\n" \
"Connection: close\r\n"
#define HTTP_RESPONSE_200_OK_LENGTH 52
#define HTTP_RESPONSE_400_BAD_REQUEST \ #define HTTP_RESPONSE_400_BAD_REQUEST \
"HTTP/1.1 400 Bad Request\r\n" \ "HTTP/1.1 400 Bad Request\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n"
"\r\n" #define HTTP_RESPONSE_400_BAD_REQUEST_LENGTH 61
#define HTTP_RESPONSE_404_NOT_FOUND \ #define HTTP_RESPONSE_404_NOT_FOUND \
"HTTP/1.1 404 Not Found\r\n" \ "HTTP/1.1 404 Not Found\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n"
"\r\n" #define HTTP_RESPONSE_404_NOT_FOUND_LENGTH 59
#define HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE \ #define HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE \
"HTTP/1.1 413 Payload Too Large\r\n" \ "HTTP/1.1 413 Payload Too Large\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n"
"\r\n" #define HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE_LENGTH 67
#define HTTP_RESPONSE_429_TOO_MANY_REQUESTS \ #define HTTP_RESPONSE_429_TOO_MANY_REQUESTS \
"HTTP/1.1 429 Too Many Requests\r\n" \ "HTTP/1.1 429 Too Many Requests\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n"
"\r\n" #define HTTP_RESPONSE_429_TOO_MANY_REQUESTS_LENGTH 67
#define HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR \ #define HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR \
"HTTP/1.1 500 Internal Server Error\r\n" \ "HTTP/1.1 500 Internal Server Error\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n"
"\r\n" #define HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR_LENGTH 71
#define HTTP_RESPONSE_503_SERVICE_UNAVAILABLE \ #define HTTP_RESPONSE_503_SERVICE_UNAVAILABLE \
"HTTP/1.1 503 Service Unavailable\r\n" \ "HTTP/1.1 503 Service Unavailable\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n"
"\r\n" #define HTTP_RESPONSE_503_SERVICE_UNAVAILABLE_LENGTH 69
static inline const char * static inline const char *
http_header_build(int status_code) http_header_build(int status_code)
{ {
switch (status_code) { switch (status_code) {
case 200:
return HTTP_RESPONSE_200_OK;
case 400: case 400:
return HTTP_RESPONSE_400_BAD_REQUEST; return HTTP_RESPONSE_400_BAD_REQUEST;
case 404: case 404:
@ -86,17 +88,17 @@ http_header_len(int status_code)
{ {
switch (status_code) { switch (status_code) {
case 400: case 400:
return strlen(HTTP_RESPONSE_400_BAD_REQUEST); return HTTP_RESPONSE_400_BAD_REQUEST_LENGTH;
case 404: case 404:
return strlen(HTTP_RESPONSE_404_NOT_FOUND); return HTTP_RESPONSE_404_NOT_FOUND_LENGTH;
case 413: case 413:
return strlen(HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE); return HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE_LENGTH;
case 429: case 429:
return strlen(HTTP_RESPONSE_429_TOO_MANY_REQUESTS); return HTTP_RESPONSE_429_TOO_MANY_REQUESTS_LENGTH;
case 500: case 500:
return strlen(HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR); return HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR_LENGTH;
case 503: case 503:
return strlen(HTTP_RESPONSE_503_SERVICE_UNAVAILABLE); return HTTP_RESPONSE_503_SERVICE_UNAVAILABLE_LENGTH;
default: default:
panic("%d is not a valid status code\n", status_code); panic("%d is not a valid status code\n", status_code);
} }

@ -34,7 +34,6 @@ http_router_add_route(http_router_t *router, struct route_config *config, struct
.relative_deadline_us = config->relative_deadline_us, .relative_deadline_us = config->relative_deadline_us,
.relative_deadline = (uint64_t)config->relative_deadline_us .relative_deadline = (uint64_t)config->relative_deadline_us
* runtime_processor_speed_MHz, * runtime_processor_speed_MHz,
.response_size = config->http_resp_size,
.response_content_type = config->http_resp_content_type }; .response_content_type = config->http_resp_content_type };
http_route_total_init(&route.metrics); http_route_total_init(&route.metrics);

@ -9,6 +9,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include "auto_buf.h"
#include "debuglog.h" #include "debuglog.h"
#include "epoll_tag.h" #include "epoll_tag.h"
#include "http_parser.h" #include "http_parser.h"
@ -20,13 +21,6 @@
#include "route.h" #include "route.h"
#include "tcp_session.h" #include "tcp_session.h"
#include "tenant.h" #include "tenant.h"
#include "vec.h"
#define HTTP_SESSION_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE)
#define HTTP_SESSION_RESPONSE_HEADER_CAPACITY 256
#define u8 uint8_t
VEC(u8)
enum http_session_state enum http_session_state
{ {
@ -52,12 +46,11 @@ struct http_session {
int socket; int socket;
struct http_parser http_parser; struct http_parser http_parser;
struct http_request http_request; struct http_request http_request;
struct vec_u8 request_buffer; struct auto_buf request_buffer;
char response_header[HTTP_SESSION_RESPONSE_HEADER_CAPACITY]; struct auto_buf response_header;
size_t response_header_length;
size_t response_header_written; size_t response_header_written;
struct vec_u8 response_buffer; struct auto_buf response_body;
size_t response_buffer_written; size_t response_body_written;
struct tenant *tenant; /* Backlink required when read blocks on listener core */ struct tenant *tenant; /* Backlink required when read blocks on listener core */
struct route *route; /* Backlink required to handle http metrics */ struct route *route; /* Backlink required to handle http metrics */
uint64_t request_arrival_timestamp; uint64_t request_arrival_timestamp;
@ -104,11 +97,11 @@ http_session_init(struct http_session *session, int socket_descriptor, const str
http_session_parser_init(session); http_session_parser_init(session);
int rc = vec_u8_init(&session->request_buffer, HTTP_SESSION_DEFAULT_REQUEST_RESPONSE_SIZE); int rc = auto_buf_init(&session->request_buffer);
if (rc < 0) return -1; if (rc < 0) return -1;
/* Defer allocating response until we've matched a route */ /* Defer initializing response_body until we've matched a route */
session->response_buffer.buffer = NULL; auto_buf_init(&session->response_header);
session->state = HTTP_SESSION_INITIALIZED; session->state = HTTP_SESSION_INITIALIZED;
@ -116,14 +109,16 @@ http_session_init(struct http_session *session, int socket_descriptor, const str
} }
static inline int static inline int
http_session_init_response_buffer(struct http_session *session, size_t capacity) http_session_init_response_body(struct http_session *session)
{ {
assert(session != NULL); assert(session != NULL);
assert(session->response_buffer.buffer == NULL); assert(session->response_body.data == NULL);
assert(session->response_body.size == 0);
assert(session->response_body_written == 0);
int rc = vec_u8_init(&session->response_buffer, capacity); int rc = auto_buf_init(&session->response_body);
if (rc < 0) { if (rc < 0) {
vec_u8_deinit(&session->request_buffer); auto_buf_deinit(&session->request_buffer);
return -1; return -1;
} }
@ -158,8 +153,9 @@ http_session_deinit(struct http_session *session)
{ {
assert(session); assert(session);
vec_u8_deinit(&session->request_buffer); auto_buf_deinit(&session->request_buffer);
vec_u8_deinit(&session->response_buffer); auto_buf_deinit(&session->response_header);
auto_buf_deinit(&session->response_body);
} }
static inline void static inline void
@ -177,8 +173,7 @@ http_session_free(struct http_session *session)
* @param status_code * @param status_code
*/ */
static inline void static inline void
http_session_set_response_header(struct http_session *session, int status_code, const char *content_type, http_session_set_response_header(struct http_session *session, int status_code)
size_t content_length)
{ {
assert(session != NULL); assert(session != NULL);
assert(status_code >= 200 && status_code <= 599); assert(status_code >= 200 && status_code <= 599);
@ -187,20 +182,31 @@ http_session_set_response_header(struct http_session *session, int status_code,
/* We might not have actually matched a route */ /* We might not have actually matched a route */
if (likely(session->route != NULL)) { http_route_total_increment(&session->route->metrics, status_code); } if (likely(session->route != NULL)) { http_route_total_increment(&session->route->metrics, status_code); }
int rc = fputs(http_header_build(status_code), session->response_header.handle);
assert(rc != EOF);
if (status_code == 200) { if (status_code == 200) {
session->response_header_length = snprintf(session->response_header, /* Make sure the response_body is flushed */
HTTP_SESSION_RESPONSE_HEADER_CAPACITY, int rc = auto_buf_flush(&session->response_body);
HTTP_RESPONSE_200_TEMPLATE, content_type, content_length); if (unlikely(rc != 0)) { panic("response_body auto_buf failed to flush: %s\n", strerror(errno)); };
} else {
size_t header_len = http_header_len(status_code); /* Technically fprintf can truncate, but I assume this won't happen with a memstream */
size_t to_copy = HTTP_SESSION_RESPONSE_HEADER_CAPACITY < header_len rc = fprintf(session->response_header.handle, HTTP_RESPONSE_CONTENT_TYPE,
? HTTP_SESSION_RESPONSE_HEADER_CAPACITY session->route->response_content_type);
: header_len; assert(rc > 0);
rc = fprintf(session->response_header.handle, HTTP_RESPONSE_CONTENT_LENGTH,
strncpy(session->response_header, http_header_build(status_code), to_copy); session->response_body.size);
session->response_header_length = to_copy; assert(rc > 0);
rc = fputs(HTTP_RESPONSE_200_OK, session->response_header.handle);
assert(rc != EOF);
} }
rc = fputs(HTTP_RESPONSE_TERMINATOR, session->response_header.handle);
assert(rc != EOF);
rc = auto_buf_flush(&session->response_header);
if (unlikely(rc != 0)) { panic("response_header auto_buf failed to flush: %s\n", strerror(errno)); };
session->response_takeoff_timestamp = __getcycles(); session->response_takeoff_timestamp = __getcycles();
} }
@ -226,11 +232,11 @@ http_session_send_response_header(struct http_session *session, void_star_cb on_
|| session->state == HTTP_SESSION_SEND_RESPONSE_HEADER_BLOCKED); || session->state == HTTP_SESSION_SEND_RESPONSE_HEADER_BLOCKED);
session->state = HTTP_SESSION_SENDING_RESPONSE_HEADER; session->state = HTTP_SESSION_SENDING_RESPONSE_HEADER;
while (session->response_header_length > session->response_header_written) { while (session->response_header.size > session->response_header_written) {
ssize_t sent = ssize_t sent =
tcp_session_send(session->socket, tcp_session_send(session->socket,
(const char *)&session->response_header[session->response_header_written], (const char *)&session->response_header.data[session->response_header_written],
session->response_header_length - session->response_header_written, on_eagain, session->response_header.size - session->response_header_written, on_eagain,
session); session);
if (sent < 0) { if (sent < 0) {
return (int)sent; return (int)sent;
@ -259,16 +265,18 @@ http_session_send_response_body(struct http_session *session, void_star_cb on_ea
|| session->state == HTTP_SESSION_SEND_RESPONSE_BODY_BLOCKED); || session->state == HTTP_SESSION_SEND_RESPONSE_BODY_BLOCKED);
session->state = HTTP_SESSION_SENDING_RESPONSE_BODY; session->state = HTTP_SESSION_SENDING_RESPONSE_BODY;
while (session->response_buffer_written < session->response_buffer.length) { /* Assumption: Already flushed in order to write content-length to header */
// TODO: Test if body is empty
while (session->response_body_written < session->response_body.size) {
ssize_t sent = ssize_t sent =
tcp_session_send(session->socket, tcp_session_send(session->socket,
(const char *)&session->response_buffer.buffer[session->response_buffer_written], (const char *)&session->response_body.data[session->response_body_written],
session->response_buffer.length - session->response_buffer_written, on_eagain, session->response_body.size - session->response_body_written, on_eagain, session);
session);
if (sent < 0) { if (sent < 0) {
return (int)sent; return (int)sent;
} else { } else {
session->response_buffer_written += (size_t)sent; session->response_body_written += (size_t)sent;
} }
} }
@ -276,45 +284,6 @@ http_session_send_response_body(struct http_session *session, void_star_cb on_ea
return 0; return 0;
} }
static inline bool
http_session_request_buffer_is_full(struct http_session *session)
{
return session->request_buffer.length == session->request_buffer.capacity;
}
static inline int
http_session_request_buffer_grow(struct http_session *session)
{
/* We have not yet fully parsed the header, so we don't know content-length, so just grow
* (double) the buffer */
uint8_t *old_buffer = session->request_buffer.buffer;
if (vec_u8_grow(&session->request_buffer) != 0) {
debuglog("Failed to grow request buffer\n");
return -1;
}
/* buffer moved, so invalidate to reparse */
if (old_buffer != session->request_buffer.buffer) { http_session_parser_init(session); }
return 0;
}
static inline int
http_session_request_buffer_resize(struct http_session *session, int required_size)
{
uint8_t *old_buffer = session->request_buffer.buffer;
if (vec_u8_resize(&session->request_buffer, required_size) != 0) {
debuglog("Failed to resize request vector to %d bytes\n", required_size);
return -1;
}
/* buffer moved, so invalidate to reparse */
if (old_buffer != session->request_buffer.buffer) { http_session_parser_init(session); }
return 0;
}
typedef void (*http_session_cb)(struct http_session *); typedef void (*http_session_cb)(struct http_session *);
static inline ssize_t static inline ssize_t
@ -331,8 +300,8 @@ http_session_parse(struct http_session *session, ssize_t bytes_received)
#endif #endif
size_t bytes_parsed = size_t bytes_parsed =
http_parser_execute(&session->http_parser, settings, http_parser_execute(&session->http_parser, settings,
(const char *)&session->request_buffer.buffer[session->http_request.length_parsed], (const char *)&session->request_buffer.data[session->http_request.length_parsed],
(size_t)session->request_buffer.length - session->http_request.length_parsed); (size_t)session->request_buffer.size - session->http_request.length_parsed);
if (session->http_parser.http_errno != HPE_OK) { if (session->http_parser.http_errno != HPE_OK) {
debuglog("Error: %s, Description: %s\n", debuglog("Error: %s, Description: %s\n",
@ -382,52 +351,46 @@ static inline int
http_session_receive_request(struct http_session *session, void_star_cb on_eagain) http_session_receive_request(struct http_session *session, void_star_cb on_eagain)
{ {
assert(session != NULL); assert(session != NULL);
assert(session->request_buffer.capacity > 0); assert(session->request_buffer.handle != NULL);
assert(session->request_buffer.length <= session->request_buffer.capacity);
assert(session->state == HTTP_SESSION_INITIALIZED || session->state == HTTP_SESSION_RECEIVE_REQUEST_BLOCKED); assert(session->state == HTTP_SESSION_INITIALIZED || session->state == HTTP_SESSION_RECEIVE_REQUEST_BLOCKED);
session->state = HTTP_SESSION_RECEIVING_REQUEST; session->state = HTTP_SESSION_RECEIVING_REQUEST;
int rc = 0; struct http_request *http_request = &session->http_request;
int rc = 0;
while (!session->http_request.message_end) { char temp[BUFSIZ];
/* If we know the header size and content-length, resize exactly. Otherwise double */
if (session->http_request.header_end && session->http_request.body) {
int header_size = (uint8_t *)session->http_request.body - session->request_buffer.buffer;
int required_size = header_size + session->http_request.body_length;
if (required_size > session->request_buffer.capacity) {
rc = http_session_request_buffer_resize(session, required_size);
if (rc != 0) goto err_nobufs;
}
} else if (http_session_request_buffer_is_full(session)) {
rc = http_session_request_buffer_grow(session);
if (rc != 0) goto err_nobufs;
}
ssize_t bytes_received = while (!http_request->message_end) {
tcp_session_recv(session->socket, ssize_t bytes_received = tcp_session_recv(session->socket, temp, BUFSIZ, on_eagain, session);
(char *)&session->request_buffer.buffer[session->request_buffer.length],
session->request_buffer.capacity - session->request_buffer.length, on_eagain,
session);
if (unlikely(bytes_received == -EAGAIN)) if (unlikely(bytes_received == -EAGAIN))
goto err_eagain; goto err_eagain;
else if (unlikely(bytes_received < 0)) else if (unlikely(bytes_received < 0))
goto err; goto err;
/* If we received an EOF before we were able to parse a complete HTTP message, request is malformed */ /* If we received an EOF before we were able to parse a complete HTTP message, request is malformed */
else if (unlikely(bytes_received == 0 && !session->http_request.message_end)) else if (unlikely(bytes_received == 0 && !http_request->message_end))
goto err; goto err;
assert(bytes_received > 0); assert(bytes_received > 0);
assert(session->request_buffer.length < session->request_buffer.capacity);
session->request_buffer.length += bytes_received; const char *old_buffer = session->request_buffer.data;
const ssize_t header_length = session->request_buffer.size - http_request->body_length_read;
assert(!http_request->header_end || header_length > 0);
/* Write temp buffer to memstream */
fwrite(temp, 1, bytes_received, session->request_buffer.handle);
/* fflush memstream managed buffer */
fflush(session->request_buffer.handle);
ssize_t bytes_parsed = http_session_parse(session, bytes_received); /* Update parser structure if buffer moved */
if (bytes_parsed == -1) goto err; if (old_buffer != session->request_buffer.data) {
http_request->body = header_length ? session->request_buffer.data + header_length : NULL;
}
if (http_session_parse(session, bytes_received) == -1) goto err;
} }
assert(session->http_request.message_end == true); assert(http_request->message_end == true);
session->state = HTTP_SESSION_RECEIVED_REQUEST; session->state = HTTP_SESSION_RECEIVED_REQUEST;
http_session_log_query_params(session); http_session_log_query_params(session);
@ -456,26 +419,10 @@ static inline int
http_session_write_response(struct http_session *session, const uint8_t *source, size_t n) http_session_write_response(struct http_session *session, const uint8_t *source, size_t n)
{ {
assert(session); assert(session);
assert(session->response_buffer.buffer != NULL); assert(session->response_body.handle != NULL);
assert(source); assert(source);
int rc = 0; return fwrite(source, 1, n, session->response_body.handle);
size_t buffer_remaining = session->response_buffer.capacity - session->response_buffer.length;
if (buffer_remaining < n) {
rc = vec_u8_resize(&session->response_buffer, session->response_buffer.capacity + n - buffer_remaining);
if (rc != 0) goto DONE;
}
assert(session->response_buffer.capacity - session->response_buffer.length >= n);
memcpy(&session->response_buffer.buffer[session->response_buffer.length], source, n);
session->response_buffer.length += n;
rc = n;
DONE:
return rc;
} }
static inline void static inline void

@ -15,7 +15,6 @@ struct route {
/* HTTP State */ /* HTTP State */
uint32_t relative_deadline_us; uint32_t relative_deadline_us;
uint64_t relative_deadline; /* cycles */ uint64_t relative_deadline; /* cycles */
size_t response_size;
char *response_content_type; char *response_content_type;
struct admissions_info admissions_info; struct admissions_info admissions_info;
}; };

@ -15,7 +15,6 @@ enum route_config_member
route_config_member_admissions_percentile, route_config_member_admissions_percentile,
route_config_member_expected_execution_us, route_config_member_expected_execution_us,
route_config_member_relative_deadline_us, route_config_member_relative_deadline_us,
route_config_member_http_resp_size,
route_config_member_http_resp_content_type, route_config_member_http_resp_content_type,
route_config_member_len route_config_member_len
}; };
@ -26,7 +25,6 @@ struct route_config {
uint8_t admissions_percentile; uint8_t admissions_percentile;
uint32_t expected_execution_us; uint32_t expected_execution_us;
uint32_t relative_deadline_us; uint32_t relative_deadline_us;
uint32_t http_resp_size;
char *http_resp_content_type; char *http_resp_content_type;
}; };
@ -49,7 +47,6 @@ route_config_print(struct route_config *config)
printf("[Route] Admissions Percentile: %hhu\n", config->admissions_percentile); printf("[Route] Admissions Percentile: %hhu\n", config->admissions_percentile);
printf("[Route] Expected Execution (us): %u\n", config->expected_execution_us); printf("[Route] Expected Execution (us): %u\n", config->expected_execution_us);
printf("[Route] Relative Deadline (us): %u\n", config->relative_deadline_us); printf("[Route] Relative Deadline (us): %u\n", config->relative_deadline_us);
printf("[Route] HTTP Response Size: %u\n", config->http_resp_size);
printf("[Route] HTTP Response Content Type: %s\n", config->http_resp_content_type); printf("[Route] HTTP Response Content Type: %s\n", config->http_resp_content_type);
} }

@ -11,7 +11,6 @@ static const char *route_config_json_keys[route_config_member_len] = { "route",
"admissions-percentile", "admissions-percentile",
"expected-execution-us", "expected-execution-us",
"relative-deadline-us", "relative-deadline-us",
"http-resp-size",
"http-resp-content-type" }; "http-resp-content-type" };
static inline int static inline int
@ -89,14 +88,6 @@ route_config_parse(struct route_config *config, const char *json_buf, jsmntok_t
route_config_json_keys[route_config_member_relative_deadline_us], route_config_json_keys[route_config_member_relative_deadline_us],
&config->relative_deadline_us); &config->relative_deadline_us);
if (rc < 0) return -1; if (rc < 0) return -1;
} else if (strcmp(key, route_config_json_keys[route_config_member_http_resp_size]) == 0) {
if (!has_valid_type(tokens[i], key, JSMN_PRIMITIVE, json_buf)) return -1;
if (route_config_set_key_once(did_set, route_config_member_http_resp_size) == -1) return -1;
int rc = parse_uint32_t(tokens[i], json_buf,
route_config_json_keys[route_config_member_http_resp_size],
&config->http_resp_size);
if (rc < 0) return -1;
} else if (strcmp(key, route_config_json_keys[route_config_member_http_resp_content_type]) == 0) { } else if (strcmp(key, route_config_json_keys[route_config_member_http_resp_content_type]) == 0) {
if (!is_nonempty_string(tokens[i], key)) return -1; if (!is_nonempty_string(tokens[i], key)) return -1;
if (route_config_set_key_once(did_set, route_config_member_http_resp_content_type) == -1) if (route_config_set_key_once(did_set, route_config_member_http_resp_content_type) == -1)

@ -58,7 +58,7 @@ sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state)
admissions_control_subtract(sandbox->admissions_estimate); admissions_control_subtract(sandbox->admissions_estimate);
/* Return HTTP session to listener core to be written back to client */ /* Return HTTP session to listener core to be written back to client */
http_session_set_response_header(sandbox->http, 500, NULL, 0); http_session_set_response_header(sandbox->http, 500);
sandbox->http->state = HTTP_SESSION_EXECUTION_COMPLETE; sandbox->http->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_send_response(sandbox->http, (void_star_cb)listener_thread_register_http_session); http_session_send_response(sandbox->http, (void_star_cb)listener_thread_register_http_session);
sandbox->http = NULL; sandbox->http = NULL;

@ -3,6 +3,7 @@
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#include "auto_buf.h"
#include "arch/getcycles.h" #include "arch/getcycles.h"
#include "listener_thread.h" #include "listener_thread.h"
#include "local_runqueue.h" #include "local_runqueue.h"
@ -50,8 +51,7 @@ sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state)
sandbox_state_totals_increment(SANDBOX_RETURNED); sandbox_state_totals_increment(SANDBOX_RETURNED);
sandbox_state_totals_decrement(last_state); sandbox_state_totals_decrement(last_state);
http_session_set_response_header(sandbox->http, 200, sandbox->route->response_content_type, http_session_set_response_header(sandbox->http, 200);
sandbox->http->response_buffer.length);
sandbox->http->state = HTTP_SESSION_EXECUTION_COMPLETE; sandbox->http->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_send_response(sandbox->http, (void_star_cb)listener_thread_register_http_session); http_session_send_response(sandbox->http, (void_star_cb)listener_thread_register_http_session);
sandbox->http = NULL; sandbox->http = NULL;

@ -20,6 +20,6 @@ http_session_perf_log_print_entry(struct http_session *http_session)
fprintf(http_session_perf_log, "%s,%s,%u,%lu,%lu,%lu,%lu,%lu,%u\n", http_session->tenant->name, fprintf(http_session_perf_log, "%s,%s,%u,%lu,%lu,%lu,%lu,%lu,%u\n", http_session->tenant->name,
http_session->http_request.full_url, http_session->state, http_session->response_header_written, http_session->http_request.full_url, http_session->state, http_session->response_header_written,
http_session->response_buffer_written, receive_duration, sent_duration, total_lifetime, http_session->response_body_written, receive_duration, sent_duration, total_lifetime,
runtime_processor_speed_MHz); runtime_processor_speed_MHz);
} }

@ -786,23 +786,9 @@ wasi_snapshot_preview1_backing_fd_write(wasi_context_t *context, __wasi_fd_t fd,
size_t iovs_len, __wasi_size_t *nwritten_retptr) size_t iovs_len, __wasi_size_t *nwritten_retptr)
{ {
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
struct sandbox *s = current_sandbox_get(); struct sandbox *s = current_sandbox_get();
size_t buffer_remaining = 0; __wasi_size_t nwritten = 0;
__wasi_size_t nwritten = 0; int rc = 0;
int rc = 0;
/* Precompute required buffer size for entire iovec to call realloc at most once */
size_t total_size_to_copy = 0;
for (size_t i = 0; i < iovs_len; i++) { total_size_to_copy += iovs[i].buf_len; }
buffer_remaining = s->http->response_buffer.capacity - s->http->response_buffer.length;
if (buffer_remaining < total_size_to_copy) {
rc = vec_u8_resize(&s->http->response_buffer,
s->http->response_buffer.capacity + total_size_to_copy - buffer_remaining);
assert(rc == 0);
}
assert(s->http->response_buffer.capacity - s->http->response_buffer.length >= total_size_to_copy);
for (size_t i = 0; i < iovs_len; i++) { for (size_t i = 0; i < iovs_len; i++) {
#ifdef LOG_SANDBOX_STDERR #ifdef LOG_SANDBOX_STDERR
@ -810,8 +796,8 @@ wasi_snapshot_preview1_backing_fd_write(wasi_context_t *context, __wasi_fd_t fd,
debuglog("STDERR from Sandbox: %.*s", iovs[i].buf_len, iovs[i].buf); debuglog("STDERR from Sandbox: %.*s", iovs[i].buf_len, iovs[i].buf);
} }
#endif #endif
rc = http_session_write_response(s->http, iovs[i].buf, iovs[i].buf_len); rc = fwrite(iovs[i].buf, 1, iovs[i].buf_len, s->http->response_body.handle);
if (rc < 0) return __WASI_ERRNO_FBIG; if (rc != iovs[i].buf_len) return __WASI_ERRNO_FBIG;
nwritten += rc; nwritten += rc;
} }

@ -182,7 +182,7 @@ on_client_request_arrival(int client_socket, const struct sockaddr *client_addre
/* Failed to allocate memory */ /* Failed to allocate memory */
debuglog("Failed to allocate http session\n"); debuglog("Failed to allocate http session\n");
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 500, NULL, 0); http_session_set_response_header(session, 500);
on_client_response_header_sending(session); on_client_response_header_sending(session);
return; return;
} }
@ -203,13 +203,13 @@ on_client_request_receiving(struct http_session *session)
/* Failed to grow request buffer */ /* Failed to grow request buffer */
debuglog("Failed to grow http request buffer\n"); debuglog("Failed to grow http request buffer\n");
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 500, NULL, 0); http_session_set_response_header(session, 500);
on_client_response_header_sending(session); on_client_response_header_sending(session);
return; return;
} else if (rc < 0) { } else if (rc < 0) {
debuglog("Failed to receive or parse request\n"); debuglog("Failed to receive or parse request\n");
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 400, NULL, 0); http_session_set_response_header(session, 400);
on_client_response_header_sending(session); on_client_response_header_sending(session);
return; return;
} }
@ -227,7 +227,7 @@ on_client_request_received(struct http_session *session)
if (route == NULL) { if (route == NULL) {
debuglog("Did not match any routes\n"); debuglog("Did not match any routes\n");
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 404, NULL, 0); http_session_set_response_header(session, 404);
on_client_response_header_sending(session); on_client_response_header_sending(session);
return; return;
} }
@ -242,7 +242,7 @@ on_client_request_received(struct http_session *session)
uint64_t work_admitted = admissions_control_decide(route->admissions_info.estimate); uint64_t work_admitted = admissions_control_decide(route->admissions_info.estimate);
if (work_admitted == 0) { if (work_admitted == 0) {
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 429, NULL, 0); http_session_set_response_header(session, 429);
on_client_response_header_sending(session); on_client_response_header_sending(session);
return; return;
} }
@ -253,7 +253,7 @@ on_client_request_received(struct http_session *session)
if (unlikely(sandbox == NULL)) { if (unlikely(sandbox == NULL)) {
debuglog("Failed to allocate sandbox\n"); debuglog("Failed to allocate sandbox\n");
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 500, NULL, 0); http_session_set_response_header(session, 500);
on_client_response_header_sending(session); on_client_response_header_sending(session);
return; return;
} }
@ -263,7 +263,7 @@ on_client_request_received(struct http_session *session)
debuglog("Failed to add sandbox to global queue\n"); debuglog("Failed to add sandbox to global queue\n");
sandbox_free(sandbox); sandbox_free(sandbox);
session->state = HTTP_SESSION_EXECUTION_COMPLETE; session->state = HTTP_SESSION_EXECUTION_COMPLETE;
http_session_set_response_header(session, 429, NULL, 0); http_session_set_response_header(session, 429);
on_client_response_header_sending(session); on_client_response_header_sending(session);
} }
} }

@ -60,6 +60,7 @@ metrics_server_thread_spawn(int client_socket)
if (strncmp(http_status_code_buf, "GET /metrics HTTP", 10) != 0) { if (strncmp(http_status_code_buf, "GET /metrics HTTP", 10) != 0) {
write(client_socket, http_header_build(404), http_header_len(404)); write(client_socket, http_header_build(404), http_header_len(404));
write(client_socket, HTTP_RESPONSE_TERMINATOR, HTTP_RESPONSE_TERMINATOR_LENGTH);
close(client_socket); close(client_socket);
return; return;
} }
@ -122,7 +123,7 @@ metrics_server_handler(void *arg)
proc_stat_metrics_init(&stat); proc_stat_metrics_init(&stat);
#endif #endif
fprintf(ostream, "HTTP/1.1 200 OK\r\n\r\n"); fprintf(ostream, HTTP_RESPONSE_200_OK HTTP_RESPONSE_TERMINATOR);
#ifdef PROC_STAT_METRICS #ifdef PROC_STAT_METRICS
fprintf(ostream, "# TYPE os_proc_major_page_faults counter\n"); fprintf(ostream, "# TYPE os_proc_major_page_faults counter\n");

@ -94,9 +94,9 @@ sandbox_prepare_execution_environment(struct sandbox *sandbox)
int rc; int rc;
rc = http_session_init_response_buffer(sandbox->http, sandbox->route->response_size); rc = http_session_init_response_body(sandbox->http);
if (rc < 0) { if (rc < 0) {
error_message = "failed to allocate response buffer"; error_message = "failed to allocate response body";
goto err_globals_allocation_failed; goto err_globals_allocation_failed;
} }

@ -10,7 +10,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 128,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -18,7 +17,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 128,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream" "http-resp-content-type": "application/octet-stream"
}, },
{ {
@ -18,7 +17,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream" "http-resp-content-type": "application/octet-stream"
}, },
{ {
@ -26,7 +24,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream" "http-resp-content-type": "application/octet-stream"
} }
] ]

@ -10,7 +10,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream" "http-resp-content-type": "application/octet-stream"
} }
] ]

@ -10,7 +10,6 @@
"path": "depth_to_xyz.wasm.so", "path": "depth_to_xyz.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 360000, "relative-deadline-us": 360000,
"http-resp-size": 5335057,
"http-resp-content-type": "img/png" "http-resp-content-type": "img/png"
} }
] ]

@ -5,6 +5,5 @@
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-req-size": 4096, "http-req-size": 4096,
"http-resp-size": 128,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }

@ -5,6 +5,5 @@
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-req-size": 1024000, "http-req-size": 1024000,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream" "http-resp-content-type": "application/octet-stream"
} }

@ -5,6 +5,5 @@
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 360000, "relative-deadline-us": 360000,
"http-req-size": 5335057, "http-req-size": 5335057,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }

@ -5,6 +5,5 @@
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-req-size": 1002400, "http-req-size": 1002400,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }

@ -5,6 +5,5 @@
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-req-size": 1524000, "http-req-size": 1524000,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png" "http-resp-content-type": "image/png"
} }

@ -10,7 +10,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream" "http-resp-content-type": "application/octet-stream"
}, },
{ {
@ -18,7 +17,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "image/png" "http-resp-content-type": "image/png"
}, },
{ {
@ -26,7 +24,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -34,7 +31,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 360000, "relative-deadline-us": 360000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -42,7 +38,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 128,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,7 +11,6 @@
"expected-execution-us": 500, "expected-execution-us": 500,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 0,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,7 +11,6 @@
"admissions-percentile": 70, "admissions-percentile": 70,
"expected-execution-us": 6000, "expected-execution-us": 6000,
"relative-deadline-us": 20000, "relative-deadline-us": 20000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -20,7 +19,6 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]
@ -37,7 +35,6 @@
"admissions-percentile": 70, "admissions-percentile": 70,
"expected-execution-us": 6000, "expected-execution-us": 6000,
"relative-deadline-us": 20000, "relative-deadline-us": 20000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,7 +11,6 @@
"admissions-percentile": 70, "admissions-percentile": 70,
"expected-execution-us": 4000, "expected-execution-us": 4000,
"relative-deadline-us": 16000, "relative-deadline-us": 16000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -18,7 +17,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -26,7 +24,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -18,7 +17,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -26,7 +24,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -18,7 +17,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -26,7 +24,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 1024000,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 36000, "relative-deadline-us": 36000,
"http-resp-size": 1024000,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 360000, "relative-deadline-us": 360000,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,7 +11,6 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-size": 102400,
"http-resp-content-type": "text/html" "http-resp-content-type": "text/html"
} }
] ]

@ -1,36 +1,34 @@
[ [
{ {
"name": "GWU", "name": "GWU",
"port": 20030, "port": 20030,
"replenishment-period-us": 16000, "replenishment-period-us": 16000,
"max-budget-us": 144000, "max-budget-us": 144000,
"routes": [ "routes": [
{ {
"route": "/fib", "route": "/fib",
"path": "fibonacci.wasm.so", "path": "fibonacci.wasm.so",
"admissions-percentile": 70, "admissions-percentile": 70,
"expected-execution-us": 4000, "expected-execution-us": 4000,
"relative-deadline-us": 16000, "relative-deadline-us": 16000,
"http-resp-size": 1024, "http-resp-content-type": "text/plain"
"http-resp-content-type": "text/plain" }
} ]
] },
}, {
{ "name": "NNN",
"name": "NNN", "port": 10030,
"port": 10030, "replenishment-period-us": 0,
"replenishment-period-us": 0, "max-budget-us": 0,
"max-budget-us": 0, "routes": [
"routes": [ {
{ "route": "/fib",
"route": "/fib", "path": "fibonacci.wasm.so",
"path": "fibonacci.wasm.so", "admissions-percentile": 70,
"admissions-percentile": 70, "expected-execution-us": 4000,
"expected-execution-us": 4000, "relative-deadline-us": 16000,
"relative-deadline-us": 16000, "http-resp-content-type": "text/plain"
"http-resp-size": 1024, }
"http-resp-content-type": "text/plain" ]
} }
]
}
] ]

@ -10,7 +10,6 @@
"admissions-percentile": 0, "admissions-percentile": 0,
"expected-execution-us": 0, "expected-execution-us": 0,
"relative-deadline-us": 0, "relative-deadline-us": 0,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,8 +11,7 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain"
"http-resp-size": 1024
}, },
{ {
"route": "/get", "route": "/get",
@ -20,8 +19,7 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain"
"http-resp-size": 1024
}, },
{ {
"route": "/delete", "route": "/delete",
@ -29,8 +27,7 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain"
"http-resp-size": 1024
}, },
{ {
"route": "/upsert", "route": "/upsert",
@ -38,8 +35,7 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain"
"http-resp-size": 1024
} }
] ]
} }

@ -10,7 +10,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "image/png" "http-resp-content-type": "image/png"
}, },
{ {
@ -18,7 +17,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "image/png" "http-resp-content-type": "image/png"
}, },
{ {
@ -26,7 +24,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png" "http-resp-content-type": "image/png"
} }
] ]

@ -10,7 +10,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1024000,
"http-resp-content-type": "image/jpeg" "http-resp-content-type": "image/jpeg"
} }
] ]

@ -10,7 +10,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -18,7 +17,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -26,7 +24,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 5000, "expected-execution-us": 5000,
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -9,7 +9,6 @@
"route": "/hello_ps", "route": "/hello_ps",
"path": "hello_ps.wasm.so", "path": "hello_ps.wasm.so",
"relative-deadline-us": 50000, "relative-deadline-us": 50000,
"http-resp-size": 1048576,
"http-resp-content-type": "image/jpeg" "http-resp-content-type": "image/jpeg"
} }
] ]

@ -11,7 +11,6 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,7 +11,6 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-size": 64,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -11,7 +11,6 @@
"expected-execution-us": 6000, "expected-execution-us": 6000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000, "relative-deadline-us": 20000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
}, },
{ {
@ -20,7 +19,6 @@
"expected-execution-us": 10000000, "expected-execution-us": 10000000,
"admissions-percentile": 70, "admissions-percentile": 70,
"relative-deadline-us": 20000000, "relative-deadline-us": 20000000,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain" "http-resp-content-type": "text/plain"
} }
] ]

@ -10,7 +10,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 2777, "expected-execution-us": 2777,
"relative-deadline-us": 4166, "relative-deadline-us": 4166,
"http-resp-size": 128,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -19,7 +18,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 2777, "expected-execution-us": 2777,
"relative-deadline-us": 4443, "relative-deadline-us": 4443,
"http-resp-size": 128,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -28,7 +26,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 2777, "expected-execution-us": 2777,
"relative-deadline-us": 4721, "relative-deadline-us": 4721,
"http-resp-size": 128,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -37,7 +34,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 2777, "expected-execution-us": 2777,
"relative-deadline-us": 4999, "relative-deadline-us": 4999,
"http-resp-size": 128,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -46,7 +42,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 2777, "expected-execution-us": 2777,
"relative-deadline-us": 5276, "relative-deadline-us": 5276,
"http-resp-size": 128,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -55,7 +50,6 @@
"path": "cifar10.wasm.so", "path": "cifar10.wasm.so",
"expected-execution-us": 2777, "expected-execution-us": 2777,
"relative-deadline-us": 5554, "relative-deadline-us": 5554,
"http-resp-size": 128,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -64,7 +58,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 158, "expected-execution-us": 158,
"relative-deadline-us": 237, "relative-deadline-us": 237,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream", "http-resp-content-type": "application/octet-stream",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -73,7 +66,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 158, "expected-execution-us": 158,
"relative-deadline-us": 253, "relative-deadline-us": 253,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream", "http-resp-content-type": "application/octet-stream",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -82,7 +74,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 158, "expected-execution-us": 158,
"relative-deadline-us": 269, "relative-deadline-us": 269,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream", "http-resp-content-type": "application/octet-stream",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -91,7 +82,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 158, "expected-execution-us": 158,
"relative-deadline-us": 284, "relative-deadline-us": 284,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream", "http-resp-content-type": "application/octet-stream",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -100,7 +90,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 158, "expected-execution-us": 158,
"relative-deadline-us": 300, "relative-deadline-us": 300,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream", "http-resp-content-type": "application/octet-stream",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -109,7 +98,6 @@
"path": "gps_ekf.wasm.so", "path": "gps_ekf.wasm.so",
"expected-execution-us": 158, "expected-execution-us": 158,
"relative-deadline-us": 316, "relative-deadline-us": 316,
"http-resp-size": 1024000,
"http-resp-content-type": "application/octet-stream", "http-resp-content-type": "application/octet-stream",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -118,7 +106,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 461831, "expected-execution-us": 461831,
"relative-deadline-us": 692746, "relative-deadline-us": 692746,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -127,7 +114,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 461831, "expected-execution-us": 461831,
"relative-deadline-us": 738930, "relative-deadline-us": 738930,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -136,7 +122,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 461831, "expected-execution-us": 461831,
"relative-deadline-us": 785113, "relative-deadline-us": 785113,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -145,7 +130,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 461831, "expected-execution-us": 461831,
"relative-deadline-us": 831296, "relative-deadline-us": 831296,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -154,7 +138,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 461831, "expected-execution-us": 461831,
"relative-deadline-us": 877479, "relative-deadline-us": 877479,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -163,7 +146,6 @@
"path": "gocr.wasm.so", "path": "gocr.wasm.so",
"expected-execution-us": 461831, "expected-execution-us": 461831,
"relative-deadline-us": 923662, "relative-deadline-us": 923662,
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -172,7 +154,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 31597, "expected-execution-us": 31597,
"relative-deadline-us": 47396, "relative-deadline-us": 47396,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -181,7 +162,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 31597, "expected-execution-us": 31597,
"relative-deadline-us": 50555, "relative-deadline-us": 50555,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -190,7 +170,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 31597, "expected-execution-us": 31597,
"relative-deadline-us": 53715, "relative-deadline-us": 53715,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -199,7 +178,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 31597, "expected-execution-us": 31597,
"relative-deadline-us": 56875, "relative-deadline-us": 56875,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -208,7 +186,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 31597, "expected-execution-us": 31597,
"relative-deadline-us": 60034, "relative-deadline-us": 60034,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -217,7 +194,6 @@
"path": "license_plate_detection.wasm.so", "path": "license_plate_detection.wasm.so",
"expected-execution-us": 31597, "expected-execution-us": 31597,
"relative-deadline-us": 63194, "relative-deadline-us": 63194,
"http-resp-size": 1048576,
"http-resp-content-type": "text/plain", "http-resp-content-type": "text/plain",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -226,7 +202,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 138903, "expected-execution-us": 138903,
"relative-deadline-us": 208354, "relative-deadline-us": 208354,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png", "http-resp-content-type": "image/png",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -235,7 +210,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 138903, "expected-execution-us": 138903,
"relative-deadline-us": 222245, "relative-deadline-us": 222245,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png", "http-resp-content-type": "image/png",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -244,7 +218,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 138903, "expected-execution-us": 138903,
"relative-deadline-us": 236135, "relative-deadline-us": 236135,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png", "http-resp-content-type": "image/png",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -253,7 +226,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 138903, "expected-execution-us": 138903,
"relative-deadline-us": 250025, "relative-deadline-us": 250025,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png", "http-resp-content-type": "image/png",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -262,7 +234,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 138903, "expected-execution-us": 138903,
"relative-deadline-us": 263916, "relative-deadline-us": 263916,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png", "http-resp-content-type": "image/png",
"admissions-percentile": 90 "admissions-percentile": 90
}, },
@ -271,7 +242,6 @@
"path": "resize_image.wasm.so", "path": "resize_image.wasm.so",
"expected-execution-us": 138903, "expected-execution-us": 138903,
"relative-deadline-us": 277806, "relative-deadline-us": 277806,
"http-resp-size": 1524000,
"http-resp-content-type": "image/png", "http-resp-content-type": "image/png",
"admissions-percentile": 90 "admissions-percentile": 90
} }

Loading…
Cancel
Save