mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
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
4 changed files with 12 additions and 6 deletions
|
@ -346,6 +346,10 @@
|
||||||
#cmakedefine01 REGEX_DEBUG
|
#cmakedefine01 REGEX_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef REQUESTSERVER_DEBUG
|
||||||
|
#cmakedefine01 REQUESTSERVER_DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef RESIZE_DEBUG
|
#ifndef RESIZE_DEBUG
|
||||||
#cmakedefine01 RESIZE_DEBUG
|
#cmakedefine01 RESIZE_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -145,6 +145,7 @@ set(PTHREAD_DEBUG ON)
|
||||||
set(PTMX_DEBUG ON)
|
set(PTMX_DEBUG ON)
|
||||||
set(REACHABLE_DEBUG ON)
|
set(REACHABLE_DEBUG ON)
|
||||||
set(REGEX_DEBUG ON)
|
set(REGEX_DEBUG ON)
|
||||||
|
set(REQUESTSERVER_DEBUG ON)
|
||||||
set(RESIZE_DEBUG ON)
|
set(RESIZE_DEBUG ON)
|
||||||
set(RESOURCE_DEBUG ON)
|
set(RESOURCE_DEBUG ON)
|
||||||
set(ROUTING_DEBUG ON)
|
set(ROUTING_DEBUG ON)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ConnectionCache.h"
|
#include "ConnectionCache.h"
|
||||||
|
#include <AK/Debug.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
|
|
||||||
namespace RequestServer::ConnectionCache {
|
namespace RequestServer::ConnectionCache {
|
||||||
|
@ -19,7 +20,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgln("Request for {} finished", url);
|
dbgln_if(REQUESTSERVER_DEBUG, "Request for {} finished", url);
|
||||||
|
|
||||||
ConnectionKey key { url.host(), url.port_or_default() };
|
ConnectionKey key { url.host(), url.port_or_default() };
|
||||||
auto fire_off_next_job = [&](auto& cache) {
|
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->current_url = {};
|
||||||
connection->removal_timer->on_timeout = [ptr = connection.ptr(), &cache_entry = *it->value, key = it->key, &cache]() mutable {
|
connection->removal_timer->on_timeout = [ptr = connection.ptr(), &cache_entry = *it->value, key = it->key, &cache]() mutable {
|
||||||
Core::deferred_invoke([&, key = move(key), ptr] {
|
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; });
|
auto did_remove = cache_entry.remove_first_matching([&](auto& entry) { return entry == ptr; });
|
||||||
VERIFY(did_remove);
|
VERIFY(did_remove);
|
||||||
if (cache_entry.is_empty())
|
if (cache_entry.is_empty())
|
||||||
|
@ -58,9 +59,9 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
|
||||||
if (!is_connected) {
|
if (!is_connected) {
|
||||||
// Create another socket for the connection.
|
// Create another socket for the connection.
|
||||||
connection->socket = SocketType::construct(nullptr);
|
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();
|
auto request = connection->request_queue.take_first();
|
||||||
connection->timer.start();
|
connection->timer.start();
|
||||||
connection->current_url = url;
|
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];
|
auto& connection = sockets_for_url[index];
|
||||||
if (!connection.has_started) {
|
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.has_started = true;
|
||||||
connection.removal_timer->stop();
|
connection.removal_timer->stop();
|
||||||
connection.timer.start();
|
connection.timer.start();
|
||||||
connection.current_url = url;
|
connection.current_url = url;
|
||||||
start_job(*connection.socket);
|
start_job(*connection.socket);
|
||||||
} else {
|
} 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));
|
connection.request_queue.append(move(start_job));
|
||||||
}
|
}
|
||||||
return connection;
|
return connection;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue