{"action":"created","issue":{"url":"https://api.github.com/repos/netty/netty/issues/5528","repository_url":"https://api.github.com/repos/netty/netty","labels_url":"https://api.github.com/repos/netty/netty/issues/5528/labels{/name}","comments_url":"https://api.github.com/repos/netty/netty/issues/5528/comments","events_url":"https://api.github.com/repos/netty/netty/issues/5528/events","html_url":"https://github.com/netty/netty/pull/5528","id":165235681,"number":5528,"title":"[#5505] Enforce Recycler limit when recycling from different threads","user":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/netty/netty/labels/defect","name":"defect","color":"e11d21"},{"url":"https://api.github.com/repos/netty/netty/labels/improvement","name":"improvement","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"assignees":[{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/netty/netty/milestones/146","html_url":"https://github.com/netty/netty/milestones/4.0.39.Final","labels_url":"https://api.github.com/repos/netty/netty/milestones/146/labels","id":1859618,"number":146,"title":"4.0.39.Final","description":"","creator":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"open_issues":55,"closed_issues":26,"state":"open","created_at":"2016-07-01T11:24:45Z","updated_at":"2016-07-13T04:41:36Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-07-13T04:38:45Z","updated_at":"2016-07-13T06:01:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/5528","html_url":"https://github.com/netty/netty/pull/5528","diff_url":"https://github.com/netty/netty/pull/5528.diff","patch_url":"https://github.com/netty/netty/pull/5528.patch"},"body":"Motivation:\r\n\r\nCurrently, the recycler max capacity it's only enforced on the\r\nthread-local stack which is used when the recycling happens on the\r\nsame thread that requested the object.\r\n\r\nWhen the recycling happens in a different thread, then the objects\r\nwill be queued into a linked list (where each node holds N objects,\r\ndefault=16). These objects are then transfered into the stack when\r\nnew objects are requested and the stack is empty.\r\n\r\nThe problem is that the queue doesn't have a max capacity and that\r\ncan lead to bad scenarios. Eg:\r\n\r\n- Allocate 1M object from recycler\r\n- Recycle all of them from different thread\r\n- Recycler WeakOrderQueue will contain 1M objects\r\n- Reference graph will be very long to traverse and GC timeseems to be negatively impacted\r\n- Size of the queue will never shrink after this\r\n\r\nModifications:\r\n\r\nAdd some shared counter which is used to manage capacity limits when recycle from different thread then the allocation thread. We modify the counter whenever we allocate a new Link to reduce the overhead of increment / decrement it.\r\n\r\nResult:\r\n\r\nMore predictable number of objects mantained in the recycler pool."},"comment":{"url":"https://api.github.com/repos/netty/netty/issues/comments/232264233","html_url":"https://github.com/netty/netty/pull/5528#issuecomment-232264233","issue_url":"https://api.github.com/repos/netty/netty/issues/5528","id":232264233,"user":{"login":"merlimat","id":62500,"avatar_url":"https://avatars.githubusercontent.com/u/62500?v=3","gravatar_id":"","url":"https://api.github.com/users/merlimat","html_url":"https://github.com/merlimat","followers_url":"https://api.github.com/users/merlimat/followers","following_url":"https://api.github.com/users/merlimat/following{/other_user}","gists_url":"https://api.github.com/users/merlimat/gists{/gist_id}","starred_url":"https://api.github.com/users/merlimat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merlimat/subscriptions","organizations_url":"https://api.github.com/users/merlimat/orgs","repos_url":"https://api.github.com/users/merlimat/repos","events_url":"https://api.github.com/users/merlimat/events{/privacy}","received_events_url":"https://api.github.com/users/merlimat/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T06:01:44Z","updated_at":"2016-07-13T06:01:44Z","body":"+1 thanks for carrying on with this!"}}
{"actor":{"display_login":"merlimat"}}