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

map: allow pre-allocating per-CPU values on lookup #1220

Merged
merged 2 commits into from
Nov 17, 2023

Commits on Nov 17, 2023

  1. map: allow pre-allocating per-CPU values

    Until now doing a per-CPU lookup required using a pointer to a slice:
    
        var s []uint64
        m.Lookup(uint32(0), &s)
    
    This causes the library to allocate a slice of the correct size behind
    the scenes. This is very wasteful when doing a lot of per-CPU lookups
    and also doesn't match the semantics we have for non-per-CPU maps.
    
    Allow passing a pre-allocated slice to per-CPU Lookup and BatchLookup:
    
        s := make([]uint64, MustPossibleCPU())
        m.Lookup(uint32(0), s)
    
    Signed-off-by: Alun Evans <alun@badgerous.net>
    alxn authored and lmb committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    2816d2f View commit details
    Browse the repository at this point in the history
  2. map: move per-CPU validation into unmarshalPerCPUValue

    Move validation required for reflect based decoding into
    unmarshalPerCPU value. This ensures that the checks are
    as close as possible to where they are required.
    
    Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
    lmb committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    eea7482 View commit details
    Browse the repository at this point in the history