Skip to content

Benchmarks

What the hot paths cost, measured end to end through the real code: the HTTP pipeline, SQLite in a temporary file (polaristest’s database: foreign keys on, SQLite’s default journal and synchronous), RS256 session tokens unless stated. Numbers are the median of three runs; they move with the machine and the database, so read them as orders of magnitude and as a baseline for regressions, not as a promise.

make bench # every Benchmark* in the module
go test -run '^$' -bench . -benchmem -count 3 ./token/ ./internal/httpapi/ ./plugins/apikeys/ ./plugins/agents/

Machine: Apple M1 Pro (10 cores), 16 GiB, macOS 26.6.2, Go 1.26.11 (darwin/arm64), 2026-11-20.

BenchmarkWhat it measuresns/opB/opallocs/op
token BenchmarkParse/RS256access-token verification: signature, iss, aud, exp/nbf, typ37 4006 54486
token BenchmarkParse/EdDSAthe same with Ed25519 keys51 9004 97677
internal/httpapi BenchmarkLogin/argon2=productionPOST /auth/login, security.Argon2id{} (64 MiB, t=4, p=1: the defaults)195 000 00067 207 776860
internal/httpapi BenchmarkLogin/argon2=cheapthe same with the test suite’s Argon2id (1 MiB, t=1, p=1)3 600 0001 140 553813
internal/httpapi BenchmarkRefreshPOST /auth/token/refresh, single-use rotation (consume, insert, sign)2 590 00085 9291 109
plugins/apikeys BenchmarkProtect/jwta host route behind Protect, session access token122 00028 081376
plugins/apikeys BenchmarkProtect/api_keythe same with an API key (hashed-secret lookup, delegated principal)124 00036 298597
plugins/agents BenchmarkExecute/delegated_tokenPOST /agents/execute with an RFC 8693 exchanged token: grant, budget, schema, handler, hash-chained receipt, audit, one transaction3 160 000152 2392 304
plugins/agents BenchmarkExecute/private_key_jwtthe same with a request JWT signed per call (EdDSA, htm/htu/body_hash, unique jti; signing included)3 040 000135 4082 088

Reading them:

  • Login is Argon2id. With production parameters the hash is ~98% of the time and 64 MiB of memory per concurrent login; size the login rate limit and the instance memory for it (Auth.RateLimits.Login). The cheap parameters show the rest of the path costs ~3.6 ms.
  • Writes are the database. Login, refresh and agent execution each commit a transaction; on SQLite in a file that commit dominates (milliseconds). PostgreSQL/MySQL on a network move the number by their round trips, not by Polaris’s CPU.
  • The denylist is two cache reads. With AUTH_ACCESS_TOKEN_DENYLIST on, Protect reads the user’s entry and the session’s. In memory the second is lost in the noise (64 B and one allocation more, within 1% of the time); a shared cache adds a round trip for each.
  • Reads are cheap. Verifying a token is ~40–50 µs; Protect adds the denylist and the principal’s authority from the database (~120 µs on SQLite).