{"action":"created","issue":{"url":"https://api.github.com/repos/OpenGamma/Strata/issues/783","repository_url":"https://api.github.com/repos/OpenGamma/Strata","labels_url":"https://api.github.com/repos/OpenGamma/Strata/issues/783/labels{/name}","comments_url":"https://api.github.com/repos/OpenGamma/Strata/issues/783/comments","events_url":"https://api.github.com/repos/OpenGamma/Strata/issues/783/events","html_url":"https://github.com/OpenGamma/Strata/issues/783","id":133541252,"number":783,"title":"List generation inefficiency","user":{"login":"fmovlex","id":3194860,"avatar_url":"https://avatars.githubusercontent.com/u/3194860?v=3","gravatar_id":"","url":"https://api.github.com/users/fmovlex","html_url":"https://github.com/fmovlex","followers_url":"https://api.github.com/users/fmovlex/followers","following_url":"https://api.github.com/users/fmovlex/following{/other_user}","gists_url":"https://api.github.com/users/fmovlex/gists{/gist_id}","starred_url":"https://api.github.com/users/fmovlex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fmovlex/subscriptions","organizations_url":"https://api.github.com/users/fmovlex/orgs","repos_url":"https://api.github.com/users/fmovlex/repos","events_url":"https://api.github.com/users/fmovlex/events{/privacy}","received_events_url":"https://api.github.com/users/fmovlex/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OpenGamma/Strata/labels/Type:Task","name":"Type:Task","color":"333300"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-14T13:55:25Z","updated_at":"2016-02-16T12:21:43Z","closed_at":null,"body":"I've noticed this issue in `PeriodicSchedule.java` - it probably exists in other spots as well.\r\nTake for example `PeriodicSchedule#generateBackwards` (line 493 or 499 on my version) - and consider a non standard internal swap (e.g. float-float, pay 1m, over 50y, pay/rec legs -> ~1200 payment periods).\r\n\r\nUsing an `ArrayList` copies a giant amount of increasingly-sized arrays - and in a portfolio with hundreds of these swaps (or during HVaR) things get messy.\r\nUsing an `ArrayDeque` here and optimizing inserts for head/tail will really help here - for example, instead of adding `end` and `start` (which forces you to insert at position 1), use a `Deque` and head-insert everything, then head-insert `start` last.\r\n\r\nI'm not really familiar with anything except swaps so I hesitate to change things myself, but a review of similar list-generating methods (and especially backward-generating) across the library would likely boost performance.\r\nThanks guys"},"comment":{"url":"https://api.github.com/repos/OpenGamma/Strata/issues/comments/184661771","html_url":"https://github.com/OpenGamma/Strata/issues/783#issuecomment-184661771","issue_url":"https://api.github.com/repos/OpenGamma/Strata/issues/783","id":184661771,"user":{"login":"jodastephen","id":213212,"avatar_url":"https://avatars.githubusercontent.com/u/213212?v=3","gravatar_id":"","url":"https://api.github.com/users/jodastephen","html_url":"https://github.com/jodastephen","followers_url":"https://api.github.com/users/jodastephen/followers","following_url":"https://api.github.com/users/jodastephen/following{/other_user}","gists_url":"https://api.github.com/users/jodastephen/gists{/gist_id}","starred_url":"https://api.github.com/users/jodastephen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodastephen/subscriptions","organizations_url":"https://api.github.com/users/jodastephen/orgs","repos_url":"https://api.github.com/users/jodastephen/repos","events_url":"https://api.github.com/users/jodastephen/events{/privacy}","received_events_url":"https://api.github.com/users/jodastephen/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T12:21:43Z","updated_at":"2016-02-16T12:21:43Z","body":"My testing didn't find a major slowdown as a result of the insertion at index 1 pattern. I've raised a R to address it, using a private `List` implementation that acts like `ArrayDeque`."}}