/!\\ Advanced Analysis

Account Lock Analysis

Your PDAs pass collision checks. Great. But under real concurrent load, write locks create invisible bottlenecks that tank your protocol's throughput.

Skaf's Lock Analysis simulates 100 concurrent transactions against your account structure and shows exactly where the serialization happens — before you deploy to mainnet.

collision-free contention-free

Collision checks verify your PDAs derive unique addresses. But unique addresses don't guarantee performance under load.

[ok]

Collision Check

"Do any of my PDA seed combinations produce the same on-chain address?"

> All 4 accounts derive unique addresses. No collisions detected.

Checks: address uniqueness, seed overlap, bump validity

[!!]

Lock Analysis

"When 100 users hit my protocol at once, which accounts become serial bottlenecks?"

> CRITICAL: amm_pool has 89% write contention. Throughput limited to ~11 TPS.

Checks: write-lock conflicts, read/write ratio, serialization depth

How Solana account locks work

Solana's runtime processes transactions in parallel by default. But when two transactions touch the same account, the lock system kicks in.

Parallel (no conflict)

PARALLEL
TX1[W]User A PDA
TX2[W]User B PDA

> Different accounts = both execute simultaneously. Maximum throughput.

Read sharing (safe)

PARALLEL
TX1[R]Config PDA
TX2[R]Config PDA

> Multiple read locks on the same account are allowed. No blocking.

Write conflict (serial)

SERIAL
TX1[W]Pool PDA
TX2[W]Pool PDA

> Two write locks on the same account = forced serial execution. Bottleneck!

Read + Write conflict

SERIAL
TX1[R]Pool PDA
TX2[W]Pool PDA

> Write lock blocks all readers on the same account. Even reads get queued.

Key insight: The more transactions write to the same account, the more they serialize. At 100 concurrent TXs targeting one writable account, your protocol becomes a single-threaded queue.

See it in action

A real DEX AMM account structure — before and after optimization. Toggle to see how sharding transforms the contention profile.

Account Lock AnalysisCRITICAL
amm_pool
R:12% W:88%89%
tick_array
R:28% W:72%72%
position
R:66% W:34%34%
fee_tier
R:92% W:8%8%

> CRITICAL: amm_pool is a serial bottleneck at 89% contention. 100 concurrent TXs queue behind a single write lock.

Optimization strategies

Lock Analysis doesn't just find problems — it suggests solutions. Here are the four patterns that eliminate most contention.

[#]

Account Sharding

Problem

One global account handles all writes

Solution

Split into N partitioned accounts (e.g., pool_0, pool_1, pool_2)

Example:

tick_array → tick_array_0, tick_array_1, tick_array_2

>Contention drops by ~N factor
[U]

Per-User PDAs

Problem

Shared account written by every user TX

Solution

Derive unique PDA per user: seeds = ["position", user_wallet]

Example:

position → position_<wallet_A>, position_<wallet_B>

>Near-zero contention for user accounts
[T]

Time-based Epochs

Problem

Accumulator account updated every TX

Solution

Rotate accounts by epoch: seeds = ["stats", epoch_id]

Example:

stats → stats_epoch_1, stats_epoch_2

>Writes spread across time windows
[R]

Read-only Separation

Problem

Config data mixed with mutable state

Solution

Separate read-only config from writable state into different PDAs

Example:

pool_config (read-only) + pool_state (writable)

>Config reads never block state writes

Real-world examples

How common Solana protocol patterns create contention — and how to fix them.

DEX AMM

Single pool account handles all swaps — 89% contention at peak load

amm_pool89% → 34%
BeforeAfter
tick_array72% → 22%
BeforeAfter

> Sharded tick arrays into 3 partitions, separated pool config from state

2.6x throughput improvement

Lending Protocol

Global reserve account written on every deposit/borrow

reserve95% → 28%
BeforeAfter
obligation15% → 12%
BeforeAfter

> Per-market reserves with epoch-based interest accumulators

3.4x throughput improvement

NFT Marketplace

Listing index account grows linearly, every new listing writes to it

listing_index78% → 18%
BeforeAfter
escrow8% → 5%
BeforeAfter

> Per-collection listing PDAs with user-scoped escrow accounts

4.3x throughput improvement

How it works

From your PDA design to actionable optimization — in one click.

01

Design PDAs

Build your account structure in the visual designer with seeds, space, and relationships.

02

Run Analysis

Click 'Lock Analysis' to simulate 100 concurrent transactions against every account.

03

Find Bottlenecks

See per-account contention scores, read/write ratios, and serialization depth.

04

Optimize & Export

Apply sharding suggestions, verify improvement, and export production-ready Anchor code.

Stop guessing. Start measuring.

Design your PDA structure, run Lock Analysis, find bottlenecks, and export optimized Anchor code — all in one workflow.

89%

Max contention
detected

3.8x

Avg throughput
improvement

<1s

Analysis
time