WebServer: Put dbgln's behind WEBSERVER_DEBUG

These dbgln's caused excessive load in the WebServer process,
accounting for ~67% of the processing time when serving a webpage
with a bunch of resources like serenityos.org/happy/2nd/.
This commit is contained in:
Edwin Hoksberg 2021-05-30 16:42:03 +02:00 committed by Linus Groh
parent a557f83f8c
commit e68780e1ad
3 changed files with 13 additions and 5 deletions

View file

@ -422,6 +422,10 @@
#cmakedefine01 WASM_TRACE_DEBUG
#endif
#ifndef WEBSERVER_DEBUG
#cmakedefine01 WEBSERVER_DEBUG
#endif
#ifndef WINDOWMANAGER_DEBUG
#cmakedefine01 WINDOWMANAGER_DEBUG
#endif

View file

@ -186,6 +186,7 @@ set(WASM_TRACE_DEBUG ON)
set(PDF_DEBUG ON)
set(SOLITAIRE_DEBUG ON)
set(DDS_DEBUG ON)
set(WEBSERVER_DEBUG ON)
# False positive: DEBUG is a flag but it works differently.
# set(DEBUG ON)

View file

@ -6,6 +6,7 @@
#include "Client.h"
#include <AK/Base64.h>
#include <AK/Debug.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/MemoryStream.h>
@ -50,7 +51,7 @@ void Client::start()
}
auto request = builder.to_byte_buffer();
dbgln("Got raw request: '{}'", String::copy(request));
dbgln_if(WEBSERVER_DEBUG, "Got raw request: '{}'", String::copy(request));
handle_request(request);
die();
};
@ -63,9 +64,11 @@ void Client::handle_request(ReadonlyBytes raw_request)
return;
auto& request = request_or_error.value();
dbgln("Got HTTP request: {} {}", request.method_name(), request.resource());
for (auto& header : request.headers()) {
dbgln(" {} => {}", header.name, header.value);
if constexpr (WEBSERVER_DEBUG) {
dbgln("Got HTTP request: {} {}", request.method_name(), request.resource());
for (auto& header : request.headers()) {
dbgln(" {} => {}", header.name, header.value);
}
}
if (request.method() != HTTP::HttpRequest::Method::GET) {
@ -74,7 +77,7 @@ void Client::handle_request(ReadonlyBytes raw_request)
}
auto requested_path = LexicalPath::join("/", request.resource()).string();
dbgln("Canonical requested path: '{}'", requested_path);
dbgln_if(WEBSERVER_DEBUG, "Canonical requested path: '{}'", requested_path);
StringBuilder path_builder;
path_builder.append(m_root_path);