Kareadita / Kavita

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
http://www.kavitareader.com
GNU General Public License v3.0
5.38k stars 271 forks source link

Avoid multiple concurrent extractions of the same archive v2 #2921

Closed SamuelBMartins closed 1 week ago

SamuelBMartins commented 1 month ago

Fixed

SamuelBMartins commented 1 month ago

This is a continuation of the PR #2840.

This time I used an ConcurrentDictionary<int, SemaphoreSlim> so that every chapter uses a different Semaphore. The dictionary keeps every Semaphore ever used in memory since the semaphore is needed not only for creating the cache but also checking if the cache exists in successive request. I have another branch bugfix/concurrent-extraction2-2 where I try to keep the number of entries in the dictionary low. However, I'm not sure this alternative is better since for each page requested, even if already cached, I need to create a new semaphore.

@majora2007 Can you check if you notice a slowdown with this solution? If there are some automated benchmarks I can run them myself.

majora2007 commented 2 weeks ago

Hey, sorry haven't gotten around to this. Been pretty swamped irl. There is another PR from Robbie with reader changes. Going to combine these and deploy them to my prod instance to give a good shakeout this week.

majora2007 commented 2 weeks ago

Looking good so far, nothing stood out. I yet again manually merged this into another branch that will be merged, then I will close this PR.

majora2007 commented 1 week ago

This was merged here: https://github.com/Kareadita/Kavita/pull/2960