{"action":"created","issue":{"url":"https://api.github.com/repos/spree/spree/issues/5776","labels_url":"https://api.github.com/repos/spree/spree/issues/5776/labels{/name}","comments_url":"https://api.github.com/repos/spree/spree/issues/5776/comments","events_url":"https://api.github.com/repos/spree/spree/issues/5776/events","html_url":"https://github.com/spree/spree/pull/5776","id":51903351,"number":5776,"title":"Improve store performance for orders with total quantity > 1000","user":{"login":"mtomov","id":1651750,"avatar_url":"https://avatars.githubusercontent.com/u/1651750?v=3","gravatar_id":"","url":"https://api.github.com/users/mtomov","html_url":"https://github.com/mtomov","followers_url":"https://api.github.com/users/mtomov/followers","following_url":"https://api.github.com/users/mtomov/following{/other_user}","gists_url":"https://api.github.com/users/mtomov/gists{/gist_id}","starred_url":"https://api.github.com/users/mtomov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtomov/subscriptions","organizations_url":"https://api.github.com/users/mtomov/orgs","repos_url":"https://api.github.com/users/mtomov/repos","events_url":"https://api.github.com/users/mtomov/events{/privacy}","received_events_url":"https://api.github.com/users/mtomov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spree/spree/labels/address_feedback","name":"address_feedback","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/spree/spree/milestones/27","labels_url":"https://api.github.com/repos/spree/spree/milestones/27/labels","id":709927,"number":27,"title":"v3.0.0","description":"","creator":{"login":"JDutil","id":25104,"avatar_url":"https://avatars.githubusercontent.com/u/25104?v=3","gravatar_id":"","url":"https://api.github.com/users/JDutil","html_url":"https://github.com/JDutil","followers_url":"https://api.github.com/users/JDutil/followers","following_url":"https://api.github.com/users/JDutil/following{/other_user}","gists_url":"https://api.github.com/users/JDutil/gists{/gist_id}","starred_url":"https://api.github.com/users/JDutil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDutil/subscriptions","organizations_url":"https://api.github.com/users/JDutil/orgs","repos_url":"https://api.github.com/users/JDutil/repos","events_url":"https://api.github.com/users/JDutil/events{/privacy}","received_events_url":"https://api.github.com/users/JDutil/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":35,"state":"open","created_at":"2014-07-03T22:04:28Z","updated_at":"2015-02-03T19:06:45Z","due_on":"2025-07-31T07:00:00Z","closed_at":null},"comments":5,"created_at":"2014-12-13T23:41:21Z","updated_at":"2015-02-06T19:36:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/spree/spree/pulls/5776","html_url":"https://github.com/spree/spree/pull/5776","diff_url":"https://github.com/spree/spree/pull/5776.diff","patch_url":"https://github.com/spree/spree/pull/5776.patch"},"body":"by refactoring Package#add\r\n\r\nBefore the change => `Package#contents` was an array, and finding content items using `detect` was very costly as per the performance measurements below.\r\n\r\nAfter the change => `Package#contents` is a Set. A set contains only unique items by definition. To properly allow Ruby to compare the `content items` in the set, the #hash and the #eql? methods have to be defined on the `Content Item` class as per this example in the  [Ruby Docs](http://www.ruby-doc.org/core-2.1.5/Hash.html#class-Hash-label-Hash+Keys)\r\n\r\n\r\npartially contributes to the fix of #5706\r\n\r\n\r\n```ruby\r\n\r\n\r\n# Spree 3.0 latest\r\n\r\n                           user     system      total        real\r\n1000 Inventory Units:  3.490000   0.060000   3.550000 (  3.732619)\r\n2000 Inventory Units: 10.760000   0.120000  10.880000 ( 11.182196)\r\n3000 Inventory Units: 23.590000   0.210000  23.800000 ( 24.274458)\r\n\r\n# commenting out Spree::Stock::Package#add -> #unless find_item(inventory_unit)\r\n# (no comparison is performed)\r\n                           user     system      total        real\r\n1000 Inventory Units:  1.910000   0.070000   1.980000 (  2.165775)\r\n2000 Inventory Units:  3.460000   0.130000   3.590000 (  3.921917)\r\n3000 Inventory Units:  5.400000   0.180000   5.580000 (  6.061517)\r\n\r\n\r\n# After converting Package.contents to a Set from Array\r\n                           user     system      total        real\r\n1000 Inventory Units:  2.100000   0.070000   2.170000 (  2.376794)\r\n2000 Inventory Units:  3.700000   0.140000   3.840000 (  4.187232)\r\n3000 Inventory Units:  5.620000   0.200000   5.820000 (  6.382836)\r\n\r\n```\r\n\r\n----\r\nAfter the change, `#find_item` is only used by `#remove`. Please advise if `#remove` should also receive a better implementation.\r\n\r\nFeedback is appreciated!"},"comment":{"url":"https://api.github.com/repos/spree/spree/issues/comments/73298828","html_url":"https://github.com/spree/spree/pull/5776#issuecomment-73298828","issue_url":"https://api.github.com/repos/spree/spree/issues/5776","id":73298828,"user":{"login":"mtomov","id":1651750,"avatar_url":"https://avatars.githubusercontent.com/u/1651750?v=3","gravatar_id":"","url":"https://api.github.com/users/mtomov","html_url":"https://github.com/mtomov","followers_url":"https://api.github.com/users/mtomov/followers","following_url":"https://api.github.com/users/mtomov/following{/other_user}","gists_url":"https://api.github.com/users/mtomov/gists{/gist_id}","starred_url":"https://api.github.com/users/mtomov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtomov/subscriptions","organizations_url":"https://api.github.com/users/mtomov/orgs","repos_url":"https://api.github.com/users/mtomov/repos","events_url":"https://api.github.com/users/mtomov/events{/privacy}","received_events_url":"https://api.github.com/users/mtomov/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T19:36:36Z","updated_at":"2015-02-06T19:36:36Z","body":"Sorry for the long gap.\r\n\r\n@jhawthorn, your comments on commit https://github.com/spree/spree/commit/7837fd1640596055b303f702bdef16a3610149bc#commitcomment-9225760 have no relation to the rafactoring performed here. I am by no means trying to change the comparison logic itself. I am just transferring it from a structure of type  `array` to a `set`, as this brings noticeable performance gains.\r\n\r\nWhat is more, I think that I have addressed all of `your concerns`, and have explicitly asked for any further comments. Given that there are no further replies, it is normal for @JDutil to merge it.\r\n\r\nCould you please further clarify your `concerns` and also help me if possible to realize the intended performance gains?\r\n\r\nThank you!"}}