Sui.

Post

Share your knowledge.

i love god.
Aug 27, 2025
Expert Q&A

What are the best practices for writing high-performance Move modules on Sui?

What are the best practices for writing high-performance Move modules on Sui?

  • Sui
2
7
Share
Comments
.

Answers

7
obito.
Sep 3 2025, 08:56
  • Minimize shared writes. Do 99% of work on owned/immutable objects; touch shared objects once, briefly.
  • Shard global state. Split by pool/market/price-level/etc. to reduce contention; avoid monolithic “registry” objects.
  • Small, flat objects. Prefer many small child objects over one huge map; keep structs tight (no bloated vectors/strings).
  • Derive IDs, don’t count. Use tx_context::derive_id()/hashes instead of global counters.
  • Read > write. Use &T when possible; only take &mut for the exact field you mutate.
  • Cheap lookups. Choose the right container (e.g., tables for sparse keys, vectors for tiny, indexable sets).
  • Batch locally. Mutate multiple owned objects, then settle a single shared update.
  • Emit lean events. Log only what you must; events cost gas.
  • Recycle storage. Delete/merge unused child objects to get storage rebates; avoid churny dynamic fields.
  • Fail fast, not often. Validate early to avoid aborts after heavy work; structure code paths to minimize retries.
2
Comments
.
Copeee.
Aug 27 2025, 00:21

Versioning: Always maintain a clear versioning scheme in your package metadata and documentation so integrators know what changed.

1
Comments
.
Opiiii.
Opiiii1029
Aug 27 2025, 00:22

mutable – cannot ever be upgraded.

compatible – only backward-compatible changes are allowed (e.g., adding new functions, but not changing existing signatures).

custom – more flexible, you can implement custom checks for upgrades.

Upgrade Flow The upgrade process is two-step:

Prepare Upgrade → Validate the new version against the chosen policy.

1
Comments
.
Hemerald34.
Aug 27 2025, 00:36

You write high-performance Move modules on Sui by keeping your logic object-centric and minimizing unnecessary state updates. Design your objects so that transactions only touch what they need, since Sui’s parallel execution performs best when conflicts are rare. Use capabilities for fine-grained access control instead of large shared states, and avoid deep object nesting that can slow down lookups. Emit events for off-chain tracking rather than storing full histories on-chain to save gas and storage. Keep functions small, predictable, and use clear invariants so the Move Prover can optimize verification. Benchmark with dev-inspect to profile gas usage and restructure code when you find hot spots.

Read more here: Best Practices for Move on Sui.

1
Comments
.
Jedoyak.
Aug 27 2025, 00:24

Minimize storage reads/writes to reduce gas and improve speed

Use value types over references when possible

Keep object structures simple and avoid deep nesting

Avoid redundant logic and reuse computed values

Limit cross-object dependencies to enable parallel execution

Profile gas usage to spot expensive operations

Design efficient entry functions and delegate logic internally

Simplify access control to keep logic clean and fast

0
Comments
.

Do you know the answer?

Please log in and share it.