diff options
author | Kui-Feng Lee <kuifeng@fb.com> | 2022-01-19 10:02:14 -0800 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-01-19 10:57:27 -0800 |
commit | d81283d272661094ecc564709f25c7b7543308e0 (patch) | |
tree | 242dacc3fc1f5bf2e931124ebeb0bcd4e02449d4 /tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c | |
parent | 0ba3929e5b3d3fda05d3b9c8d0d20a90a084c19e (diff) |
libbpf: Improve btf__add_btf() with an additional hashmap for strings.
Add a hashmap to map the string offsets from a source btf to the
string offsets from a target btf to reduce overheads.
btf__add_btf() calls btf__add_str() to add strings from a source to a
target btf. It causes many string comparisons, and it is a major
hotspot when adding a big btf. btf__add_str() uses strcmp() to check
if a hash entry is the right one. The extra hashmap here compares
offsets of strings, that are much cheaper. It remembers the results
of btf__add_str() for later uses to reduce the cost.
We are parallelizing BTF encoding for pahole by creating separated btf
instances for worker threads. These per-thread btf instances will be
added to the btf instance of the main thread by calling btf__add_str()
to deduplicate and write out. With this patch and -j4, the running
time of pahole drops to about 6.0s from 6.6s.
The following lines are the summary of 'perf stat' w/o the change.
6.668126396 seconds time elapsed
13.451054000 seconds user
0.715520000 seconds sys
The following lines are the summary w/ the change.
5.986973919 seconds time elapsed
12.939903000 seconds user
0.724152000 seconds sys
V4 fixes a bug of error checking against the pointer returned by
hashmap__new().
[v3] https://lore.kernel.org/bpf/20220118232053.2113139-1-kuifeng@fb.com/
[v2] https://lore.kernel.org/bpf/20220114193713.461349-1-kuifeng@fb.com/
Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220119180214.255634-1-kuifeng@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c')
0 files changed, 0 insertions, 0 deletions