Skip to content

Removing redundant work when doing index updates - #2619

Draft
tkhurana wants to merge 2 commits into
apache:PHOENIX-7562-feature-newfrom
tkhurana:PHOENIX-7562-feature-new
Draft

tkhurana wants to merge 2 commits into
apache:PHOENIX-7562-feature-newfrom
tkhurana:PHOENIX-7562-feature-new

Conversation

@tkhurana

Copy link
Copy Markdown
Contributor

No description provided.

…exed write path

Two allocation/CPU cleanups that fire on every indexed batch:

- MetricsIndexerSourceImpl: memoize the resolved per-(table, base-metric)
  MetricHistogram/MutableFastCounter handles instead of rebuilding the
  "base.table" name string and re-resolving the registry handle on every
  update. The (base, table) set is small and bounded and the handles are
  stable for the life of the source, so steady-state per-batch allocation at
  getCounterName drops to zero. Metric names, values, and JMX output are
  unchanged.

- IndexRegionObserver: doPre/doPost emitted updatePreIndexUpdateTime /
  updatePostIndexUpdateTime unconditionally, even when doIndexWritesWithExceptions
  short-circuited with no index updates to write -- recording a near-zero sample
  every batch on tables with no pre/post index work. doIndexWritesWithExceptions
  now returns whether it actually wrote, and the callers only record the timing
  metric when it did. Failure metrics are unchanged.
…ive index write path

On the active path every generated index-mutation cell carries the batch-wide
timestamp (set by setTimestamps), so re-scanning each mutation's cells with the
O(cells) IndexUtil.getMaxTimestamp on every index-prepare step was wasted work.
Introduce indexMutationTimestamp(context, m): use context.batchTimestamp on the
active path, fall back to getMaxTimestamp only on the standby replay path (which
regenerates index updates per (row, ts) group, where the mutation's own timestamp
is authoritative).

Make context.batchTimestamp the single source of truth for the index-prepare
chain: set it once where it is computed and drop the now-redundant batchTimestamp
parameter threaded through prepareAndCommitGlobalIndexUpdates,
preparePreIndexMutations, and prepareIndexMutations. Also drop the never-used
timestamp parameter from prepareDataRowStates/applyPendingPutMutations.

Standby path is unchanged (byte-for-byte). Validated by GlobalIndexCheckerIT,
GlobalIndexCheckerEventualGenerateIT, UncoveredGlobalMutableNonTxIndexIT, and
ReplicationLogGroupIT.
@tkhurana
tkhurana marked this pull request as draft September 16, 2026 05:08
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