Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 674
    • Issues 674
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #3402
Closed
Open
Created Feb 19, 2021 by Adrian@Adrian

Tornado slower than expected with PyPy

As you know, I've recently been troubleshooting a poorly-performing Tornado app, where PyPy was delivering 50% of CPython's throughput.

I managed to close this gap significantly (and drastically improve overall performance) by eliminating use of Tornado's "import" and "module" templating features.

I've created a minimal test case, where PyPy outperforms by 15%, but this is still far short of a previously published benchmark involving Tornado.

What's more, if I switch from Tornado's HTML output to JSON output, CPython outperforms by 50%, which I didn't expect.

I'm raising this issue in case you'd consider looking for any PyPy bottlenecks with one of the more popular frameworks. Minimal code below:

app.py

import tornado.httpserver
import tornado.ioloop
import tornado.web

from random import choice
from string import ascii_letters


text = [[''.join(choice(ascii_letters) for x in range(8)) for y in range(16)] for z in range(64)]


class MainHandler(tornado.web.RequestHandler):
    async def get(self):
        self.render("index.html", title="Test", text=text)
        # self.write(dict(title="Test", text=text))


def main():
    app = tornado.web.Application([(r"/", MainHandler)])
    app.listen(80)
    tornado.ioloop.IOLoop.current().start()


if __name__ == "__main__":
    main()

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>{{ title }}</title>
  </head>
  <body>
    <h1>{{ title }}</h1>
    {% for par in text %}
      <p>{% for word in par %} {{ word }} {% end %}</p>
    {% end %}
  </body>
</html>
Edited Feb 19, 2021 by Adrian
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking