-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi all,
Since my patch of last night with deep copying the in-memory netblock database was a disaster due to performance issues, I have been working on an improved patch which avoids changing the in-memory database entirely.
The following patch uses a function that was added in py-radix 0.8 to do exactly that, and after deploying an updated py-radix and this patch in staging it's been working just fine.
Could I get +1's to both update py-radix and apply the below patch? I will make sure to first update one and only if that works deploy it further.
Patch:
- From 5bfdeebd42f9d52a1fa2326bcd9b0eb71e4d8e32 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk puiterwijk@redhat.com Date: Tue, 20 Oct 2015 05:58:57 +0200 Subject: [PATCH] Use search_covering in radix to avoid having to modify the tree
Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com - --- mirrorlist/mirrorlist_server.py | 8 ++------ requirements_mirrorlist.txt | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/mirrorlist/mirrorlist_server.py b/mirrorlist/mirrorlist_server.py index a8adcf0..3344e4e 100755 - --- a/mirrorlist/mirrorlist_server.py +++ b/mirrorlist/mirrorlist_server.py @@ -206,8 +206,7 @@ def tree_lookup(tree, ip, field, maxResults=None): len_data = 0 if ip is None: return result - - node = tree.search_best(ip.strNormal()) - - while node is not None: + for node in tree.search_covering(ip.strNormal()): prefix = node.prefix if type(node.data[field]) == list: len_data += len(node.data[field]) @@ -215,10 +214,7 @@ def tree_lookup(tree, ip, field, maxResults=None): len_data += 1 t = (prefix, node.data[field],) result.append(t) - - if maxResults is None or len_data < maxResults: - - tree.delete(prefix) - - node = tree.search_best(ip.strNormal()) - - else: + if maxResults is not None and len_data >= maxResults: break return result
- -- With kind regards, Patrick Uiterwijk Fedora Infra
+1 here.
kevin
On Tue, Oct 20, 2015 at 05:07:26PM +0200, Patrick Uiterwijk wrote:
Hi all,
Since my patch of last night with deep copying the in-memory netblock database was a disaster due to performance issues, I have been working on an improved patch which avoids changing the in-memory database entirely.
The following patch uses a function that was added in py-radix 0.8 to do exactly that, and after deploying an updated py-radix and this patch in staging it's been working just fine.
Could I get +1's to both update py-radix and apply the below patch? I will make sure to first update one and only if that works deploy it further.
Patch:
From 5bfdeebd42f9d52a1fa2326bcd9b0eb71e4d8e32 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk puiterwijk@redhat.com Date: Tue, 20 Oct 2015 05:58:57 +0200 Subject: [PATCH] Use search_covering in radix to avoid having to modify the tree
Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com
mirrorlist/mirrorlist_server.py | 8 ++------ requirements_mirrorlist.txt | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/mirrorlist/mirrorlist_server.py b/mirrorlist/mirrorlist_server.py index a8adcf0..3344e4e 100755 --- a/mirrorlist/mirrorlist_server.py +++ b/mirrorlist/mirrorlist_server.py @@ -206,8 +206,7 @@ def tree_lookup(tree, ip, field, maxResults=None): len_data = 0 if ip is None: return result
- node = tree.search_best(ip.strNormal())
- while node is not None:
- for node in tree.search_covering(ip.strNormal()): prefix = node.prefix if type(node.data[field]) == list: len_data += len(node.data[field])
@@ -215,10 +214,7 @@ def tree_lookup(tree, ip, field, maxResults=None): len_data += 1 t = (prefix, node.data[field],) result.append(t)
if maxResults is None or len_data < maxResults:
tree.delete(prefix)
node = tree.search_best(ip.strNormal())
else:
return resultif maxResults is not None and len_data >= maxResults: break
+1 for me as well
Pierre
infrastructure@lists.fedoraproject.org