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

Switch to turn on/off cache functionality #368

Open
bigretromike opened this issue Aug 12, 2016 · 34 comments
Open

Switch to turn on/off cache functionality #368

bigretromike opened this issue Aug 12, 2016 · 34 comments

Comments

@bigretromike
Copy link
Contributor

Adding ability to switch cache on and off - as it being request few times on chat by few peoples (including me)

Maybe implement inside cache as everything ask cache for data and if proper setting is "true" then it returns cache if not then ask database as before cache all request went there directly.

@misakitchi
Copy link

Thanks! ^_^

@bigretromike
Copy link
Contributor Author

Or if its extremely hard to make "off-switch" in current form and maintain both paths we could make something that represents this idea:
cache is always on, cache size is configurable, if you query cache and it lack of data it will query database save it and respond. If cache reach size limit it will delete non used data (or any other criteria like no-access or the lowest access count)

This way we would join both worlds. People with a lot of RAM would use big size cache, and the one that don't want to use it would use the low amount. Also I would hardcoded minimum amount as people could abuse it and set it to small as 1mb so that would double the time anyway so bear minimum would be 100mb which should be ok, as the most case the daily driver would be from my point of view this: people watching series - series with episodes is caches so they watch and read info about it from cache - and this case would give boost for people with less RAM and wouldn't bother those with big RAM.

What do you think guys @maxpiva @ElementalCrisis is it possible?

@da3dsoul
Copy link
Member

How much RAM does your MySQL take in 3.5? The cache just moved the RAM usage to server, and the final step is move everything to SQLite and not use any extra RAM for db. As for this idea, it might be possible, but it'll be slow. The argument for me is not whether we can fit an elephant in the front door, it's why would we try. A raspberry pi is not designed to be a server. It is a gpio toy for hobbyists to build fun things with. An itx box with 8GB of RAM is like $75-$100. Okay it's not $30, but a server is not $30.

@bigretromike
Copy link
Contributor Author

bigretromike commented Sep 19, 2016

My MySQL use 430mb and JMM using that MySQL user 410mb, but also Kodi user same Mysql, few webpages and other smaller programs.. so yeah...
Also I wont uninstall mysql just because Jmm wont need it. same go for linux servers - mysql is most time there anyway
Also there setups that are unable to free-up ram or you are unable to upgrade ram there.

Note that the RAM = collection size... So it will always increase and with "size limitation" you should be on safe side.

@maxpiva
Copy link
Member

maxpiva commented Sep 19, 2016

After the repository refactor is possible, but i wont code it. As you can see the new Repositories are separated in two folders. (direct and cached) all repositories now are based on the same interface (IRepository, and use base helper classes).

How to do it....
For Every Cached Repository a Direct One should be made, you can get the original repositories queries to the database from JMMServer older version.

Create extra interfaces for the Cached Repositories, so the extra Methods used in Cached ~ the ones you created in Direct.

After that, You should code in RepoFactory the initialization part, depending of the use of cache or not, init the cached repositories or the direct ones...

DONE

@bigretromike
Copy link
Contributor Author

Wouldnt it be easier to do it in cache implementation?as you ask cache about data and cache knows which data is missing. And if the item is missing the query db

On September 19, 2016 4:51:40 PM GMT+02:00, Maximo Piva notifications@github.com wrote:

After the refactor is possible, but i wont code it. As you can see the
new Repositories are separated in two folders. (direct and cached) all
repositories now are based on the same interface (IRepository, and use
base helper classes).

How to do it....
For Every Cached Repository a Direct One should be made, you can get
the original repositories queries to the database from JMMServer older
version.

After that, You should code in RepoFactory the initialization part,
depending of the use of cache or not, init the cached repositories or
the direct ones...

DONE

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#368 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@maxpiva
Copy link
Member

maxpiva commented Sep 19, 2016

Cache implementation read all data at init, and queries are in
memory(Dictionary based or Linq based). There are no queries to the
database.

Direct implementation has database queries. So no. You have to re-implement
the database queries anyway. Architectural wise. is better have it split in
this way. that put an if on every method.

On Mon, Sep 19, 2016 at 1:01 PM, BigRetroMike notifications@github.com
wrote:

Wouldnt it be easier to do it in cache implementation?as you ask cache
about data and cache knows which data is missing. And if the item is
missing the query db

On September 19, 2016 4:51:40 PM GMT+02:00, Maximo Piva <
notifications@github.com> wrote:

After the refactor is possible, but i wont code it. As you can see the
new Repositories are separated in two folders. (direct and cached) all
repositories now are based on the same interface (IRepository, and use
base helper classes).

How to do it....
For Every Cached Repository a Direct One should be made, you can get
the original repositories queries to the database from JMMServer older
version.

After that, You should code in RepoFactory the initialization part,
depending of the use of cache or not, init the cached repositories or
the direct ones...

DONE

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#368
issuecomment-248015867

Sent from my Android device with K-9 Mail. Please excuse my brevity.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#368 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABHDbSGOu67U-QfhDSvI5ynMmgbUgRo4ks5qrrHrgaJpZM4JjYwx
.

@bigretromike
Copy link
Contributor Author

As the cache author yoy are probably right. Thats something for later as it will be more clear when user base will increase and user case will expanse. Thsnks for info

On September 19, 2016 6:53:45 PM GMT+02:00, Maximo Piva notifications@github.com wrote:

Cache implementation read all data at init, and queries are in
memory(Dictionary based or Linq based). There are no queries to the
database.

Direct implementation has database queries. So no. You have to
re-implement
the database queries anyway. Architectural wise. is better have it
split in
this way. that put an if on every method.

On Mon, Sep 19, 2016 at 1:01 PM, BigRetroMike
notifications@github.com
wrote:

Wouldnt it be easier to do it in cache implementation?as you ask
cache
about data and cache knows which data is missing. And if the item is
missing the query db

On September 19, 2016 4:51:40 PM GMT+02:00, Maximo Piva <
notifications@github.com> wrote:

After the refactor is possible, but i wont code it. As you can see
the
new Repositories are separated in two folders. (direct and cached)
all
repositories now are based on the same interface (IRepository, and
use
base helper classes).

How to do it....
For Every Cached Repository a Direct One should be made, you can get
the original repositories queries to the database from JMMServer
older
version.

After that, You should code in RepoFactory the initialization part,
depending of the use of cache or not, init the cached repositories
or
the direct ones...

DONE

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#368
issuecomment-248015867

Sent from my Android device with K-9 Mail. Please excuse my brevity.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub

#368 (comment),
or mute the thread

https://github.com/notifications/unsubscribe-auth/ABHDbSGOu67U-QfhDSvI5ynMmgbUgRo4ks5qrrHrgaJpZM4JjYwx
.

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#368 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@bigretromike
Copy link
Contributor Author

@Cazzar this

@craige1
Copy link
Contributor

craige1 commented Sep 11, 2017

I would also like the ability to turn of the stupid cache so it doesn't take 2 GOOD DAM FUCKING HOURS TO START THE SERVER!@!!!! this has me royally pissed

@Cazzar
Copy link
Member

Cazzar commented Sep 11, 2017

@craige1 if it is taking 2 hours for the server to load everything via cache, there might be other problems because ultimately disabling cache will slow the software down a very large amount.
What kind of size collection do you have?

@da3dsoul
Copy link
Member

Dude chill. Siding with @Cazzar here, it takes me 45s to start the server with 900 series. It's not the cache's fault here. See if you can find more info and make a separate issue about it.

@bigretromike
Copy link
Contributor Author

It could be cache problem if RAM is unavailable so that "cache" is on pagefile on hdd.
also as @Cazzar stated it load db into 'cache' instead of passing thru requests.

So basicly @craige1 long start time could be the result of low RAM system.

@da3dsoul
Copy link
Member

Good point. We're doing better on RAM, but generally Shoko has always needed more than half of a gig of RAM in total. It used to just keep most of the RAM in SQL

@maxpiva
Copy link
Member

maxpiva commented Sep 16, 2017

@craige1 The text is misleading, it just happens to me, It says something like
Database Cache - Caching - ... Generating ... 1-20394 or something like that. I Expect to end in about 4 hours or so.
Is not a cache issue, is a regenerating issue, Every time you update to a new version, and this version has changed in the internal contracts, those contracts need regeneration. So it happens, only the first time you update the program if the above contracts need regeneration, after that the boot up will be less than a minute.
The text is misleading, because the contract regeneration happens in the cache subsystem. But its not a cache delay. Cache, just notice the contracts need regeneration and trigger thats.

@hidden4003
Copy link
Member

@Cazzar turned off use of cached contracts because they were failing to update properly and sometimes showed stale info, and there wasn't any significant performance hit. So this issue probably should be closed as won't fix, cache is core functionality now.

@da3dsoul
Copy link
Member

Well... There was a significant performance hit, but I just profiled it and fixed it....

@bigretromike
Copy link
Contributor Author

so no no on embedded devices ?

@da3dsoul
Copy link
Member

No no on embedded devices! A server relies on exactly two things: the speed of io, and the speed of network. Embedded devices (or at least the Pi) generally have them on the same port, so they can never be even as fast as half of a single port....

@da3dsoul
Copy link
Member

Embedded devices aren't servers! They are io controllers, ie toys. Do we need Tim Allen to explain this?

@da3dsoul
Copy link
Member

@bigretromike
Copy link
Contributor Author

embedded device was just a example of low Memory system, as argument of 'low RAM' is not compatible with someone ;-)

@da3dsoul
Copy link
Member

My point stands, though. If it doesn't have at least 2GB of RAM, it's almost certainly not going to meet the io and network requirements for a server

@bigretromike
Copy link
Contributor Author

bigretromike commented Sep 17, 2017 via email

@da3dsoul
Copy link
Member

Mhmm. You could.... Buy more RAM! Yeah sorry no, in that setup you'd have ECC unbuffered, and that's expensive. But really, most people have more RAM than they need. We are past the time of RAM restrictions in modern hardware. If you have more RAM, and can't spare 700MB, there is something else using too much RAM. For example, in a Linux box with 3GB, the OS takes 200MB, you might get fancy and run some monitoring software for another 100MB, a buffered file host for a variable 200-700MB, MySQL for the above few things at 100-500MB. You are still looking at 600-1500MB used out of 3GB, leaving plenty for ShokoServer.

@bigretromike
Copy link
Contributor Author

bigretromike commented Sep 17, 2017 via email

@da3dsoul
Copy link
Member

You are correct. I do in fact forget that exists.

@bigretromike
Copy link
Contributor Author

bigretromike commented Sep 17, 2017 via email

@da3dsoul
Copy link
Member

I'll leave it open as a constant reminder to not use all the RAM

@da3dsoul
Copy link
Member

da3dsoul commented Sep 17, 2017

Also, when Plex contracts are refactored out, it'll use much less RAM. There are also plans for better contract disposing and loading based on frequency of usage. The goal is to have the RAM usage a bit more configurable. I say use as much RAM as it takes to be as fast as possible. Brm says don't use more than 400Mb, so it starts disposing objects when it gets close.

@bigretromike
Copy link
Contributor Author

That would be a REALLY nice thing

@da3dsoul
Copy link
Member

We aren't against being stingy with RAM. We are against intentionally making a slow and annoying experience to save a few hundred megs

@ElementalCrisis
Copy link
Member

I may be confused but isn't the cache gone @da3dsoul?

@revam
Copy link
Member

revam commented Dec 31, 2023

I'm not da3d, but it's not yet gone. it will be gone after the EF migration... hopefully.

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

No branches or pull requests

9 participants