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

Improve performance by avoiding string concatenation in a loop using StringBuilder #458

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

tyqi11
Copy link

@tyqi11 tyqi11 commented Mar 3, 2020

String concatenation in a loop is inefficient in time and space complexity. Using a StringBuilder solves the problem.

@smiklosovic smiklosovic added the missing-ticket missing ticket in Cassandra JIRA label Mar 16, 2022
@smiklosovic
Copy link
Contributor

@tyqi11 please create a jira ticket in Apache Cassandra JIRA if you want to see this happen.

blambov pushed a commit to blambov/cassandra that referenced this pull request Sep 30, 2022
* abstract mutations used by CDC
At first, I tried to refactor StorageProxy methods and
WritePerformer interface, but since every now and then we want to
rebase on OS C*, I reverted all the changes.
Instead, a new abstraction level over various mutate methods is
introduced - Mutator. The default implementation proxies the calls to
the original (default) methods.
The users may provide a custom class Mutator implementation to alter
the mutation behavior.

This solution was chosen to minimize the rebase conflicts, it's a
compromise between code structuring and maintenance cost.
In the ideal world we could refactor the mutation methods to
separate classes.

* add ComplexColumnData.hasCells

* make currentTimeoutNanos overridable
CDCWriteResponseHandler doesn't use the default timeout
taken from DatabaseDescriptor

* port 'CNDB-3334 CDC counter support'
Add applyCounterMutationWithoutLocks method.

The method applies the counter without locks (not needed in CDC as
all the writes to the same partition are serialized by CDC Service).
The mutation is applied with the given id and clockMicros. The values
are precomputed and distributed by CDC Service. Writers receive the
mutation with the attached values, thanks to this all the writers may
apply the mutation as if they were leader replicas.
See the ticket description for details on leader and follower replica
concepts used by pure Cassandra counter write path.

* make RepairedDataInfo public

RepairedDataInfo.NO_OP_REPAIRED_DATA_INFO is used by CDC 
to denote no repair data info.
blambov pushed a commit to blambov/cassandra that referenced this pull request Nov 24, 2022
* abstract mutations used by CDC
At first, I tried to refactor StorageProxy methods and
WritePerformer interface, but since every now and then we want to
rebase on OS C*, I reverted all the changes.
Instead, a new abstraction level over various mutate methods is
introduced - Mutator. The default implementation proxies the calls to
the original (default) methods.
The users may provide a custom class Mutator implementation to alter
the mutation behavior.

This solution was chosen to minimize the rebase conflicts, it's a
compromise between code structuring and maintenance cost.
In the ideal world we could refactor the mutation methods to
separate classes.

* add ComplexColumnData.hasCells

* make currentTimeoutNanos overridable
CDCWriteResponseHandler doesn't use the default timeout
taken from DatabaseDescriptor

* port 'CNDB-3334 CDC counter support'
Add applyCounterMutationWithoutLocks method.

The method applies the counter without locks (not needed in CDC as
all the writes to the same partition are serialized by CDC Service).
The mutation is applied with the given id and clockMicros. The values
are precomputed and distributed by CDC Service. Writers receive the
mutation with the attached values, thanks to this all the writers may
apply the mutation as if they were leader replicas.
See the ticket description for details on leader and follower replica
concepts used by pure Cassandra counter write path.

* make RepairedDataInfo public

RepairedDataInfo.NO_OP_REPAIRED_DATA_INFO is used by CDC
to denote no repair data info.

(cherry picked from commit 5191be2)
adelapena pushed a commit to adelapena/cassandra that referenced this pull request Sep 26, 2023
* abstract mutations used by CDC
At first, I tried to refactor StorageProxy methods and
WritePerformer interface, but since every now and then we want to
rebase on OS C*, I reverted all the changes.
Instead, a new abstraction level over various mutate methods is
introduced - Mutator. The default implementation proxies the calls to
the original (default) methods.
The users may provide a custom class Mutator implementation to alter
the mutation behavior.

This solution was chosen to minimize the rebase conflicts, it's a
compromise between code structuring and maintenance cost.
In the ideal world we could refactor the mutation methods to
separate classes.

* add ComplexColumnData.hasCells

* make currentTimeoutNanos overridable
CDCWriteResponseHandler doesn't use the default timeout
taken from DatabaseDescriptor

* port 'CNDB-3334 CDC counter support'
Add applyCounterMutationWithoutLocks method.

The method applies the counter without locks (not needed in CDC as
all the writes to the same partition are serialized by CDC Service).
The mutation is applied with the given id and clockMicros. The values
are precomputed and distributed by CDC Service. Writers receive the
mutation with the attached values, thanks to this all the writers may
apply the mutation as if they were leader replicas.
See the ticket description for details on leader and follower replica
concepts used by pure Cassandra counter write path.

* make RepairedDataInfo public

RepairedDataInfo.NO_OP_REPAIRED_DATA_INFO is used by CDC
to denote no repair data info.

(cherry picked from commit 5191be2)
(cherry picked from commit 75b8d12)
(cherry picked from commit ba2a0a6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing-ticket missing ticket in Cassandra JIRA
Projects
None yet
2 participants