Skip to content

perf(lease-read): cache LeaseProvider type assertion (deferred from #549) #555

@bootjp

Description

@bootjp

Issue

Coordinate.LeaseRead and groupLeaseRead perform c.engine.(raftengine.LeaseProvider) on every call. Each type assertion is ~1-3 ns; not a bottleneck but trivially cacheable.

Fix

  • Add lp raftengine.LeaseProvider field on Coordinate and ShardGroup.
  • Set once in NewCoordinatorWithEngine / NewShardedCoordinator (after the type assertion).
  • LeaseRead checks c.lp != nil instead of asserting.

Acceptance

  • Same observable behavior; LeaseRead benchmark shows reduced cycles per op.

References: PR #549 (deferred).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions