-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Improve loading pages (library, titles) #222
Improve loading pages (library, titles) #222
Conversation
* Cache sum of entry progress * Cache cover_url * Cache display_name * Cache sort_opt
sorted_entries cached
Thanks for the PR! I was trying to review this but got confused about two points. I am probably missing something so it would be great if you could explain it a bit more.
|
instance_sizeof(SortedEntriesCacheEntry): sizeof( Since It's not perfectly accurate (I forgot to add After scanning, entries and titles could be added or removed. We should invalidate I think my naming sense is not good 😢 |
Ah now it makes more sense. Thanks for the clarification!
I think the I will test the current implementation and try to improve the naming a bit. I can then start exploring the idea above. |
I just notice there is the I think the data cached by I agree that generalized cache entry would be good. Let me try to do. It takes a time learning the Crystal 😄 I'll ask you a help when having problems. |
Haha I didn't know about The only problem I have with the current implementation is that we have two cache systems Yes I agree that we can cache the metadata into the generalized LRU cache at
Sure looking forward to it! As always, thank you for the effort you put into this :D |
I Fixed my implementation Implementation
|
Thanks! The code looks great overall, and I just have one question - why do we need to cache the sort options and cover URLs separately when we already have the
Perhaps we can somehow achieve this with the Crystal |
I agree that caching sort options and cover URLs separately to LRU cache is verbose. So I removed them and tested it, It took about 2ms to restore cached I'm going to cache the |
db5bc33
to
9807db6
Compare
Again thanks a lot for the PR! I took the liberty and made some small changes. |
Great changes! Thanks for merging |
Implementations
To improve page loading, I cached lots of data. The principles are:
info.json
filesMisc.
cache entry_cover_url
Like
entry_display_name
, cachedentry_cover_url
would improve renderingsrc/views/components/card.html.ecr
. This is very effective.cache
display_name
of titleThis would avoid to access
info.json
change where sort opt are saved
It's okay that sort options are saved when accessing library, book with parameters. I removed unnecessary actions. This would avoid to access
info.json
Caching Library
This utility implemented at
cache.cr
helps cached data to be preserved after scanning.This caches:
cover_url
of each entrydeep_read_page_count
of each titleinfo.json
filesI think the second one is quite effective.
Sorted Entries Cache
There are lots of calls
sorted_entries
, which takes long (222 entries took 80ms on my machine). Besides it called three times with the same arguments when accessing title page. Caching them is effective since they are not changed until modifying entries. Currently, this option is not enabled as default. You should set the flag true for enabling. And the cache size option doesn't guarantee the machine to consume memory precisely.Effectiveness
Test environment
I loaded a title page that has 222 entries (no nested title, about 11GB) on SATA3 SSD. I'm sorry that I have tested them only once
As is
first access: took 1140ms
second access: 1119ms (not changed)
took long, almost same time
With only caching entries' cover url
first access: 700ms (x1.6 faster)
second access: 735ms
With full implementation except sorted entries cache
first access: took 233ms (x4.9 faster)
second access: took 238ms
With full implementation
first access: took 115ms (x10 faster)
second access: took 50ms (even faster)
This resolve #186 partly.