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.
This commit is contained in:
parent
0e56dac51e
commit
6d532649d4
Notes:
sideshowbarker
2024-07-17 20:27:56 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/6d532649d4e Pull-request: https://github.com/SerenityOS/serenity/pull/12061 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg ✅
4 changed files with 12 additions and 6 deletions
AK
Meta/CMake
Userland/Services/RequestServer
|
@ -346,6 +346,10 @@
|
|||
#cmakedefine01 REGEX_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef REQUESTSERVER_DEBUG
|
||||
#cmakedefine01 REQUESTSERVER_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef RESIZE_DEBUG
|
||||
#cmakedefine01 RESIZE_DEBUG
|
||||
#endif
|
||||
|
|
|
@ -145,6 +145,7 @@ set(PTHREAD_DEBUG ON)
|
|||
set(PTMX_DEBUG ON)
|
||||
set(REACHABLE_DEBUG ON)
|
||||
set(REGEX_DEBUG ON)
|
||||
set(REQUESTSERVER_DEBUG ON)
|
||||
set(RESIZE_DEBUG ON)
|
||||
set(RESOURCE_DEBUG ON)
|
||||
set(ROUTING_DEBUG ON)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue