-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: db_main
Are you sure you want to change the base?
receive perf #110
Conversation
pkg/receive/handler.go
Outdated
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) | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this 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 :)
201767f
to
cf49e95
Compare
Nice work. Have you deployed the change to a dev cluster? Any CPU usage decrease? |
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) | ||
} |
There was a problem hiding this comment.
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):") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()
.
Changes
Verification