Slow parsing when reading in a large config with multiple neighbors
ISSUE TYPE
- Bug Report
OS
RHEL 6.7
VERSION
ExaBGP : 4.0.2-1c737d99
Python : 3.5.2 (default, Sep 16 2016, 16:05:49) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
Uname : Linux exabgp.example.com 2.6.32-573.18.1.el6.x86_64 #1 SMP Wed Jan 6 11:20:49 EST 2016 x86_64
Root : /root/.local
I have also tested the master branch (060cf873dcf876247008c4693fc5095a7213c322) with the same result. I have not tested ExaBGP 3 (incompatible syntax).
ENVIRONMENT
The "exabgp --di" output is empty.
CONFIGURATION
https://gist.github.com/yesbox/12577c779858243594859a73ebcc6348
SUMMARY
Parsing a configuration with 6523 routes (mixed IPv4 and IPv6) spread over 16 neighbors (not equally) takes a very long time.
The parsing slows down exponentially for each neighbor config that is being processed. While the configuration is being parsed ExaBGP is running 1 thread at 100% CPU.
Below are some snippets from the debug log to demonstrate the performance characteristics.
16:59:59 | 1315 | configuration | performing reload of exabgp 4.0.2-1c737d99
17:00:01 | 1315 | configuration | . description | 'vpn1'
17:00:01 | 1315 | configuration | . description | 'vpn2'
17:00:01 | 1315 | configuration | . description | 'vpn3'
17:00:01 | 1315 | configuration | . description | 'vpn4'
17:00:01 | 1315 | configuration | . description | 'vpn5'
17:00:01 | 1315 | configuration | . description | 'vpn6'
17:00:02 | 1315 | configuration | . description | 'vpn7'
17:00:02 | 1315 | configuration | . description | 'vpn8'
17:00:03 | 1315 | configuration | . description | 'vpn9'
17:00:05 | 1315 | configuration | . description | 'vpn10'
17:00:11 | 1315 | configuration | . description | 'vpn11'
17:00:26 | 1315 | configuration | . description | 'vpn12'
17:01:13 | 1315 | configuration | . description | 'vpn13'
17:03:57 | 1315 | configuration | . description | 'vpn14'
17:14:00 | 1315 | configuration | . description | 'vpn16'
17:52:22 | 1315 | configuration | . description | 'vpn17'
20:22:25 | 1315 | configuration | < neighbor |
20:22:25 | 1315 | reactor | loaded new configuration successfully
Full debug log excluding the lines between the start and stop (due to being several hundreds of megabyte of lines about timing, which is working without issue once the config is parsed). https://gist.github.com/yesbox/c3b79a3a7d9f802ad247c9f8383eaa65
Is this a known limitation? Am I doing something in an inefficient way that would be faster with an adjusted config?
STEPS TO REPRODUCE
Run exabgp with no arguments other than the config file.
EXPECTED RESULTS
Open connections to neighbors in seconds after starting ExaBGP.
ACTUAL RESULTS
Time before connections to neighbors are attempted takes hours.
IMPORTANCE
It complicates things, would greatly prefer to use a single process/instance for all neighbors. I have not yet tried to split up the config and use multiple daemons, I assume that would be the workaround and only alternative I see now.
For the time being I would advocate running multiple copies. ExaBGP is single threaded (this is a limitation of Python) and the code will need some intrusive re-engineering to make it use multiple cores. I need to find some time to look at performance and it is a 5 minutes thing.
Breaking up the configuration in smaller files and running one process per peer did indeed mitigate this issue. Thanks!
There may be an O(n) behaviour somewhere in the configuration code - it is not the fastest parsing code in the world (far from it). As it seems all is ok for you, I will close this issue.
Although we did find a workaround for my particular use-case at this time, the issue of reading in a large config or a large amount of routes via the config is unusable slow after a certain number of entries is still present.
I would be happy to see scaling limitations like these documented in the project wiki, as the issue is closed.