Fix dashboard ignored system setting cache#21621
Conversation
|
#21611 related? |
|
|
Not sure thought, the issue mentiones 1.17 but #18058 is only on 1.18. |
Wow, so that's not the same issue. |
There's too much duplication of the cache functionality within the PR, and looking at other models packages we're happy to use cache - so - move the caching functionality in to models/system and models/user. Then remove the functions from modules/system and directly call functions in models/system Signed-off-by: Andrew Thornton <art27@cantab.net>
…hing Reduce duplication and move functions out of modules/system
|
@zeripath done. |
…tea into lunny/fix_performance_dashboard
|
OK, there are a few other problems here:
As an aside, we really need to rethink our caching infrastructure. Ideally I think what we need is a two-or-three level caching infrastructure.
Things cached in the internal memory caches would need be considered immutable on Get - request level cache could be considered mutable because they're unlikely to affected by concurrency and the external caches would create new structs by default anyway. So, I am now concerned that this may not be the correct solution at all and I think the issue that this data is being requested over and over again unnecessary. With a little thought we could prevent this problem entirely. |
Why the time is important need to be changed? I think once the value changed, the cache has been updated.
I think yes. We should always return the values as string or int64 so that they cannot be changed.
I think no, we can't remove the caching, it has produced actual affect in the main branch especially in dashboard from some users' reports. A memory cache or a redis cache operation will be nanosecond level but a database operation is microsecond level, memory/redis is fast about 10~1000 than database operations. And even in one request, the same setting maybe reused serveral times.
As above.
|
Codecov Report
@@ Coverage Diff @@
## main #21621 +/- ##
=======================================
Coverage ? 48.19%
=======================================
Files ? 1030
Lines ? 140403
Branches ? 0
=======================================
Hits ? 67664
Misses ? 64629
Partials ? 8110
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This is not definitely the case. Imagine a clustered system with a non-clustered cache. Imagine a change to the caching configuration. ...
I meant could we restructure this code to only request this only once per HTTP request (eg. per GET/POST level)? There's no good reason to repeatedly get the setting from the db over and over again. In fact it could/would even lead to inconsistent results within the handling of a request if the value were to change mid-way through something. This is a good example where context passing could be used to ensure that data is cached at a HTTP request level. |
zeripath
left a comment
There was a problem hiding this comment.
I guess we should approve this PR as it stands as a bug-fix but we really need to address the issues I've noted above.
It's silly that we risk having to keep hit the db like this. There should be a better way of doing this.
It's a good idea to cache per request based on |
|
make L-G-T-M work |
This is a performance regression from go-gitea#18058 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
* giteaofficial/main: Revert unrelated changes for SMTP auth (go-gitea#21767) Init git module before database migration (go-gitea#21764) Extract updateSession function to reduce repetition (go-gitea#21735) Fix dashboard ignored system setting cache (go-gitea#21621) Add .dockerignore (go-gitea#21753)
This is a performance regression from go-gitea#18058 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
Fix #22281 In #21621 , `Get[V]` and `Set[V]` has been introduced, so that cache value will be `*Setting`. For memory cache it's OK. But for redis cache, it can only store `string` for the current implementation. This PR revert some of changes of that and just store or return a `string` for system setting.
This is a performance regression from #18058