]> git.puffer.fish Git - mirror/frr.git/commit
lib: Memory spike reduction for sh cmds at scale 16672/head
authorSrujana <skanchisamud@nvidia.com>
Tue, 30 Jul 2024 20:39:33 +0000 (20:39 +0000)
committerRajasekar Raja <rajasekarr@nvidia.com>
Tue, 27 Aug 2024 19:47:00 +0000 (12:47 -0700)
commit9112fb367b1ae0168b4e7a81f41c2ca621979199
tree134a10f33a7069ca9025cf2f46726ff3bd227559
parentfa7c77f2939b4be9649ee95a78ed3a307aeac342
lib: Memory spike reduction for sh cmds at scale

The output buffer vty->obuf is a linked list where
each element is of 4KB.
Currently, when a huge sh command  like <show ip route json>
is executed on a large scale, all the vty_outs are
processed and the entire data is accumulated.
After the entire vty execution, vtysh_flush proceeses
and puts this data in the socket (131KB at a time).

Problem here is the memory spike for such heavy duty
show commands.

The fix here is to chunkify the output on VTY shell by
flushing it intermediately for every 128 KB of output
accumulated and free the memory allocated for the buffer data.

This way, we achieve ~25-30% reduction in the memory spike.

Fixes: #16498
Note: This is a continuation of MR #16498

Signed-off-by: Srujana <skanchisamud@nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
lib/vty.c
lib/vty.h
vtysh/vtysh.c
vtysh/vtysh.h