# py-spy, 20 s at 250 Hz, ONE replica of n2-api1-pg2-pool10, k6 240 req/s (ok 235.6 req/s for the whole stand) # label baseline-3f45eb1, commit 3f45eb1; samples 3889 (idle in the event loop poll: 0.0 %) ## Share of samples by library (innermost known frame) 52.7 % psycopg (PostgreSQL driver + pool) 23.0 % asyncio / uvloop (event loop) 9.6 % messenger (our code) 4.4 % uvicorn + httptools (HTTP server) 3.7 % redis-py (Valkey client) 2.9 % logging (access log JSON lines) 2.2 % starlette (routing, middleware, responses) 1.3 % json (stdlib) 0.2 % other ## Top 25 functions by SELF time (on top of the stack) 15.5 % run (asyncio/runners.py) 13.8 % wait_async (psycopg/waiting.py) 7.1 % _exec_command (psycopg/_connection_base.py) 5.8 % _send_query_prepared (psycopg/_cursor_base.py) 4.1 % _maybe_prepare_gen (psycopg/_cursor_base.py) 2.9 % send (http/httptools_impl.py) 2.1 % _execute_send (psycopg/_cursor_base.py) 1.9 % writelines (asyncio/streams.py) 1.3 % _select_current_result (psycopg/_cursor_base.py) 1.1 % unit (messenger/db.py) 1.1 % wait (psycopg/connection_async.py) 1.1 % rfc3339 (messenger/timefmt.py) 1.0 % __call__ (messenger/app.py) 0.9 % reschedule (asyncio/timeouts.py) 0.9 % work (messenger/repo.py) 0.9 % wakeup (psycopg/waiting.py) 0.8 % maybe_add_to_cache (psycopg/_preparing.py) 0.8 % convert (psycopg/_queries.py) 0.8 % get (psycopg/_preparing.py) 0.7 % ensure_future (asyncio/tasks.py) 0.7 % execute (psycopg/connection_async.py) 0.7 % getconn (psycopg_pool/pool_async.py) 0.6 % __aenter__ (contextlib.py) 0.6 % __aexit__ (asyncio/timeouts.py) 0.6 % execute (psycopg/cursor_async.py) ## Top 25 functions by TOTAL time (anywhere in the stack) 46.6 % run (asyncio/runners.py) 46.6 % (messenger/__main__.py) 46.6 % run (uvicorn/server.py) 46.6 % main (messenger/__main__.py) 46.6 % _run_module_as_main () 46.6 % _run_code () 27.8 % wait_async (psycopg/waiting.py) 27.4 % wait (psycopg/connection_async.py) 20.3 % unit (messenger/db.py) 15.3 % _maybe_prepare_gen (psycopg/_cursor_base.py) 14.9 % execute (psycopg/cursor_async.py) 14.7 % _execute_gen (psycopg/_cursor_base.py) 13.9 % execute (psycopg/connection_async.py) 11.9 % __call__ (messenger/app.py) 11.8 % app (starlette/routing.py) 11.4 % wrapped_app (starlette/_exception_handler.py) 11.1 % __call__ (middleware/errors.py) 10.8 % work (messenger/repo.py) 10.5 % __call__ (starlette/applications.py) 10.3 % create_message (messenger/app.py) 10.1 % run_asgi (http/httptools_impl.py) 9.6 % handle (starlette/routing.py) 9.1 % __call__ (starlette/routing.py) 8.7 % __call__ (middleware/exceptions.py) 7.5 % _exec_command (psycopg/_connection_base.py)