Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save blackwithwhite666/971bf9a9f8ff1905be5c4cc15decb5b2 to your computer and use it in GitHub Desktop.

Select an option

Save blackwithwhite666/971bf9a9f8ff1905be5c4cc15decb5b2 to your computer and use it in GitHub Desktop.
Let's test memory consumption on server with ~10k NDP entries.
$ time ip neigh | wc -l
11830
Code simply invoke `IPRoute.get_neighbours` method. Memory consumption was recorded with valgrind and massif.
```
from pyroute2 import IPRoute
IPRoute().get_neighbours(socket.AF_INET6)
```
Without patch (1 iteration):
MB
71.16^ :::
| @:#: :
| :::@:#: :
| @@@@:::::@:#: :
| @@::@ : :::@:#: :
| @@@@@: @ : :::@:#: :
| @@@ @@@: @ : :::@:#: :
| ::::@@@@@ @@@: @ : :::@:#: :
| @::: :@@@@@ @@@: @ : :::@:#: :
| @@@@: : :@@@@@ @@@: @ : :::@:#: :
| @@@@@ @: : :@@@@@ @@@: @ : :::@:#: :
| @@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| @@@:@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| @@::@@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| :@ : @@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| :@@@@:@ : @@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| @@@:@ @ :@ : @@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| @@@@ @:@ @ :@ : @@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| @@@@@@ @:@ @ :@ : @@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
| @:@@@ @@@@ @:@ @ :@ : @@ :@@@@@ @@ @: : :@@@@@ @@@: @ : :::@:#: :
0 +----------------------------------------------------------------------->Gi
0 4.224
Without patch (10 iteration, gc disabled):
MB
701.4^ :
| @@@###:
| @@@@@@@# :
| @@@@@@@@@@# :
| :@@@@@@@@@@@@@# :
| @@@@@@@@@@@@@@@@@# :
| ::@@@@@@@@@@@@@@@@@@# :
| ::::: @@@@@@@@@@@@@@@@@@# :
| @@::::: @@@@@@@@@@@@@@@@@@# :
| @@@@@::::: @@@@@@@@@@@@@@@@@@# :
| :@@@@@@@@::::: @@@@@@@@@@@@@@@@@@# :
| :::::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| @@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| @@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| :@@@@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| :@:@@@@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| @@@@:@:@@@@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| @::@@@@ :@:@@@@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| :@@@::@@@@ :@:@@@@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
| :@@@:@@@::@@@@ :@:@@@@::@@@:: ::@@ @@@@@::::: @@@@@@@@@@@@@@@@@@# ::
0 +----------------------------------------------------------------------->Gi
0 32.07
With patch (1 iteration):
MB
30.68^ #
| @@@:#
| @@@@@@:#
| @@@@@@@@@@:#
| @@@@@@@@@@@@@@@@:#
| @@@@@ @@@@@@@@@@@@:#
| :@:@@@@@ @@@@@@@@@@@@:#
| @@@::@:@@@@@ @@@@@@@@@@@@:#
| @@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| @@:@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| :@@@@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| :::@@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| @@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| :@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| @::::@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| :::@@::::@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| @:::: @@::::@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| ::@@:::: @@::::@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| :@@:::@@:::: @@::::@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
| :::@@:::@@:::: @@::::@:@@@::: @@ @@ :@@@@@@@ ::@:@@@@@ @@@@@@@@@@@@:#:
0 +----------------------------------------------------------------------->Gi
0 3.579
With patch (10 iteration, gc disabled):
MB
31.17^ :
| # : : : : : : : :
| :# : : : :: : : : :: :
| :# : : : :: : : :: :: :
| :# :: : :: ::: :: :: :: ::: :
| :# :: :: :: ::: :: :: :: ::: @:
| @:# ::: :: :: ::: :: :: :: @::: @:
| @:# ::: ::: :: :::: :::: :: @:: @::: :@:
| @:# ::: ::: :::: :::: : :: :::: @:: @::: :@:
| @@:# ::: ::: : :: :::: : :: : :: :@:: @::: ::@:
| @@:# @@::: ::::: : :: ::::: : :: : :: ::@:: :@::: ::@:
| @@:# @ ::: : ::: :: :: ::::: :: :: :: :: ::@:: ::@::: ::@:
| ::@@:# @ ::: : ::: :: :: :::::: :: :: :: :: ::@:: ::@::: :::@:
| : @@:# :@ ::: : ::: :: :: :::::: ::: :: :: :: ::@:: :::@::: :::@:
| : @@:# :@ ::: @: ::: :: :: ::::::: ::: :: ::: :: :::@:: :::@:::::::@:
| :: @@:# :@ ::: @: ::: :: :: ::::::::::: :: ::: :: :::@:: :::@:::::::@:
| :: @@:#::@ ::: @: ::::::: :: ::::::::::: :::::: ::::::@:: :::@:::::::@:
|::: @@:#::@ ::::@: :::: :: :::::::::::::: :::::: ::::::@::::::@:::::::@:
|::: @@:#::@ ::::@: :::: :: :::::::::::::: :::::: ::::::@::::::@:::::::@:
|::: @@:#::@ ::::@: :::: :: :::::::::::::: :::::: ::::::@::::::@:::::::@:
0 +----------------------------------------------------------------------->Gi
0 29.84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment