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>