Sui.

Post

Share your knowledge.

BigSneh.
Jul 25, 2025
Expert Q&A

How do I optimize my Move code for parallel execution

I know Sui supports parallel transaction processing, but I’m not sure how to structure my Move code to take advantage of it. Any tips?

  • Sui
  • SDKs and Developer Tools
  • Move
4
6
Share
Comments
.

Answers

6
290697tz.
Jul 25 2025, 13:42

Here you go!

  1. Use Unique Owned Objects Design your smart contracts so each user or asset has its own uniquely owned object. Sui can parallelize transactions that interact with distinct objects.

  2. Avoid Global Mutable State Refrain from using shared mutable objects unless necessary. Shared objects can cause conflicts and reduce concurrency.

  3. Minimize Object Dependencies Limit the number of objects a function reads or writes. The fewer overlapping objects, the more likely transactions can be executed in parallel.

  4. Design Stateless Entry Points If possible, make your entry functions operate on just one or two objects. This reduces the chance of lock contention between transactions.

  5. Use Immutable or Read-Only Data Use &T references to read data instead of mutating it, where possible. Multiple transactions can read the same object in parallel.

  6. Avoid Cross-User Object Access Don’t let one user’s transaction modify another user’s object. This breaks parallelism and increases risk.

  7. Simulate and Test Use Sui’s localnet and transaction blocks to simulate many operations. Monitor how Sui handles parallel execution and adjust your object model.

By isolating object usage and keeping mutation localized to owned resources, you enable your app to scale better and execute faster on Sui’s parallel runtime.

1
Best Answer
Comments
.
Paul.
Paul4340
Jul 31 2025, 15:33

To optimize your Move code for parallel execution on Sui, the key is making sure your transactions are independent. Here’s how you can do that:

  1. Avoid Shared State: Ensure your transactions don’t depend on the same object. If they do, Sui can’t run them in parallel. For example, if you’re updating multiple user records, make sure each update happens in its own transaction.

  2. Split Work Into Independent Tasks: Instead of doing everything in one big transaction, break it down. For example, if you're processing multiple objects, split the work so that each object is handled in a separate transaction.

  3. Use Separate Objects: If you’re modifying objects, ensure each transaction works on a different one. Sui can process them in parallel if they don’t interfere with each other.

  4. Batch Independent Operations: If you can, batch similar tasks (like transfers or updates) into smaller, independent transactions. This way, they can run simultaneously.

  5. Test and Monitor: Once you’ve split up your code, test it and see how Sui handles it. Use Sui’s tools to check if the parallel execution is happening as expected.

In short, structure your code so each transaction is independent, and Sui will handle the rest!

8
Comments
.
Owen.
Owen4662
Jul 30 2025, 17:08

To optimize Move code for parallel execution on Sui, design your application to minimize shared state. Use owned objects instead of shared ones, as transactions operating on owned objects can execute in parallel without coordination. Avoid bottlenecks by structuring data so that users interact with independent objects (e.g., per-user vaults). Use Table or Bag for large collections instead of embedding data directly in structs. This reduces object size and contention, enabling higher throughput. Ensure transactions do not depend on the same object unless necessary, as this forces serialization.

7
Comments
.
HeavenSky.
Sep 7 2025, 17:28

Hey! The key is to design your contracts around owned objects. Transactions that operate on disjoint sets of owned objects can execute in parallel without conflict. Shared objects, especially those frequently written to, act as global mutexes and can become bottlenecks. So, aim to have most user-specific data or state exist within objects owned by individual users or other distinct entities, rather than centralizing everything in a few shared objects. Immutable objects are also excellent for parallelism as they can be read concurrently by many transactions. Think about how to partition your data so different transactions touch different parts.

7
Comments
.
SuiLover.
Jul 27 2025, 07:43

To optimize Move code for parallel execution on Sui, avoid unnecessary shared object references. Use distinct, owned objects in transactions to allow independent execution paths. Minimize dependencies on global or shared state when designing smart contracts. Leverage fine-grained resource partitioning to reduce contention. Profile and test using Sui tools to identify and resolve bottlenecks.

2
Comments
.

Do you know the answer?

Please log in and share it.