Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inefficient caching of FdsnNetExtender.extend() #8

Closed
andres-h opened this issue Oct 6, 2022 · 7 comments
Closed

Inefficient caching of FdsnNetExtender.extend() #8

andres-h opened this issue Oct 6, 2022 · 7 comments

Comments

@andres-h
Copy link

andres-h commented Oct 6, 2022

FdsnNetExtender.extend(self, net, date_string) has lru_cache(maxsize=1000), but since date_string is different most of the time, caching seems to be inefficient. In any case, I can observe urls like http://www.fdsn.org/ws/networks/1/query?fdsn_code=3E being downloaded hundreds of times. Sometimes this causes an exception, which seems to be the reason of incomplete statistics at GFZ.

Maybe date_string should be reduced to year (two different temporary networks with the same code never exist in same year?). Alternatively I would suggest caching the result of urlopen(request).

@jschaeff
Copy link
Collaborator

jschaeff commented Oct 6, 2022

Nice spotting. I'll fix fdsnnetextender.

@jschaeff
Copy link
Collaborator

jschaeff commented Oct 6, 2022

fdsnnetextender 3.3.0 implements caching of the FDSN request only.

Tests are OK.

Could you upgrade only this package ? If it's working alright, then we advertise the new version to everyone, it's an important fix.

jschaeff added a commit that referenced this issue Oct 6, 2022
@andres-h
Copy link
Author

andres-h commented Oct 7, 2022

Seems to work OK now.

@jschaeff
Copy link
Collaborator

jschaeff commented Oct 7, 2022

Let it run during the week end. On monday, if everything is fine, I'll make an announce for everyone to update.

Thank you for your help !

@jschaeff
Copy link
Collaborator

@andres-h can you confirm that this fix is improving the situation ?

@jschaeff jschaeff mentioned this issue Oct 11, 2022
11 tasks
@andres-h
Copy link
Author

@andres-h can you confirm that this fix is improving the situation ?

Absolutely. Now after 5 days it is:

$ grep ^REQUESTING send_stats.log | sort | uniq -c | sort -n -r | head
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=ZW
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=ZS
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=ZE
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=Z3
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=YZ
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=XN
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=9J
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=9H
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=9C
5 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=8H

while previously:

$ grep ^REQUESTING send_stats.log.old | sort | uniq -c | sort -n -r | head
931 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=Z3
687 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=3E
644 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=5C
613 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=YU
397 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=YZ
264 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=XO
258 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=Y4
229 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=ZA
229 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=XE
151 REQUESTING http://www.fdsn.org/ws/networks/1/query?fdsn_code=Y9

@jschaeff
Copy link
Collaborator

Thank you for your help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants