Operations like looking up a map value via EBPF_OPERATION_MAP_FIND_ELEMENT are currently forced to allocate a buffer because of the way that the request structure is defined:
The key is appended to the request buffer. This means that the caller has to allocate memory and perform copying. This is especially bad for batch operations where the amount if memory to be allocated and copied is larger:
Describe the feature you'd like supported
Operations like looking up a map value via EBPF_OPERATION_MAP_FIND_ELEMENT are currently forced to allocate a buffer because of the way that the request structure is defined:
https://github.com/microsoft/ebpf-for-windows/blob/2448139787f618901fa64b614d30a27aabb06cae/libs/execution_context/ebpf_protocol.h#L145-L151
The key is appended to the request buffer. This means that the caller has to allocate memory and perform copying. This is especially bad for batch operations where the amount if memory to be allocated and copied is larger:
https://github.com/microsoft/ebpf-for-windows/blob/2448139787f618901fa64b614d30a27aabb06cae/libs/execution_context/ebpf_protocol.h#L481-L489
It would be nice if common performance critical map operations could be implemented without allocations.
Proposed solution
This could be achieved by making map keys and values pointers, like it is done for
struct bpf_prog_info
:https://github.com/microsoft/ebpf-for-windows/blob/2448139787f618901fa64b614d30a27aabb06cae/include/ebpf_structs.h#L397
Additional context
No response