-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Implement performance optimizations for the governance-as-operator pattern: batch state transition processing and governance rule caching to minimize cross-zome call overhead.
Context
Cross-zome calls in Holochain add latency. When multiple state transitions need evaluation (e.g., bulk transfers, process chains), the overhead can become significant. This issue addresses optimization after the core pattern is functional.
Technical Implementation
1. Batch State Transitions
#[hdk_extern]
pub fn batch_state_transitions(
requests: Vec<GovernanceTransitionRequest>,
) -> ExternResult<Vec<GovernanceTransitionResult>> {
// Group requests by resource specification
// Load governance rules once per group
// Process all requests in each group
}Benefits:
- Single rule loading for multiple transitions on same resource type
- Reduced cross-zome call count
- Atomic processing of related transitions
2. Governance Rule Caching
pub struct LazyRuleEvaluator {
cached_rules: LruCache<ActionHash, Vec<GovernanceRule>>,
}Cache governance rules per resource specification to avoid repeated DHT lookups within the same evaluation context.
3. Permission Caching
Cache agent permission lookups within a batch or session to avoid repeated role queries.
4. Process Chain Optimization
For multi-step processes (e.g., Use → Modify → Transfer), optimize the chain of governance evaluations to share context between steps.
Acceptance Criteria
-
batch_state_transitionsfunction processes multiple requests efficiently - Rule caching reduces DHT lookups for repeated specification queries
- Permission caching works within batch processing
- Process chain optimization shares context between related transitions
- Performance benchmarks show measurable improvement over individual calls
- No correctness regression — cached results match uncached results
Dependencies
- Implement pure-function GovernanceEngine for state transition evaluation #42 (GovernanceEngine implementation)
- Refactor resource zome to use Request-Evaluate-Apply pattern #43 (Resource zome Request-Evaluate-Apply pattern)
- Governance-as-operator testing infrastructure: mock engine and cross-zome tests #45 (Testing infrastructure for performance verification)
Priority Note
This is P3-medium — implement after the core governance-as-operator pattern is functional and tested. Optimize based on measured performance, not speculation.
Definition of Done
- Batch processing implemented
- Caching implemented with appropriate invalidation
- Performance benchmarks documented
- All existing tests still pass
- Code review completed
Metadata
Metadata
Assignees
Labels
Type
Projects
Status