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

PyPI package PackageMetadata endpoint recreates Templates #20210

Closed
zeripath opened this issue Jul 3, 2022 · 0 comments · Fixed by #20218
Closed

PyPI package PackageMetadata endpoint recreates Templates #20210

zeripath opened this issue Jul 3, 2022 · 0 comments · Fixed by #20218
Labels

Comments

@zeripath
Copy link
Contributor

zeripath commented Jul 3, 2022

Description

The PyPI PackageMetadata endpoint recreates a template renderer on every call:

ctx.Render = templates.HTMLRenderer()

This involves reading and parsing templates for all possible templates.

The templates should be being shared.

Gitea Version

1.17+

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

N/A

Database

No response

zeripath added a commit to zeripath/gitea that referenced this issue Jul 3, 2022
The recovery, API, Web and package frameworks all create their own HTML
Renderers. This increases the memory requirements of Gitea
unnecessarily with duplicate templates being kept in memory.

Further the reloading framework in dev mode for these involves locking
and recompiling all of the templates on each load. This will potentially
hide concurrency issues and it is inefficient.

This PR stores the templates renderer in the context and stores this
context in the NormalRoutes, it then creates a fsnotify.Watcher
framework to watch files.

The watching framework is then extended to the mailer templates which
were previously not being reloaded in dev.

Then the locales are simplified to a similar structure.

Fix go-gitea#20210, go-gitea#20211, go-gitea#20217
Replace go-gitea#20159

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Aug 28, 2022
The recovery, API, Web and package frameworks all create their own HTML
Renderers. This increases the memory requirements of Gitea
unnecessarily with duplicate templates being kept in memory.

Further the reloading framework in dev mode for these involves locking
and recompiling all of the templates on each load. This will potentially
hide concurrency issues and it is inefficient.

This PR stores the templates renderer in the context and stores this
context in the NormalRoutes, it then creates a fsnotify.Watcher
framework to watch files.

The watching framework is then extended to the mailer templates which
were previously not being reloaded in dev.

Then the locales are simplified to a similar structure.

Fix #20210 
Fix #20211
Fix #20217

Signed-off-by: Andrew Thornton <art27@cantab.net>
vsysoev pushed a commit to IntegraSDL/gitea that referenced this issue Aug 28, 2022
…a#20218)

The recovery, API, Web and package frameworks all create their own HTML
Renderers. This increases the memory requirements of Gitea
unnecessarily with duplicate templates being kept in memory.

Further the reloading framework in dev mode for these involves locking
and recompiling all of the templates on each load. This will potentially
hide concurrency issues and it is inefficient.

This PR stores the templates renderer in the context and stores this
context in the NormalRoutes, it then creates a fsnotify.Watcher
framework to watch files.

The watching framework is then extended to the mailer templates which
were previously not being reloaded in dev.

Then the locales are simplified to a similar structure.

Fix go-gitea#20210 
Fix go-gitea#20211
Fix go-gitea#20217

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant