Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce SystemKeyspace truncation record contention #559

Draft
wants to merge 1 commit into
base: palantir-cassandra-2.2.18
Choose a base branch
from

Conversation

schlosna
Copy link
Contributor

JFR profiles show significant synchronization contention on SystemKeyspace#getTruncationRecord(UUID) as part of committing PaxosState.

The SystemKeyspace truncationRecords map is a lazily initialized unmodifiable snapshot of the local node's truncated_at map. We now guard this with a read/write lock to optimistically allow concurrent reads, while falling back to most costly write lock and re-reading the local node's truncated_at from system tables when there are truncation modifications.

Contention back trace:

  org.apache.cassandra.db.SystemKeyspace.getTruncationRecord(UUID):494
  org.apache.cassandra.db.SystemKeyspace.getTruncatedAt(UUID):488
  org.apache.cassandra.service.paxos.PaxosState.commit(Commit):144
  org.apache.cassandra.service.paxos.CommitVerbHandler.doVerb(MessageIn, int):34
  org.apache.cassandra.net.MessageDeliveryTask.run():70
  java.util.concurrent.Executors$RunnableAdapter.call():539
  org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run():164
  org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$LocalSessionFutureTask.run():136
  org.apache.cassandra.concurrent.SEPWorker.run():110

JFR profiles show significant synchronization contention on
SystemKeyspace#getTruncationRecord(UUID) as part of committing
PaxosState.

The SystemKeyspace truncationRecords map is a lazily initialized
unmodifiable snapshot of the local node's truncated_at map.  We now
guard this with a read/write lock to optimistically allow concurrent
reads, while falling back to most costly write lock and re-reading the
local node's truncated_at from system tables when there are
truncation modifications.

Contention back trace:
  org.apache.cassandra.db.SystemKeyspace.getTruncationRecord(UUID):494
  org.apache.cassandra.db.SystemKeyspace.getTruncatedAt(UUID):488
  org.apache.cassandra.service.paxos.PaxosState.commit(Commit):144
  org.apache.cassandra.service.paxos.CommitVerbHandler.doVerb(MessageIn, int):34
  org.apache.cassandra.net.MessageDeliveryTask.run():70
  java.util.concurrent.Executors$RunnableAdapter.call():539
  org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run():164
  org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$LocalSessionFutureTask.run():136
  org.apache.cassandra.concurrent.SEPWorker.run():110
@schlosna schlosna force-pushed the davids/commit-system-keyspace-contention branch from 21a6eed to fc48c49 Compare October 23, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant