Scheduler
Last updated
Last updated
In optimistic concurrency control, transactions are allowed to proceed without acquiring locks initially. Conflict detection happens during the validation phase before committing. Transaction causing conflict will be reverted and re-executed to maintain data consistency. This approach assumes conflicts are infrequent, so the success of OCC depends largely on keeping conflicts to a minimum.
Additionally, in a sequential execution design, transaction ordering wouldn't affect execution efficiency much. But in parallel execution, all other factors being equal, execution efficiency is deeply affected by how transactions are organized and planned. Generally, the goal is always to pack as many parallelizable transactions into a single generation as possible to maximize execution efficiency.
In Arcology, the scheduler optimizes transaction processing. It aims to find a balance between minimizing conflict and rollbacks, while maximizing parallel execution. It significantly reduces the chances of conflicts and the need for rollbacks and is an integral part of the concurrency control system.
When a list of transactions enters the scheduler, it first performs a static analysis to assess transaction characteristics such as dependencies, conflict history, resource requirements, and priorities. Contract developers can also manually specify dependency statuses to avoid unnecessary conflicts and rollbacks.
The scheduler then groups transactions into batches called generations, where each generation consists of transactions that are highly likely to execute fully in parallel. in parallel without conflicts. An execution schedule contains one to N generations, with different generations processed sequentially.
All transactions within the same generation are guaranteed to be , meaning they can be executed in any order and still produce the same final state.
In the best case, all transactions in the block are placed in a single generation, enabling full parallel processing. In the worst case, each generation contains only one transaction, which is equivalent to serial execution.
The scheduler takes into account several factors to create a scheduling plan:
Resources Available: The availability of system resources, such as CPU cores, and memory directly impacts the scheduling plan. The scheduler allocates resources efficiently to maximize utilization and throughput. The scheduler can prevent resource contention, bottlenecks, and performance degradation.
Conflict History: Interactions with contracts may have caused conflicts in the past. The scheduler maintains this history and assigns transactions involving potentially conflicting contract interactions to different generations to minimize conflicts.
Transaction Characteristics: Different transactions have varying characteristics that influence their scheduling. For example:
Transaction Priority: High-priority transactions might need to be scheduled before lower-priority ones.
Resource Requirements: Some transactions require more resources than others. The scheduler needs to allocate resources appropriately to ensure fair treatment.
The scheduler keeps track of all conflict information reported by the conflict detector to optimize its execution scheduling for future blocks. Conflict history provides insights into how transactions have interacted in the past. By analyzing past conflicts and their resolutions, the scheduler can better predict potential conflicts and place conflict-prone transactions into serial execution sequences.