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

Our use of ps.Map implies many heap allocations #2866

Open
bboreham opened this issue Sep 25, 2017 · 2 comments
Open

Our use of ps.Map implies many heap allocations #2866

bboreham opened this issue Sep 25, 2017 · 2 comments
Labels
chore Related to fix/refinement/improvement of end user or new/existing developer functionality performance Excessive resource usage and latency; usually a bug or chore

Comments

@bboreham
Copy link
Collaborator

Take StringLatestMap which is like map[string]*struct{time.Time,string}

Each node in the map is an allocation of a ps.tree struct (size 112 bytes).
Each key and value string is an allocation, and the value struct is an allocation because it's boxed to be held as an interface{} by the ps.tree struct

So a map with n entries requires 4n memory allocations.

Relates to #1010

I have started a reimplementation of StringLatestMap based on a slice, which is a similar idea to #1758.

@bboreham
Copy link
Collaborator Author

Another thought strikes me: each ps.tree.struct node has 8 pointers to other nodes and none of them is ever nil; they are initialised to point to nilMap. So garbage-collection of a ps.Map likely involves a lot of chasing down those pointers.

@rade rade added chore Related to fix/refinement/improvement of end user or new/existing developer functionality performance Excessive resource usage and latency; usually a bug or chore labels Oct 11, 2017
@bboreham
Copy link
Collaborator Author

By now, most ps.Maps were replaced by slices. The remaining ones:

  • counters - not set in probe; only used by parent nodes in app
  • sets - done in WIP Re-implement Sets as sorted slice, for performance #2962; needs a bit more work to finish
  • node_set - replace by slice was more expensive, perhaps because node is large and we get large node_sets in specific cases such as Endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Related to fix/refinement/improvement of end user or new/existing developer functionality performance Excessive resource usage and latency; usually a bug or chore
Projects
None yet
Development

No branches or pull requests

2 participants