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

receive perf #110

Open
wants to merge 3 commits into
base: db_main
Choose a base branch
from
Open

receive perf #110

wants to merge 3 commits into from

Conversation

yuchen-db
Copy link

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Verification

Comment on lines 792 to 798
var localWrites, remoteWrites map[endpointReplica]map[string]trackedSeries
var err error
if h.receiverMode == IngestorOnly {
localWrites, remoteWrites, err = h.distributeTimeseriesToReplicas(params.tenant, params.replicas, params.writeRequest.Timeseries)
} else {
localWrites, remoteWrites, err = h.distributeTimeseriesToReplicas(params.tenant, params.replicas, params.writeRequest.Timeseries)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

didn't see difference for the two if-branch?

}

func (h *Handler) distributeTimeseriesToReplicasIngestorOnly(tenantHTTP string, replicas []uint64, timeseries []prompb.TimeSeries) (map[endpointReplica]map[string]trackedSeries, map[endpointReplica]map[string]trackedSeries, error) {
remoteWrites := make(map[endpointReplica]map[string]trackedSeries)
Copy link
Collaborator

Choose a reason for hiding this comment

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

actually should avoid allocation if remote writes are empty, you can consider to reuse a static map for ingestor

Copy link
Collaborator

@jnyi jnyi left a comment

Choose a reason for hiding this comment

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

nice finding, consider to polish it and submit a pr to upstream :)

@yuchen-db yuchen-db force-pushed the yuchen-db/writer-perf branch from 201767f to cf49e95 Compare December 4, 2024 04:39
@hczhu-db
Copy link
Collaborator

hczhu-db commented Dec 4, 2024

Nice work. Have you deployed the change to a dev cluster? Any CPU usage decrease?

Comment on lines +794 to +798
if h.receiverMode == IngestorOnly {
localWrites, remoteWrites, err = h.distributeTimeseriesToReplicasIngestorOnly(params.tenant, params.replicas, params.writeRequest.Timeseries)
} else {
localWrites, remoteWrites, err = h.distributeTimeseriesToReplicas(params.tenant, params.replicas, params.writeRequest.Timeseries)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add code comment to explain the difference?

}
localWrites[endpointReplica] = map[string]trackedSeries{tenantHTTP: {seriesIDs: seriesids, timeSeries: timeseries}}
}
fmt.Println("localWrites (IngestorOnly):")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are those fmt.Print*() only for your debugging? Remove them?

if h.receiverMode == IngestorOnly {
localWrites, remoteWrites, err = h.distributeTimeseriesToReplicasIngestorOnly(params.tenant, params.replicas, params.writeRequest.Timeseries)
} else {
localWrites, remoteWrites, err = h.distributeTimeseriesToReplicas(params.tenant, params.replicas, params.writeRequest.Timeseries)
Copy link
Collaborator

Choose a reason for hiding this comment

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

distributeTimeseriesToReplicas() can be optimized further by removing localWrites related logic. I'd suggest creating a new function, distributeTimeseriesToReplicasRouterOnly().

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.

3 participants