{"action":"created","issue":{"url":"https://api.github.com/repos/lotus/lotus/issues/185","labels_url":"https://api.github.com/repos/lotus/lotus/issues/185/labels{/name}","comments_url":"https://api.github.com/repos/lotus/lotus/issues/185/comments","events_url":"https://api.github.com/repos/lotus/lotus/issues/185/events","html_url":"https://github.com/lotus/lotus/issues/185","id":62823749,"number":185,"title":"Performance issue with rendering a partial view","user":{"login":"smt116","id":619324,"avatar_url":"https://avatars.githubusercontent.com/u/619324?v=3","gravatar_id":"","url":"https://api.github.com/users/smt116","html_url":"https://github.com/smt116","followers_url":"https://api.github.com/users/smt116/followers","following_url":"https://api.github.com/users/smt116/following{/other_user}","gists_url":"https://api.github.com/users/smt116/gists{/gist_id}","starred_url":"https://api.github.com/users/smt116/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smt116/subscriptions","organizations_url":"https://api.github.com/users/smt116/orgs","repos_url":"https://api.github.com/users/smt116/repos","events_url":"https://api.github.com/users/smt116/events{/privacy}","received_events_url":"https://api.github.com/users/smt116/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-03-18T23:00:15Z","updated_at":"2015-06-18T06:32:53Z","closed_at":null,"body":"Hi there ;)\r\n\r\nI have a [sample application](https://github.com/smt116/lotus-sample-application). It seems that using `render partial: \"foo\"` (or `render template: \"foo\"` etc) results in really poor performance. Take a look at this [change](https://github.com/smt116/lotus-sample-application/commit/707ca41358cb952bc1d93e0eb72e6118744d3ffe). It reduces performance 10 times!\r\n\r\nHere is output of [wrk](https://github.com/wg/wrk) without rendering a partial inside a layout:\r\n\r\n```bash\r\n2.2.1 ~/repos/lotus-application master\r\n $ wrk --connections 4 --duration 5 --threads 4 http://localhost:2500\r\nRunning 5s test @ http://localhost:2500\r\n  4 threads and 4 connections\r\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\r\n    Latency     2.14ms    2.56ms  27.95ms   92.90%\r\n    Req/Sec   645.90    231.82     1.33k    63.98%\r\n  12367 requests in 5.00s, 8.41MB read\r\nRequests/sec:   2473.83\r\nTransfer/sec:      1.68MB\r\n```\r\n\r\nand here is after change:\r\n\r\n```bash\r\n2.2.1 ~/repos/lotus-application partial\r\n $ wrk --connections 4 --duration 5 --threads 4 http://localhost:2500\r\nRunning 5s test @ http://localhost:2500\r\n  4 threads and 4 connections\r\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\r\n    Latency    20.86ms   15.98ms  92.89ms   86.53%\r\n    Req/Sec    63.61     26.03   128.00     65.07%\r\n  1280 requests in 5.01s, 0.87MB read\r\nRequests/sec:    255.71\r\nTransfer/sec:    178.05KB\r\n```\r\n\r\nAs you can see 2.9k req/sec vs 0.29k req/sec. I am using slim in this case, but it seems to be a general issue. I checked with haml and it remains the same.\r\n\r\n## How to reproduce\r\n\r\n```bash\r\n # clone repo\r\n $ git clone git@github.com:smt116/lotus-sample-application.git\r\n\r\n # install gems\r\n $ cd lotus-sample-application && bundle install\r\n\r\n # create config for postgresql database\r\n $ cp config/.env.example config/.env && vim config/.env\r\n\r\n # optional: setup database\r\n $ rake db:create && rake db:migrate && rake db:seed\r\n```\r\n\r\nPerform a benchmark on `master` and `partial` branchs:\r\n\r\n```bash\r\n # run server\r\n $ RACK_ENV=production puma --threads 4:4 --port 2500 --preload --quiet\r\n```\r\n\r\n```bash\r\n # perform stress test using https://github.com/wg/wrk\r\n $ wrk --connections 4 --duration 5 --threads 4 http://localhost:2500\r\n```\r\n\r\n---\r\n\r\nI talked with @jodosha and with @joneslee85 and I said that I will post it on the forum, but I think that it is more like an issue to fix than a post to discuss. I can move it there if you want ;).\r\n\r\nI can investigate it further if you want."},"comment":{"url":"https://api.github.com/repos/lotus/lotus/issues/comments/113052384","html_url":"https://github.com/lotus/lotus/issues/185#issuecomment-113052384","issue_url":"https://api.github.com/repos/lotus/lotus/issues/185","id":113052384,"user":{"login":"agenteo","id":16841,"avatar_url":"https://avatars.githubusercontent.com/u/16841?v=3","gravatar_id":"","url":"https://api.github.com/users/agenteo","html_url":"https://github.com/agenteo","followers_url":"https://api.github.com/users/agenteo/followers","following_url":"https://api.github.com/users/agenteo/following{/other_user}","gists_url":"https://api.github.com/users/agenteo/gists{/gist_id}","starred_url":"https://api.github.com/users/agenteo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agenteo/subscriptions","organizations_url":"https://api.github.com/users/agenteo/orgs","repos_url":"https://api.github.com/users/agenteo/repos","events_url":"https://api.github.com/users/agenteo/events{/privacy}","received_events_url":"https://api.github.com/users/agenteo/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T06:32:53Z","updated_at":"2015-06-18T06:32:53Z","body":"Hi guys, I took a peak at this today to help moving forward, first of all should the issue be moved or at least tracked in [lotus-view](https://github.com/lotus/view)?\r\n\r\nI located the commit introducing partial rendering at https://github.com/lotus/view/commit/ba5acdc30673bfeeecda2c61217884bdd7d5f20c\r\n\r\nI was looking at what Luca said about the templates being pre-loaded from `Lotus::View.load!`: https://github.com/lotus/view/blob/master/lib/lotus/view.rb#L289 which calls Configuration#load! https://github.com/lotus/view/blob/master/lib/lotus/view/configuration.rb#L362\r\n\r\nwhat I didn't understand is at what point is the `views` set populated? Is the private `add_view` (https://github.com/lotus/view/blob/master/lib/lotus/view/configuration.rb#L330) used at all?\r\n\r\nCheers"}}