Movespan
Block-STM contention profiler · Aptos Move

Your contract is serializing. Find out where.

Aptos runs a block in parallel and re-executes only what conflicts. But one counter every transaction touches, one pool every swap mutates, and the whole block collapses into a single chain. Movespan names the resource costing you parallelism — and tells you what fixing it is worth, before you refactor anything.

counter fixture · 24 transactions · 8 Block-STM worker threads
span 24
Parallelizability 12.5%
Speedup 1.00x
Conflict edges 99
Blocking resource counter::Counter

Left: every transaction reads the value the one before it wrote, so all 24 land on a single worker. Right: the counter becomes an aggregator, the dependency disappears, and the same work spreads across all 8. Measured on the real fixture — 7.69x of an 8x ideal.

01

Two lines of Move, an order of magnitude apart

Nothing in the toolchain flags the difference. Both compile, both pass tests, both are correct. One of them throws away the reason you chose Aptos.

serializes the block
// every swap mutates the same Pool
public entry fun swap(user: &signer, amt: u64) {
    let pool = borrow_global_mut<Pool>(@amm);
    pool.reserve_x = pool.reserve_x + amt;
    // ^ 199 read-after-write deps
    //   → 1.00x on 32 threads
}
stays parallel
// shard the hot field per user
public entry fun swap(user: &signer, amt: u64) {
    let s = borrow_global_mut<Shard>(shard_of(user));
    s.reserve_x = s.reserve_x + amt;
    // ^ writers stop colliding
    //   → 9.11x on 32 threads
}

02

It doesn't say "slow". It says what to change.

Every hotspot is re-scored with that location made non-conflicting, so the projected speedup is measured against the model rather than guessed at.

$ movespan analyze --package ./amm --module-address 0xA11CE --threads 32
MOVESPAN CONTENTION REPORT
==========================

Transactions       : 200
Threads modeled    : 32
Parallelizability  : 3.1%
Estimated speedup  : 1.00x of 32x ideal
Work / span        : 82412 / 82412
Conflict edges     : 235

TOP CONTENTION HOTSPOTS
-----------------------
 1. 0xa11ce::amm::Pool  (199 deps, blocked cost 82372)
 2. 0x700d…::amm::LpBalance  (5 deps, blocked cost 250)

RECOMMENDATIONS
---------------

[1] 0xa11ce::amm::Pool
    problem: a shared resource many transactions mutate together.
    fix    : shard the resource per user address so unrelated
             writers stop colliding on one object.
    impact : 1.00x → 9.11x  (+8.11x, 28% parallel)

03

Observed, not inferred

Access sets come from the actual VM. Static analysis cannot know which dynamic address a transaction will touch, and a wrong access set produces a confidently wrong report.

01 / EXECUTE

Real transactions

Your package is published into an in-memory chain and the workload runs against it — through the real Aptos VM, not a simulation of one.

02 / CAPTURE

Every read and write

A recording state view wraps the executor and observes each read; writes come from the transaction's write set. One transaction per block, so attribution is exact.

03 / MODEL

The conflict graph

Transaction j depends on i when it reads what i wrote. A list scheduler over Block-STM's workers gives work, span, and the parallelism actually available.

04 / ADVISE

Simulate the fix

Rank locations by the work they block, map each to a concrete Aptos refactor, then re-run the whole model with that location neutralized.

Gas payment, sequence numbers and other framework state are excluded on purpose. They touch 100% of every block, so they out-rank whatever your contract actually does wrong — and no contract author can refactor them.


04

Measured, and checkable by hand

The counter fixture is a correctness oracle rather than a benchmark. 100 transactions against one global counter must produce exactly 99 read-after-write dependencies, a fully serial schedule, and a score of exactly 1/8 on 8 threads. It does. That is why the model is trustworthy and not merely plausible.

FixtureWorkloadParallelizabilityTop hotspotSimulated fix
counter 100 txns · 8 threads 12.5% counter::Counter (99 deps) 1.00x → 7.69x
amm 200 txns · 32 threads 3.1% amm::Pool (199 deps) 1.00x → 9.11x

Figures from a debug build, hence the reduced transaction counts. The committed workloads use 2000 transactions and want a release build.


05

What these numbers are, precisely

A profiler that overstates its own accuracy is worse than no profiler. So, plainly:


06

Run it

The model is a pure Rust workspace with no Aptos dependency — it compiles and tests in under a second. Only the capture layer needs aptos-core.

# 1 — prove the model (no Aptos build needed)
cargo test --workspace

# 2 — build the profiler (one-time aptos-core build)
cd app && cargo build --release --locked

# 3 — compile a contract and profile it
(cd fixtures/counter && aptos move compile --named-addresses counter=0xC0FFEE)

app/target/release/movespan analyze \
  --package fixtures/counter \
  --module-address 0xC0FFEE \
  --workload workloads/counter.toml

--min-score 0.4 exits non-zero below a threshold, so a pull request that regresses contention fails CI the way an untested one fails a coverage gate.