---
title: "Measuring the cost of Observe"
description: "Full observation added 20% to elapsed time with two workers handling requests to 64 actors. With eight workers, the increase was 12.3%."
source: "https://hew.sh/blog/2026/11/measuring-hew-in-the-cloud"
---

With Observe switched off, a Hew program running on two workers took about 136 milliseconds to complete 27,648 actor requests. With the profiler and tracing enabled, it took 163 milliseconds. We wanted to know how much of that extra time came with the basic counters, and what happened when the runtime had more workers available.

## What the actors did

We gave each of 64 client tasks its own counter actor. Each request ran this handler.

```hew
actor Counter {
    var count: i64;
    receive fn increment() -> i64 {
        count += 1;
        count
    }
}
```

Each client asked its actor to increment the count, waited for the reply, added the returned value to a running sum and sent its next request. Clients could run concurrently. Within each client the previous reply had to arrive before the next request went out. For the two-worker profiler test each counter started at zero and received 432 requests, so the expected sum across all 64 clients was 5,985,792. The runner checked the sum on every execution.

There are a few ways an Observe user might run that program. With `HEW_OBSERVE=hot`, the runtime records measurements such as allocation counts and actor turns attributed to their handlers. Full observation adds tracing and starts a profiler endpoint with its sampler. In the benchmark, the runtime paid the cost of recording this data while the endpoint had no reader attached. The program checked that the requested mode had taken effect before starting the clients. [Hew's Observe counters](https://github.com/hew-lang/hew/blob/cee7217158795e65180db7255037b1e97d50f69a/docs/observe.md#metrics-surface)

## Timing the same executable twice

On October 30, we ran each pair on one Intel C4 VM. In 11 of the 21 full-observation pairs, the off run went first. The other ten ran in the opposite order. One pair came in at 135.8 ms off and 162.2 ms on, about 19.5% extra elapsed time. Across all 21 pairs the increases ranged from 15.5% to 26.5%.

The control used the same executable with Observe off both times. The control still produced individual timing differences from −4.1% to +6.3%. The geometric mean of their timing ratios put the difference at −0.08%. For each whisker in the chart, we resampled whole pairs 10,000 times and took the middle 95% of the estimates. The control interval ran from −1.24% to +1.13%.

<figure class="benchmark-figure">
  <a href="/images/blog/cloud-benchmarks/observation.svg" title="Open full-size figure"><img src="/images/blog/cloud-benchmarks/observation.svg" alt="Paired elapsed-time changes on two workers. Both executions with Observe off differed by −0.08%; hot counters added 6.82%, and full observation added 20.03%. Whiskers show 95% bootstrap intervals." /></a>
  <figcaption>All three comparisons used two workers. Whiskers cover 95% of the paired bootstrap estimates.</figcaption>
</figure>

With two workers, hot counters alone added 6.8% to elapsed time. With eight workers their estimated cost fell to 0.9%, with an interval from −0.8% to +2.7%. The full configuration added 12.3% on eight workers. The runner calibrated the number of requests separately for each comparison and kept that count fixed within each pair.

## Where the CPU time went

On a busy machine we also care about the CPU time the process used across all its threads. Two threads running concurrently can accumulate two milliseconds of CPU time in one millisecond on the clock. We divided each pair's difference in process time by the number of completed requests. Those figures include profiler startup and shutdown, spread across the batch.

<figure class="benchmark-figure">
  <a href="/images/blog/cloud-benchmarks/observe-cpu-and-elapsed.svg" title="Open full-size figure"><img src="/images/blog/cloud-benchmarks/observe-cpu-and-elapsed.svg" alt="With full Observe, each completed request added 0.99 microseconds of elapsed time and 1.64 microseconds of CPU time on two workers. On eight workers the corresponding costs were 0.45 and 3.75 microseconds." /></a>
  <figcaption>Elapsed time uses the wall clock. CPU time adds up the work done by all process threads.</figcaption>
</figure>

The eight-worker batch incurred roughly half as much extra elapsed time per request as the two-worker run. It also consumed over twice as much extra CPU time per request. Both runs needed more resident memory with full observation, about 7 MiB at peak. A service running alongside other CPU-intensive processes has to budget for those processor cycles even when its own completion time changes little.

## Echoing a request across two VMs

The network tests timed each round trip on the client's monotonic clock. In one version a TCP server echoed 64 bytes. In the other, a Hew client sent the payload to a remote actor over an authenticated connection and checked the reply. The latter included actor dispatch and the work of encoding the message. We enabled the same observation mode at both ends. Each trial began with 32 warmup requests, followed by 1,024 measured round trips with one request outstanding.

<figure class="benchmark-figure">
  <a href="/images/blog/cloud-benchmarks/observe-network-rtt.svg" title="Open full-size figure"><img src="/images/blog/cloud-benchmarks/observe-network-rtt.svg" alt="Same-zone round trips with hot counters off and on. The TCP median moved from 45.3 to 45.6 microseconds. The remote actor median moved from 78.1 to 85.5 microseconds, and its 99th percentile from 98.9 to 106.4 microseconds." /></a>
  <figcaption>The client timed each echo. Each mark is the median of the corresponding percentile across 21 trials.</figcaption>
</figure>

For each trial we sorted its 1,024 timings and took its percentiles. Each mark in the chart is the median of that percentile across 21 trials. The TCP median changed by about 0.3 µs, within the variation of the control runs. For the actor echo, the median moved by 7.4 µs and the 99th percentile by 7.5 µs. Because we enabled counters on both machines, the 7.4 µs includes work on both ends of the connection. A repeat with just the sender instrumented would isolate its contribution.

We also tried a busier client. Eight tasks each sent 128 requests of 4 KiB to the same remote actor, with up to eight requests outstanding. Within a zone, the median throughput fell from about 27,700 requests per second to 24,900 when we enabled hot counters. At the 99th percentile a reply took 466 µs with counters off and 558 µs with them on. That test changed both concurrency and payload size. Its tail latencies describe a different service load from the 64-byte echo.

Placement mattered too. In the TCP controls, the median same-zone round trip was about 45 µs. The median across two zones in the same region was about 510 µs. We kept the endpoints in place for each off/on comparison.

The October suite also timed equivalent vector operations in Hew and Rust. Scanning 4,096 elements took 3.76 times as long in Hew. A vector scan gave us a small loop we could inspect all the way down to the machine instructions. In November, we used it to investigate [a timing difference between two Hew builds](/blog/2026/11/when-identical-instructions-run-at-different-speeds/).
