Skip to content

perf: reduce store.get calls and mark TokenIdCondition immutable#5

Open
paymog wants to merge 1 commit intoPolymarket:mainfrom
goldsky-io:paymog/perf-reduce-store-get-calls
Open

perf: reduce store.get calls and mark TokenIdCondition immutable#5
paymog wants to merge 1 commit intoPolymarket:mainfrom
goldsky-io:paymog/perf-reduce-store-get-calls

Conversation

@paymog
Copy link

@paymog paymog commented Mar 6, 2026

Summary

  • Pass already-loaded UserBalance entities from _adjustSenderBalance/_adjustReceiverBalance into _setNetPosition instead of reloading them via store.get. Reduces store.get calls per TransferSingle from 9 to 5.
  • Mark TokenIdCondition as @entity(immutable: true) — it is write-once (100% version ratio), enabling graph-node to skip delete_modification_clamp_range queries and cache more efficiently.

Expected impact: ~25-45% reduction in host_export_store_get overhead during block processing.

Test plan

  • pnpm codegen && pnpm build passes (verified locally)
  • Deploy to staging and compare rate(graph_node_deployment_sync_secs[5m]) against baseline
  • Verify host_export_store_get rate drops
  • Verify delete_modification_clamp_range drops for TokenIdCondition
  • Confirm no constraint violations in graph-node logs (would indicate immutable marking is wrong)

🤖 Generated with Claude Code


Note

Medium Risk
Changes indexing logic and Graph schema semantics (@entity(immutable: true)), which can require reindexing and could surface runtime issues if TokenIdCondition is ever updated or if balance null assumptions are violated.

Overview
Performance-focused indexing updates. TokenIdCondition is now declared @entity(immutable: true) to let graph-node treat it as write-once and avoid extra mutation-related queries.

Transfer processing is optimized by refactoring _setNetPosition to accept the already-loaded current UserBalance from _adjustSenderBalance/_adjustReceiverBalance, only loading the complement balance to cut redundant store.get calls per TransferSingle.

Written by Cursor Bugbot for commit b4da9da. This will update automatically on new commits. Configure here.

Two optimizations to improve indexing performance:

1. Pass already-loaded UserBalance entities from _adjustSenderBalance /
   _adjustReceiverBalance into _setNetPosition instead of reloading them.
   This reduces store.get calls per TransferSingle from 9 to 5 (~44%
   reduction in store_get overhead).

2. Mark TokenIdCondition as @entity(immutable: true) since it is
   write-once (created in handleConditionPreparation, only read after).
   This skips delete_modification_clamp_range queries and enables more
   efficient caching in graph-node.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant