Re: [PATCH bpf-next 0/6] bpf: add BPF_MAP_DUMP command to dump more than one entry per call
From: Song Liu
Date: Wed Jul 24 2019 - 15:20:18 EST
On Wed, Jul 24, 2019 at 10:09 AM Brian Vazquez <brianvv@xxxxxxxxxx> wrote:
> This introduces a new command to retrieve multiple number of entries
> from a bpf map.
> This new command can be executed from the existing BPF syscall as
> err = bpf(BPF_MAP_DUMP, union bpf_attr *attr, u32 size)
> using attr->dump.map_fd, attr->dump.prev_key, attr->dump.buf,
> returns zero or negative error, and populates buf and buf_len on
> This implementation is wrapping the existing bpf methods:
> map_get_next_key and map_lookup_elem
> Note that this implementation can be extended later to do dump and
> delete by extending map_lookup_and_delete_elem (currently it only works
> for bpf queue/stack maps) and either use a new flag in map_dump or a new
> command map_dump_and_delete.
> Results show that even with a 1-elem_size buffer, it runs ~40 faster
Why is the new command 40% faster with 1-elem_size buffer?
> than the current implementation, improvements of ~85% are reported when
> the buffer size is increased, although, after the buffer size is around
> 5% of the total number of entries there's no huge difference in
> increasing it.
> Tried different size buffers to handle case where the bulk is bigger, or
> the elements to retrieve are less than the existing ones, all runs read
> a map of 100K entries. Below are the results(in ns) from the different
> buf_len_1: 69038725 entry-by-entry: 112384424 improvement
> buf_len_2: 40897447 entry-by-entry: 111030546 improvement
> buf_len_230: 13652714 entry-by-entry: 111694058 improvement
> buf_len_5000: 13576271 entry-by-entry: 111101169 improvement
> buf_len_73000: 14694343 entry-by-entry: 111740162 improvement
> buf_len_100000: 13745969 entry-by-entry: 114151991 improvement
> buf_len_234567: 14329834 entry-by-entry: 114427589 improvement
It took me a while to figure out the meaning of 87.476941. It is probably
a good idea to say 87.5% instead.