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

ebpf: allow resizing maps #3181

Merged
merged 9 commits into from
Apr 12, 2024
Merged

ebpf: allow resizing maps #3181

merged 9 commits into from
Apr 12, 2024

Conversation

korniltsev
Copy link
Collaborator

address #3148

  • allow resizing maps
  • cleanup the pids map faster
  • increase default pids map size
  • do not use arch specific hook name( cillium handles it)

@korniltsev
Copy link
Collaborator Author

vm image broken down :(

@korniltsev korniltsev marked this pull request as draft April 8, 2024 13:38
@korniltsev korniltsev marked this pull request as ready for review April 8, 2024 14:18
@korniltsev korniltsev requested a review from a team as a code owner April 8, 2024 14:18
Copy link
Contributor

@simonswine simonswine left a comment

Choose a reason for hiding this comment

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

Tested this! Seems to work well.

LGTM

Copy link
Contributor

@simonswine simonswine left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM

Just to make sure my understanding is correct, that this will double the memory footprint of the map, from 8K (2 * 4bytes key/value * 1024) to 16k.

Comment on lines +915 to +920
func (s *session) printDebugInfo() {
_ = level.Debug(s.logger).Log("arch", runtime.GOARCH)
pv, _ := os.ReadFile("/proc/version")
_ = level.Debug(s.logger).Log("/proc/version", pv)
}

Copy link
Contributor

@simonswine simonswine Apr 9, 2024

Choose a reason for hiding this comment

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

I think it would be nice if this could make into the pyroscope.ebpf to have observable debug infos in Grafana Agent:

func (s *session) DebugInfo() interface{} {

@korniltsev
Copy link
Collaborator Author

Just to make sure my understanding is correct, that this will double the memory footprint of the map, from 8K (2 * 4bytes key/value * 1024) to 16k.

I think it is a bit more complicated

At the map creation it will preallocate max_entries (2048) buckets here
And each bucket is probably 16 bytes
So it will preallocate 32k memory for buckets.

Then for each map update it will allocate an element of size sizeof(htab_elem) + round_up(htab->map.key_size, 8) + round_up(htab->map.value_size, 8) which is 48+8+8=64 and if we insert 2048 elements into the map, it will take 64*2048=128k

In total 160k

I am not 100% sure in the math, just looked into the source of hashmap for the first time

@korniltsev korniltsev merged commit 3778701 into main Apr 12, 2024
27 checks passed
@korniltsev korniltsev deleted the ebpf/maps_resize branch April 12, 2024 12:18
@towolf
Copy link

towolf commented Apr 18, 2024

@korniltsev just for my information, will this fix help with this error message from grafana-agent?

ts=2024-04-17T13:09:31.61514799Z level=error msg="updating pids map" component=pyroscope.ebpf.instance err="update: key too big for map: argument list too long"

@korniltsev
Copy link
Collaborator Author

@korniltsev just for my information, will this fix help with this error message from grafana-agent?

ts=2024-04-17T13:09:31.61514799Z level=error msg="updating pids map" component=pyroscope.ebpf.instance err="update: key too big for map: argument list too long"

Yes, it may help, especially if you have a lot of short lived processes.

I think this commit is not included in any public release of the grafana-agent/alloy yet though

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