{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-js/issues/708","repository_url":"https://api.github.com/repos/swagger-api/swagger-js","labels_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/708/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/708/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/708/events","html_url":"https://github.com/swagger-api/swagger-js/pull/708","id":134820599,"number":708,"title":"Fix slowness for all of resolvment","user":{"login":"markusz","id":6770995,"avatar_url":"https://avatars.githubusercontent.com/u/6770995?v=3","gravatar_id":"","url":"https://api.github.com/users/markusz","html_url":"https://github.com/markusz","followers_url":"https://api.github.com/users/markusz/followers","following_url":"https://api.github.com/users/markusz/following{/other_user}","gists_url":"https://api.github.com/users/markusz/gists{/gist_id}","starred_url":"https://api.github.com/users/markusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markusz/subscriptions","organizations_url":"https://api.github.com/users/markusz/orgs","repos_url":"https://api.github.com/users/markusz/repos","events_url":"https://api.github.com/users/markusz/events{/privacy}","received_events_url":"https://api.github.com/users/markusz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-02-19T09:53:02Z","updated_at":"2016-02-22T09:32:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/swagger-api/swagger-js/pulls/708","html_url":"https://github.com/swagger-api/swagger-js/pull/708","diff_url":"https://github.com/swagger-api/swagger-js/pull/708.diff","patch_url":"https://github.com/swagger-api/swagger-js/pull/708.patch"},"body":"Plenty of people are experiencing slowness when using SwaggerUI with complex nested specs [here](https://www.google.de/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#safe=off&q=swagger-ui+slow).\r\n\r\nI had the same problem for a project and tracked the issue down to a specific call of `swagger-js`: `resolveAllOf`. This call has several problems:\r\n\r\n- It is a recursive call (which is not a problem per se)\r\n- It is always called, regardless of actual usage of `allOf` tags\r\n- **This is the biggest issue:** It is called twice in each recursion (see [here](https://github.com/swagger-api/swagger-js/blob/master/lib/resolver.js#L673-L675) and [here](https://github.com/swagger-api/swagger-js/blob/master/lib/resolver.js#L738-L740) ), causing the call stack to completely explode for nested definitions \r\n\r\nThe following screenshots outline the severity of the problem \r\n\r\n## Status Quo\r\n\r\nFor my (rather simple) api-docs.json, `resolveAllOf` is called **104,000,000** times, resulting in a render time of 4 minutes and a CPU consumption of 90 %.\r\n\r\n![default](https://cloud.githubusercontent.com/assets/6770995/13171841/3c5bb32e-d6f5-11e5-8cda-6c6afd3c97a7.png)\r\n\r\n##  Deduplication and disableAllOfResolve = false \r\n\r\nThe screenshot below shows the behavior after only removing the duplicated recursion in `resolveAllOf` in https://github.com/swagger-api/swagger-js/commit/be29806f56b7c183c4b09d578b6a880d26c1e2ba\r\n\r\n`resolveAllOf` is now called \"only\" **6584** times,  which is still too often, but does not cause problems like hanging of the whole browser. Load time is okayish with 3 seconds\r\n\r\n**This is the proposed / implemented default behavior since it does not affect functionality in any way.**\r\n\r\n![deduplicatedresolveallcall](https://cloud.githubusercontent.com/assets/6770995/13171839/3bf032d4-d6f5-11e5-80fd-007cd4dc143d.png)\r\n\r\n##  Deduplication and disableAllOfResolve = true\r\n\r\n`resolveAllOf` is now not called at all. This is the best approach if `allOf` is not used in the swagger docs. Reduces load time to < 1s\r\n\r\n![disableallofresolving](https://cloud.githubusercontent.com/assets/6770995/13171840/3c4cb324-d6f5-11e5-8ebe-91c1d701eb3c.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-js/issues/comments/187093111","html_url":"https://github.com/swagger-api/swagger-js/pull/708#issuecomment-187093111","issue_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/708","id":187093111,"user":{"login":"andi-itagent","id":1262545,"avatar_url":"https://avatars.githubusercontent.com/u/1262545?v=3","gravatar_id":"","url":"https://api.github.com/users/andi-itagent","html_url":"https://github.com/andi-itagent","followers_url":"https://api.github.com/users/andi-itagent/followers","following_url":"https://api.github.com/users/andi-itagent/following{/other_user}","gists_url":"https://api.github.com/users/andi-itagent/gists{/gist_id}","starred_url":"https://api.github.com/users/andi-itagent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andi-itagent/subscriptions","organizations_url":"https://api.github.com/users/andi-itagent/orgs","repos_url":"https://api.github.com/users/andi-itagent/repos","events_url":"https://api.github.com/users/andi-itagent/events{/privacy}","received_events_url":"https://api.github.com/users/andi-itagent/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T09:32:43Z","updated_at":"2016-02-22T09:32:43Z","body":"+1"}}