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

Improve URL resolver performance #3712

Closed
davidfischer opened this issue Mar 1, 2018 · 4 comments · Fixed by #5530
Closed

Improve URL resolver performance #3712

davidfischer opened this issue Mar 1, 2018 · 4 comments · Fixed by #5530
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code
Milestone

Comments

@davidfischer
Copy link
Contributor

davidfischer commented Mar 1, 2018

Our URL resolver (https://github.com/rtfd/readthedocs.org/blob/4d10f2e/readthedocs/core/resolver.py) which turns a Project and/or Version into a URL to their documentation needs some performance improvements to reduce or eliminate the number of database queries it makes.

This is particularly noticeable on the footer_html API call (https://github.com/rtfd/readthedocs.org/blob/ba71aa1/readthedocs/restapi/templates/restapi/footer.html#L43) which is called on every docs pageview to inject the version selector. In order to get the URL to each version in the version selector, four database queries are needed (to make sure this isn't a subproject or translation and get the domain). So for a project with 10 active versions, we are looking at 40 database queries. Most of this effort is wasted since the data is only needed once for the project.

@davidfischer davidfischer added the Improvement Minor improvement to code label Mar 1, 2018
@aasis21
Copy link
Contributor

aasis21 commented Mar 1, 2018

Hi @davidfischer, Can I take up this issue.
I realize that the template calls version.get_subdomain_url which calls project.get_docs_url which further calls the resolver mentioned above. we should pass this resolved URL in template directly for reuse. Furthermore, the protocol in resolver function should be changed to https.
Are you suggesting to use Django ORM database optimizations techniques to reduce the count of database queries or some change of layout in the code?

@davidfischer
Copy link
Contributor Author

That's pretty accurate.

I'm not 100% sure that we should force HTTPS yet (see #3282). While every project hosted by *.readthedocs.io can and should use HTTPS, some docs use their own domain and not all of those support HTTPS (eg. http://docs.python-requests.org)

@davidfischer
Copy link
Contributor Author

I should mention that I welcome a PR for this. However, I will caution you that this will probably be a bit complex.

@stale
Copy link

stale bot commented Jan 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jan 10, 2019
@stsewd stsewd added Accepted Accepted issue on our roadmap and removed Status: stale Issue will be considered inactive soon labels Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants