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

Loki connector frequent realllocations #22

Open
vyzigold opened this issue Sep 23, 2021 · 1 comment
Open

Loki connector frequent realllocations #22

vyzigold opened this issue Sep 23, 2021 · 1 comment

Comments

@vyzigold
Copy link
Contributor

client.currentMessage.Streams = append(client.currentMessage.Streams, stream)

I'm just noting a possible issue. Wouldn't this line cause frequent extensions of the client.currentMessage.Streams, which would cause reallocations and slowdown? My recent performance tests didn't confirm this, but we might want to keep this in mind for the future.

@paramite
Copy link
Member

Allocations happen exponentially, so first its 1 item slice, then 2 item slice then 4 item slice, etc. So there is space allocated in advance. But yes if we would know the final count of items, then it would be better to allocate once instead. But I believe we don't know the count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants