{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/7918","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/7918/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/7918/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/7918/events","html_url":"https://github.com/dotnet/corefx/pull/7918","id":149701044,"number":7918,"title":"Reduce ConcurrentBag Node allocations","user":{"login":"benaadams","id":1142958,"avatar_url":"https://avatars.githubusercontent.com/u/1142958?v=3","gravatar_id":"","url":"https://api.github.com/users/benaadams","html_url":"https://github.com/benaadams","followers_url":"https://api.github.com/users/benaadams/followers","following_url":"https://api.github.com/users/benaadams/following{/other_user}","gists_url":"https://api.github.com/users/benaadams/gists{/gist_id}","starred_url":"https://api.github.com/users/benaadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benaadams/subscriptions","organizations_url":"https://api.github.com/users/benaadams/orgs","repos_url":"https://api.github.com/users/benaadams/repos","events_url":"https://api.github.com/users/benaadams/events{/privacy}","received_events_url":"https://api.github.com/users/benaadams/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-20T08:41:48Z","updated_at":"2016-04-20T11:25:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/7918","html_url":"https://github.com/dotnet/corefx/pull/7918","diff_url":"https://github.com/dotnet/corefx/pull/7918.diff","patch_url":"https://github.com/dotnet/corefx/pull/7918.patch"},"body":"Should allow higher throughput object pooling use with lower allocations\r\n\r\n* Up to 32 \"at rest\" Nodes are pooled per thread in ThreadLocalList in a `Queue<Node>`\r\n* Node references are cleared when pooled\r\n* ~~Node is padded >= 64 bytes to reduce false sharing (64 bytes + syncblock + type descriptor)~~\r\n\r\nThe following code\r\n```csharp\r\nvar o = new object();\r\nvar bag = new ConcurrentBag<object>();\r\nfor (var ii = 0; ii < 1000000; ii++)\r\n{\r\n    for (var i = 0; i < 32; i++)\r\n    {\r\n        bag.Add(o);\r\n    }\r\n    for (var i = 0; i < 32; i++)\r\n    {\r\n        bag.TryTake(out o);\r\n    }\r\n}\r\n```\r\n\r\nBefore allocations  31,974,596 Nodes for 1,278,983,840 bytes\r\n\r\n![Node allocations](http://aoa.blob.core.windows.net/aspnet/concurrentbag1.png)\r\n\r\nAfter allocations  32 Nodes for 1,280 bytes\r\n\r\n![Node allocations](http://aoa.blob.core.windows.net/aspnet/concurrentbag1.png)\r\n\r\n\r\nFixes  #7917 \r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/212387003","html_url":"https://github.com/dotnet/corefx/pull/7918#issuecomment-212387003","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/7918","id":212387003,"user":{"login":"chrisaut","id":8252355,"avatar_url":"https://avatars.githubusercontent.com/u/8252355?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisaut","html_url":"https://github.com/chrisaut","followers_url":"https://api.github.com/users/chrisaut/followers","following_url":"https://api.github.com/users/chrisaut/following{/other_user}","gists_url":"https://api.github.com/users/chrisaut/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisaut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisaut/subscriptions","organizations_url":"https://api.github.com/users/chrisaut/orgs","repos_url":"https://api.github.com/users/chrisaut/repos","events_url":"https://api.github.com/users/chrisaut/events{/privacy}","received_events_url":"https://api.github.com/users/chrisaut/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T11:25:34Z","updated_at":"2016-04-20T11:25:34Z","body":"@benaadams  Did you attach/link wrong image for the \"after\" case?"}}