Skip to content

changefeedccl: Make kvevent.Event memory efficient#87718

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
miretskiy:kvevent
Sep 9, 2022
Merged

changefeedccl: Make kvevent.Event memory efficient#87718
craig[bot] merged 1 commit intocockroachdb:masterfrom
miretskiy:kvevent

Conversation

@miretskiy
Copy link
Copy Markdown
Contributor

Fixes #84709

kvevent.Event structure is very inefficient in its use of pointers. The number of pointers in the structure makes go GC processes more expensive, resulting in loss of performance in the cluster.

This is particularly clear during the initial scan, when changefeeds rapidly allocate large number of events, which are then (rapidly) releases -- putting pressure on the go runtime GC.

This PR replaces the use of multiple pointers with a single *roachpb.RangeFeedEvent. The direct use of *roachpb.RangeFeedEvent is beneficial since this is the (already allocated) event we receive from rangefeed RPC once changefeed completes the initial scan.

Release justification: significant reduction of the changefeed impact on the foreground SQL latency.

Release note (enterprise change): Changefeeds are more efficient during initial scan and backfill. The impact on runtime GC signficantly reduced, resulting in significant reduction of the changefeed impact on the foreground SQL latency.

@miretskiy miretskiy requested a review from a team as a code owner September 9, 2022 16:39
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@miretskiy
Copy link
Copy Markdown
Contributor Author

miretskiy commented Sep 9, 2022

This change has been validated on a 15 node cluster, running TPC-E workload.

Prior to this change, starting the changefeed resulted
in the sustained drop of query throughput from ~22K down to 6k; while the 99th %-le latency
jumped from 50-70s to 400ms+ (spiking above 1sec at times). The logs also indicate significant
time spent in GC assist.

master-sql

master-sql-zoom

master-gc-runs

With this change, SQL throughput briefly drops from 22k to 12k, but then recovers to 21K; while the latency,
after the initial spike, remains consistent. The GC runs briefly go down (with corresponding increase in GC assit time), but
recovers later.

rewrite-sql

rewrite-gc-runs

@miretskiy
Copy link
Copy Markdown
Contributor Author

@nvanbenschoten : FYI

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM this is definitely better

@miretskiy miretskiy force-pushed the kvevent branch 2 times, most recently from c3bf6a3 to c2403b9 Compare September 9, 2022 19:43
Fixes cockroachdb#84709

`kvevent.Event` structure is very inefficient in its
use of pointers.  The number of pointers in the structure
makes go GC processes more expensive, resulting in loss
of performance in the cluster.

This is particularly clear during the initial scan, when
changefeeds rapidly allocate large number of events, which
are then (rapidly) releases -- putting pressure on the
go runtime GC.

This PR replaces the use of multiple pointers with a single
`*roachpb.RangeFeedEvent`.  The direct use of `*roachpb.RangeFeedEvent`
is beneficial since this is the (already allocated) event we receive
from rangefeed RPC once changefeed completes the initial scan.

Release justification: significant reduction of the changefeed
impact on the foreground SQL latency.

Release note (enterprise change): Changefeeds are more efficient
during initial scan and backfill.  The impact on runtime GC
signficantly reduced, resulting in significant reduction of the
changefeed impact on the foreground SQL latency.
@miretskiy
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 9, 2022

Build failed:

@miretskiy
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 9, 2022

Build succeeded:

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.

changefeedccl: reduce size or # of pointers of event struct

4 participants