Skip to main content

Profiling

Vox has a profiler of its own, which is off by default and can be turned on while Vox runs, without a restart or a new deployment. While it's on, every host of the deployment records what Vox does and how long each part takes: API requests, entity writes, imports, the rounds of the change processing, each calculation evaluated, projection publications, assessments, the background loops and every database command. When it stops, the result is a trace that's downloaded as one zip file and read in a tool, or sent to support.

Use it when Vox is slower than expected and the logs don't say why, eg "publishing a campaign takes 20 minutes and the product pages don't update until long after". The trace shows where the time went, eg that publication batch 17 took 6 seconds, of which 1.3 went to assessments and 4 to one statement that ran 2,000 times.

Turning it on​

In the admin UI. Open Profiler in the Administration menu, choose a duration (5, 15, 30 or 60 minutes) and optionally a note, eg "campaign publish slow, ticket 4711", and select Turn on. The screen shows since when the profiler records, on which hosts, who started it and when it stops. Turn off stops it early. The screen and its API (/vox/api/profiler) need the vox:Profiler permission, which administrators (*) have.

From code, eg in a test or a proof of concept, with IVoxProfiler:

var run = await profiler.StartAsync(TimeSpan.FromMinutes(10), "import of the spring range");
// ... the scenario ...
await profiler.StopAsync();
await using var file = File.Create("vox-profile.zip");
await profiler.WriteTraceAsync(run.Id, file);

From configuration, to profile a host's startup, eg the first load of seed data: set Vox:Profiler:StartupDuration, which builder.AddVox reads into VoxOptions.Profiler.StartupDuration, and the host starts a run as soon as it has migrated its database, or joins the run that records. What happens before, building the model and migrating the database, is in the line the host logs when it has started, see the startup log line. For example, to profile the first five minutes:

dotnet MyApp.dll --Vox:Profiler:StartupDuration 00:05:00

A run applies to the whole deployment: every host that runs Vox records it, API hosts and processing hosts, including a host that starts while it records. Hosts hear of a start or stop at once through Nexus's instance events, and otherwise check every 30 seconds. Only one run records at a time; starting another fails with a message that says who started the active one and when it ends. Blue/green deployments that share a control plane share the run, and the trace shows each host's deployment.

A run always stops by itself at its end, at most an hour after it started by default. Every host knows the end and stops on its own, even when the host that started the run crashed, so a forgotten profiler can't keep running.

The startup log line​

When the host has migrated its database at startup, it logs how long each part of its start took, in one line:

Started the Vox model in 1.20 s: database 0.01 s, applied model 0.00 s, plan 0.01 s, EF model 0.80 s, lock 0.00 s,
schema 0.01 s (unchanged), storage 0.00 s, admissions 0.01 s, activation 0.00 s, VoxUserInitializer 0.02 s.
AddVox built the model in code in 0.50 s: type scan 0.05 s, model 0.40 s, validation 0.05 s

EF model is Entity Framework's model of the tables, which a host builds once and needs to serve requests. lock is the wait for other hosts that migrate the same database. keyed model, when it's there, is the model built again with the keys of the applied model, eg after a rename. schema says whether the schema was compared, eg (unchanged) or (1 of 640 tables changed), see migrating in production.

What it costs​

  • While it's off, the instrumented code checks one field and does nothing else, and each host reads the current run with one small query every 30 seconds.
  • While it's on, each host keeps what it recorded in memory for at most 10 seconds, or until about 1 MB, and then writes it as a compressed chunk to the database. Memory doesn't grow with the length of the run. Once a host has written 50 MB of detail for a run, it keeps only the aggregates (counts and durations by operation and statement), and the trace says from when.

Vox mostly waits for its databases, so the extra work is hard to notice. Measured on PostgreSQL, the first evaluation of 10,000 products took 0.5% longer with the profiler on, and their publication about 4% longer.

What a trace contains​

A download is one zip, named after the run, eg vox-profile-2026-11-16-1402.zip:

  • summary.md: the run, its hosts, the operations, calculations and statements that took the most time, the waits and failures, the backlogs of background work at the start and end, the system snapshot and the database server's statistics. Readable as it is. Each operation also has the memory allocated while it ran, so a step that copies large entities shows up even when it's fast. The allocations are exact for synchronous work. A span that awaits counts the whole process's allocations when it ends on another thread than it started on, and only its own thread's when it ends on the same one, so compare the allocations of such spans with care.
  • The background processing records its steps as operations of their own, eg Product: evaluation: working copy and Product: promotion: reload rows, so a slow batch of recalculations shows whether the time goes to evaluating, comparing or writing the entities.
  • timeline.json: every span, command and event in the Chrome trace event format, each host a process. Open it in Perfetto or chrome://tracing. Spans of one piece of work nest, eg a write within the application's span, the commands within a calculation.
  • aggregates.json, snapshot.json, server-statistics.json and run.json: the full data, for scripts.

What's in it, and what isn't. The trace has no field values and no SQL parameter values. It does have entity ids, eg of the products a calculation evaluated, the text of SQL statements with any literals in them, the names of entity types, calculations and Vox users (who started the run, and who made each API request), and the note of the run. Who a trace is shared with is up to the company running Vox; treat it like a log file.

The system snapshot lists the entity types, their relations and roughly how many entities each has, read without scanning: the row counts the server keeps for SQL Server's and PostgreSQL's tables (estimates, which include deleted entities not yet cleaned up), exact counts of light entity types and on SQLite, and the length of each type's list in Redis. The backlogs count the undispatched dependency changes up to 100,000.

Database server statistics, as the difference between the start and the end of the run:

  • SQL Server: the waits (sys.dm_os_wait_stats), plan compilations and optimizer counters, and the most expensive cached plans of Vox's tables. They need VIEW SERVER STATE, or VIEW SERVER PERFORMANCE STATE on SQL Server 2022 and later. On Azure SQL Database, which has no server-wide views, the database's waits (sys.dm_db_wait_stats) are read instead, which need VIEW DATABASE STATE.
  • PostgreSQL: the statistics of Vox's statements from pg_stat_statements, and the database's counters. The extension must be loaded by the server (shared_preload_libraries = 'pg_stat_statements') and created in the database (CREATE EXTENSION pg_stat_statements), and the role needs pg_read_all_stats to see every statement.
  • SQLite, Redis and Elasticsearch have none.

When rights are missing, the profiler still records, and the snapshot says which statistics were skipped and why.

Not included: commands on connections that aren't Vox's, ie Nexus's queues, jobs and instance events, and the sign-in of the MCP servers' issuer. Redis commands are recorded by name only (eg HGET), and Elasticsearch requests by method and path, with ids replaced. A Redis connection the application provides through ConnectionFactory isn't recorded, since recording would replace any profiler the application registered on it; Vox records the connections it opens itself.

Keeping and deleting traces​

Traces are kept in the control plane's database for 14 days (VoxOptions.Profiler.TraceRetention) and then deleted by Vox's retention. The admin's list of traces can delete one by hand, eg after sending it; a run that still records is turned off first.

Options​

VoxOptions.Profiler:

OptionDefault
DefaultDuration15 minutesHow long a run records when it's started without a duration.
MaxDuration60 minutesThe longest a run may record.
TraceRetention14 daysHow long traces are kept.
RunCheckInterval30 secondsHow often each host reads the current run.
FlushInterval10 secondsHow often a host that records writes a chunk.
ChunkSize1 MBHow much a host buffers before it writes a chunk early.
MaxDetailPerHost50 MBThe compressed detail a host writes for a run before it keeps only aggregates.
RuntimeSampleInterval5 secondsHow often a host samples CPU, GC and the thread pool.
StartupDuration, StartupNotenoneA run the host starts, or joins, as it starts.

Your own spans​

An application can add spans of its own, so the time spent in its code shows where it happened. Eg an import handler that calls an ERP for each batch:

using (profiler.Span("fetch prices from ERP"))
{
prices = await erp.GetPricesAsync(batch, cancellationToken);
}

profiler is the injected IVoxProfiler. The span nests under the Vox span that runs, eg the import batch, and is marked as the application's (app) in the trace. While the profiler is off, Span does nothing and costs next to nothing. Give a span a fixed name, without ids: the trace adds up the spans of each name for the whole run, so $"fetch price {sku}" would add an entry for every product.

Monitoring tools​

Apart from the profiler, Vox publishes a few coarse spans through the standard .NET ActivitySource named CommerceMind.Vox, which anything that listens to .NET activities sees, eg OpenTelemetry with AddSource("CommerceMind.Vox") and Application Insights: vox.write (a write of entities of a type), vox.import (an import batch), vox.processing (a run of the change processing), vox.publication (a projection publication) and vox.work (a round of background work). Rounds that found nothing to do aren't sampled. The meter CommerceMind.Vox.Reads has the metrics of complete reads of an entity type and of evaluations with too many dependencies.

The detail, eg each calculation and database command, is only recorded by the profiler and never published as activities, so turning the profiler on doesn't flood a monitoring tool that listens to everything of Vox.