Skip to content

Commit

Permalink
Support up to 10MiB http request (microsoft#61)
Browse files Browse the repository at this point in the history
* Changes minimum request size to 10MB to support all models in ONNX Model Zoo
  • Loading branch information
NonStatic2014 authored and tmccrmck committed Apr 30, 2019
1 parent c9c0bf0 commit 8cf8705
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
11 changes: 6 additions & 5 deletions onnxruntime/server/http/core/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ HttpSession::HttpSession(const Routes& routes, tcp::socket socket)
}

void HttpSession::DoRead() {
// Make the request empty before reading,
// otherwise the operation behavior is undefined.
req_ = {};
req_.emplace();

http::async_read(socket_, buffer_, req_,
// TODO: make the max request size configable.
req_->body_limit(10 * 1024 * 1024); // Max request size: 10 MiB

http::async_read(socket_, buffer_, *req_,
net::bind_executor(
strand_,
std::bind(
Expand All @@ -43,7 +44,7 @@ void HttpSession::OnRead(beast::error_code ec, std::size_t bytes_transferred) {
}

// Send the response
HandleRequest(std::move(req_));
HandleRequest(req_->release());
}

void HttpSession::OnWrite(beast::error_code ec, std::size_t bytes_transferred, bool close) {
Expand Down
3 changes: 1 addition & 2 deletions onnxruntime/server/http/core/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class HttpSession : public std::enable_shared_from_this<HttpSession> {
tcp::socket socket_;
net::strand<net::io_context::executor_type> strand_;
beast::flat_buffer buffer_;
http::request<http::string_body> req_;
boost::optional<http::request_parser<http::string_body>> req_;
std::shared_ptr<void> res_{nullptr};

// Writes the message asynchronously back to the socket
Expand Down Expand Up @@ -76,4 +76,3 @@ class HttpSession : public std::enable_shared_from_this<HttpSession> {

} // namespace server
} // namespace onnxruntime

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ModelZooTests(unittest.TestCase):
model_zoo_model_path = '' # Required
model_zoo_test_data_path = '' # Required
supported_opsets = ['opset_7', 'opset_8', 'opset_9']
skipped_models = ['tiny_yolov2']
skipped_models = []

def test_models_from_model_zoo(self):
json_request_headers = {
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/test/server/integration_tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def decode_base64_string(s, count_and_type):
return r


def compare_floats(a, b, rel_tol=0.0001):
if not math.isclose(a, b, rel_tol=rel_tol):
test_log('Not match with relative tolerance {0}: {1} and {2}'.format(rel_tol, a, b))
def compare_floats(a, b, rel_tol=0.0001, abs_tol=0.0001):
if not math.isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol):
test_log('Not match with relative tolerance {0} and absolute tolerance {1}: {2} and {3}'.format(rel_tol, abs_tol, a, b))
return False

return True
Expand Down

0 comments on commit 8cf8705

Please sign in to comment.