Freeze Break Request: (yet another) mirrorlist: improve tree_lookup to not modify global database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----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@xxxxxxxxxx>
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@xxxxxxxxxx>
- ---
 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJWJliuAAoJEIZXmA2atR5QDroQAI7LFHrb42xZRVtKgm8jh4dU
ZwB/qKMxPY3LnByI1FVw1hgP/CY+y/9pzpoN3nYrLOJAYtAKFVaB31PrF5BJdEFj
1Dn//NTxU8QiIVcm2h95QNLcXeesBagO4cmVgeAFLXvYtRVL+9bQsQF2o/B63Y+q
ToTRpufQnZmQSgvEvM8fgflYt28fiCWNzUHdDSU3Aq/GeTN5JZinluBLVNKDjqYJ
T7fek9Q0mavfkl9BUnw/Ny1p0eA3IAyVudaFDm8FrBKgTTOhdmqQSOUOsgs5qMoK
YDYOCzzPavkO09dOt5i4Sg8EScPClmnF/PA/aA70bPP7ERCEWDW9KDNOr8DM4PD4
swz81Op7kr1jd7wkpAz8ONzuvm01m3C1YVMRokq2GMTX2wXEu8t3ePuNnT1L0YoW
XFNukNGuN2WYd3bC9+5LNxVVICarm0I+K/P1mhNuGybzcI6azyU8X43GkCQUsYj/
FMdRgo98SieRP3hoKwdUgf5e522t9Hr5nhoNYo+zw0SL9x9KhN9hp8ECsYlvjeAB
Y+uu6s1DnZxzrgQO8Ex4w9RnaGPTMJkALrK2ToRpdwe3ivUDAQ5LbHglSh6dOy2Q
u/IG30wK5fE9VavNRgeivBsnecP5QjjTOU4vzF/rVOXdVe6LvrpKg2ftkXA23nmH
B9ggq4pBr/TlFycZzkC9
=ydKL
-----END PGP SIGNATURE-----
_______________________________________________
infrastructure mailing list
infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
http://lists.fedoraproject.org/admin/infrastructure@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux