summaryrefslogtreecommitdiff
path: root/Userland/Services/RequestServer
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2022-01-21 20:04:58 -0500
committerLinus Groh <mail@linusgroh.de>2022-01-22 01:28:01 +0000
commit6d532649d4ed6c7ed969b9a865eef7ea5546f848 (patch)
tree084b6d22c0485939dcd87d0e19fb002d97c78af6 /Userland/Services/RequestServer
parent0e56dac51e294cd1195a2bae9793aa0554468d29 (diff)
downloadserenity-6d532649d4ed6c7ed969b9a865eef7ea5546f848.zip
RequestServer+AK: Move happy-path logging behind REQUESTSERVER_DEBUG
vdbgln() was responsible for ~10% of samples on pv's flamegraph for RequestServer (under request_did_finish) when loading github.com in Browser and recording a whole-system profile. This makes that almost completely disappear.
Diffstat (limited to 'Userland/Services/RequestServer')
-rw-r--r--Userland/Services/RequestServer/ConnectionCache.cpp9
-rw-r--r--Userland/Services/RequestServer/ConnectionCache.h4
2 files changed, 7 insertions, 6 deletions
diff --git a/Userland/Services/RequestServer/ConnectionCache.cpp b/Userland/Services/RequestServer/ConnectionCache.cpp
index 32956a34cc..85ae1c66a2 100644
--- a/Userland/Services/RequestServer/ConnectionCache.cpp
+++ b/Userland/Services/RequestServer/ConnectionCache.cpp
@@ -5,6 +5,7 @@
*/
#include "ConnectionCache.h"
+#include <AK/Debug.h>
#include <LibCore/EventLoop.h>
namespace RequestServer::ConnectionCache {
@@ -19,7 +20,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
return;
}
- dbgln("Request for {} finished", url);
+ dbgln_if(REQUESTSERVER_DEBUG, "Request for {} finished", url);
ConnectionKey key { url.host(), url.port_or_default() };
auto fire_off_next_job = [&](auto& cache) {
@@ -40,7 +41,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
connection->current_url = {};
connection->removal_timer->on_timeout = [ptr = connection.ptr(), &cache_entry = *it->value, key = it->key, &cache]() mutable {
Core::deferred_invoke([&, key = move(key), ptr] {
- dbgln("Removing no-longer-used connection {} (socket {})", ptr, ptr->socket);
+ dbgln_if(REQUESTSERVER_DEBUG, "Removing no-longer-used connection {} (socket {})", ptr, ptr->socket);
auto did_remove = cache_entry.remove_first_matching([&](auto& entry) { return entry == ptr; });
VERIFY(did_remove);
if (cache_entry.is_empty())
@@ -58,9 +59,9 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
if (!is_connected) {
// Create another socket for the connection.
connection->socket = SocketType::construct(nullptr);
- dbgln("Creating a new socket for {} -> {}", url, connection->socket);
+ dbgln_if(REQUESTSERVER_DEBUG, "Creating a new socket for {} -> {}", url, connection->socket);
}
- dbgln("Running next job in queue for connection {} @{}", &connection, connection->socket);
+ dbgln_if(REQUESTSERVER_DEBUG, "Running next job in queue for connection {} @{}", &connection, connection->socket);
auto request = connection->request_queue.take_first();
connection->timer.start();
connection->current_url = url;
diff --git a/Userland/Services/RequestServer/ConnectionCache.h b/Userland/Services/RequestServer/ConnectionCache.h
index 451edb718a..1f9d87c70e 100644
--- a/Userland/Services/RequestServer/ConnectionCache.h
+++ b/Userland/Services/RequestServer/ConnectionCache.h
@@ -105,14 +105,14 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job)
}
auto& connection = sockets_for_url[index];
if (!connection.has_started) {
- dbgln("Immediately start request for url {} in {} - {}", url, &connection, connection.socket);
+ dbgln_if(REQUESTSERVER_DEBUG, "Immediately start request for url {} in {} - {}", url, &connection, connection.socket);
connection.has_started = true;
connection.removal_timer->stop();
connection.timer.start();
connection.current_url = url;
start_job(*connection.socket);
} else {
- dbgln("Enqueue request for URL {} in {} - {}", url, &connection, connection.socket);
+ dbgln_if(REQUESTSERVER_DEBUG, "Enqueue request for URL {} in {} - {}", url, &connection, connection.socket);
connection.request_queue.append(move(start_job));
}
return connection;