{"action":"created","issue":{"url":"https://api.github.com/repos/datastax/csharp-driver/issues/140","labels_url":"https://api.github.com/repos/datastax/csharp-driver/issues/140/labels{/name}","comments_url":"https://api.github.com/repos/datastax/csharp-driver/issues/140/comments","events_url":"https://api.github.com/repos/datastax/csharp-driver/issues/140/events","html_url":"https://github.com/datastax/csharp-driver/pull/140","id":109782297,"number":140,"title":"Remove unneeded byte[] allocation from TypeCodec","user":{"login":"ocoanet","id":1525572,"avatar_url":"https://avatars.githubusercontent.com/u/1525572?v=3","gravatar_id":"","url":"https://api.github.com/users/ocoanet","html_url":"https://github.com/ocoanet","followers_url":"https://api.github.com/users/ocoanet/followers","following_url":"https://api.github.com/users/ocoanet/following{/other_user}","gists_url":"https://api.github.com/users/ocoanet/gists{/gist_id}","starred_url":"https://api.github.com/users/ocoanet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocoanet/subscriptions","organizations_url":"https://api.github.com/users/ocoanet/orgs","repos_url":"https://api.github.com/users/ocoanet/repos","events_url":"https://api.github.com/users/ocoanet/events{/privacy}","received_events_url":"https://api.github.com/users/ocoanet/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-10-05T12:06:39Z","updated_at":"2015-10-08T09:17:03Z","closed_at":"2015-10-08T08:26:29Z","pull_request":{"url":"https://api.github.com/repos/datastax/csharp-driver/pulls/140","html_url":"https://github.com/datastax/csharp-driver/pull/140","diff_url":"https://github.com/datastax/csharp-driver/pull/140.diff","patch_url":"https://github.com/datastax/csharp-driver/pull/140.patch"},"body":"The last allocation remaining in `TypeCode.DecodeDouble()` after @alprema improvements can be removed using a conversion struct. The benchmark now runs 70% faster than the baseline instead of 54%.\r\n\r\n`TypeCode.DecodeFloat()` was also updated to benefit from the same enhancements."},"comment":{"url":"https://api.github.com/repos/datastax/csharp-driver/issues/comments/146467613","html_url":"https://github.com/datastax/csharp-driver/pull/140#issuecomment-146467613","issue_url":"https://api.github.com/repos/datastax/csharp-driver/issues/140","id":146467613,"user":{"login":"alprema","id":954934,"avatar_url":"https://avatars.githubusercontent.com/u/954934?v=3","gravatar_id":"","url":"https://api.github.com/users/alprema","html_url":"https://github.com/alprema","followers_url":"https://api.github.com/users/alprema/followers","following_url":"https://api.github.com/users/alprema/following{/other_user}","gists_url":"https://api.github.com/users/alprema/gists{/gist_id}","starred_url":"https://api.github.com/users/alprema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alprema/subscriptions","organizations_url":"https://api.github.com/users/alprema/orgs","repos_url":"https://api.github.com/users/alprema/repos","events_url":"https://api.github.com/users/alprema/events{/privacy}","received_events_url":"https://api.github.com/users/alprema/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T09:17:03Z","updated_at":"2015-10-08T09:17:03Z","body":"Hi,\r\n\r\nI just ran your code as is and the result is about 15% in favor of the physical layout, changing the inner iteration count to 1000 to give more time for GC to factor in gives about 47% difference (benchmarking such code with 2000 iterations is clearly not representative).\r\n\r\nFinally, removing Linq from the benchmark loop (as follows) gives about 80% difference.\r\n```cs\r\n                    for (var j = 0; j < values.Length; ++j)\r\n                        DecodeFunc(values[j]);\r\n```\r\ninstead of\r\n```cs\r\n                    values.Select(DecodeFunc).Sum();\r\n```\r\n(at those speeds, Linq accounts for about half the time of the measurement).\r\n\r\nI understand your concern about readability of the code, but when writing serialization code that is called millions of times per seconds (and that is a bottleneck to a very common use case), performance can be chosen over readability.\r\n\r\nI am at your disposal if you need more details on my results / tests."}}