Skip to content

Commit

Permalink
bgpd: generate json by default for [l]communities and aspaths
Browse files Browse the repository at this point in the history
The show bgp ipv4 detail json command takes a lot of memory, and
on Linux, when reading a full route, the resulting VM size of the
bgp daemon has increased from 10.2 GB to 19.2 GB (the measure
has been done with the pathch of the below link.

The hypothesis is that the memory management is culprit: on Linux,
pages are allocated to host memory blocks. When those memory
blocks are no more used, any empty page should be made available.

If the page is not freed, this probably means that some memory
blocks have not been freed. The troubleshooting shows that some
data of bgp entries store the json format when the usage is
requested. That would imply that for a given page, some memory
blocks will remain after the show, and others not.

In order to separate both usages on a shared page, do choose to
allocate the json output of bgp aspath, bgp communities, and
bgp large communities at startup.

The number of additional allocations done at startup is measured:
- 130472 aspaths
- 18471 communities
- 1308 large communities

The memory measurement is given for information and does not show
any significative improvement since only the initial VM size has
changed frmo 10.2 to 14.5 GB.

> root@dut-sureau-nianticvf:~# ps -aux | grep bgpd
> root        7702 83.3 14.5 1663832 1485640 ?     Ssl  08:14   1:56 /usr/bin/bgpd -A 127.0.0.1 -M snmp -M rpki -M bmp
> root@dut-sureau-nianticvf:~# time vtysh -c "show bgp ipv4 json detail" > /tmp/showbgpipv4detailjson.txt
>
> real    0m30.286s
> user    0m2.796s
> sys     0m5.565s
> root@dut-sureau-nianticvf:~# ps -aux | grep bgpd
> root        7702 75.7 19.2 2137220 1959064 ?     Ssl  08:14   2:23 /usr/bin/bgpd -A 127.0.0.1 -M snmp -M rpki -M bmp

Link: FRRouting#16498

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Aug 26, 2024
1 parent 687adb3 commit 22afecb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5098,13 +5098,13 @@ void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt)
void bgp_attr_init(void)
{
aspath_init();
aspath_set_format_json(false);
aspath_set_format_json(true);
attrhash_init();
community_init();
community_set_format_json(false);
community_set_format_json(true);
ecommunity_init();
lcommunity_init();
lcommunity_set_format_json(false);
lcommunity_set_format_json(true);
cluster_init();
transit_init();
encap_init();
Expand Down

0 comments on commit 22afecb

Please sign in to comment.