forked from FRRouting/frr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zebra: backpressure - Zebra push back on Buffer/Stream creation
Currently, the way zebra works is it creates pthread per client (BGP is of interest in this case) and this thread loops itself in zserv_read() to check for any incoming data. If there is one, then it reads, validates and adds it in the ibuf_fifo signalling the main thread to process the message. The main thread when it gets a change, processes the message, and invokes the function pointer registered in the header command. (Ex: zserv_handlers). Finally, if all of this was successful, this task reschedules itself and loops in zserv_read() again However, if there are already items on ibuf FIFO, that means zebra is slow in processing. And with the current mechanism if Zebra main is busy, the ibuf FIFO keeps growing holding up the memory. Show memory zebra:(Example: 15k streams hoarding ~160 MB of data) --- qmem libfrr --- Stream : 44 variable 3432352 15042 161243800 Fix: Client IO Thread: (zserv_read) - Stop doing the read events when we know there are X number of items on the FIFO already.(X - zebra zapi-packets <1-10000> (Default-1000) - Determine the number of items on the zserv->ibuf_fifo. Subtract this from the work items and only pull the number of items off that would take us to X items on the ibuf_fifo again. - If the number of items in the ibuf_fifo has reached to the maximum * Either initially when zserv_read() is called (or) * when processing the remainders of the incoming buffer the client IO thread is woken by the the zebra main. Main thread: (zserv_process_message) - In one iteration of wake up in zserv_process_message(), a maximum of configured p2p/4 items from ibuf_fifo is only processed. - If ibuf_fifo still has items in it, main thread reschedules itself ensuring that the main thread is always processing some packets - If the client ibuf has maximum items, then the main thread after processing ptp/4 items in the ibuf_fifo signals the client IO thread. This way we ensure that the client IO thread is always reading from socket buffer and adding items in the ibuf_fifo. VTY: - Signal all client IO threads in the zrouter list when ever the hidden command "zebra zapi-packets <>" is configured/unconfigured. Ticket: #3390099 Signed-off-by: Donald Sharp <[email protected]> Signed-off-by: Rajasekar Raja <[email protected]>
- Loading branch information
1 parent
ffab0d7
commit a24eaa4
Showing
3 changed files
with
129 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters