-
Notifications
You must be signed in to change notification settings - Fork 8
Speedups
Because BGPy was written in Python, and mainly built for development instead of speed, it can be slow for certain simulations. However, there are a few things that can be done to speed this up.
First and foremost, make sure that you are running with pypy3 -O (to turn the asserts off).
Whenever possible, run with the BGP subclasses, NOT BGPFull (much slower). Generally, if a class has the word Full in it, it's much slower.
Make sure you are running with parse_cpus=cpu_count() (you can import this from multiprocessing).
The final thing that can be modified is the Announcement class itself. Currently the Announcement class supports a plethora of policies. Copying this announcement class around the ASGraph is costly and a bottleneck for BGPy. We can actually make a much smaller version of the announcement if we don't need specific attributes for specific policies.
You can see an example of this here. Just by using a smaller announcement class, we have a 1.5x faster simulation runtime.
We've also implemented BGPy in C++ with Python bindings as well, but since it only resulted in a 2-3x speed gain (it was a bit lossy going from python to C++ and back), we opted to leave it out since it drastically increased the complexity of the simulator.