perf: reduce store.get calls and mark TokenIdCondition immutable#5
Open
paymog wants to merge 1 commit intoPolymarket:mainfrom
Open
perf: reduce store.get calls and mark TokenIdCondition immutable#5paymog wants to merge 1 commit intoPolymarket:mainfrom
paymog wants to merge 1 commit intoPolymarket:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UserBalanceentities from_adjustSenderBalance/_adjustReceiverBalanceinto_setNetPositioninstead of reloading them viastore.get. Reduces store.get calls perTransferSinglefrom 9 to 5.TokenIdConditionas@entity(immutable: true)— it is write-once (100% version ratio), enabling graph-node to skipdelete_modification_clamp_rangequeries and cache more efficiently.Expected impact: ~25-45% reduction in
host_export_store_getoverhead during block processing.Test plan
pnpm codegen && pnpm buildpasses (verified locally)rate(graph_node_deployment_sync_secs[5m])against baselinehost_export_store_getrate dropsdelete_modification_clamp_rangedrops for TokenIdCondition🤖 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 ifTokenIdConditionis ever updated or if balance null assumptions are violated.Overview
Performance-focused indexing updates.
TokenIdConditionis 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
_setNetPositionto accept the already-loaded currentUserBalancefrom_adjustSenderBalance/_adjustReceiverBalance, only loading the complement balance to cut redundantstore.getcalls perTransferSingle.Written by Cursor Bugbot for commit b4da9da. This will update automatically on new commits. Configure here.