{"action":"created","issue":{"url":"https://api.github.com/repos/alecthomas/go_serialization_benchmarks/issues/42","labels_url":"https://api.github.com/repos/alecthomas/go_serialization_benchmarks/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/alecthomas/go_serialization_benchmarks/issues/42/comments","events_url":"https://api.github.com/repos/alecthomas/go_serialization_benchmarks/issues/42/events","html_url":"https://github.com/alecthomas/go_serialization_benchmarks/issues/42","id":128347143,"number":42,"title":"capnproto misuse","user":{"login":"glycerine","id":445247,"avatar_url":"https://avatars.githubusercontent.com/u/445247?v=3","gravatar_id":"","url":"https://api.github.com/users/glycerine","html_url":"https://github.com/glycerine","followers_url":"https://api.github.com/users/glycerine/followers","following_url":"https://api.github.com/users/glycerine/following{/other_user}","gists_url":"https://api.github.com/users/glycerine/gists{/gist_id}","starred_url":"https://api.github.com/users/glycerine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glycerine/subscriptions","organizations_url":"https://api.github.com/users/glycerine/orgs","repos_url":"https://api.github.com/users/glycerine/repos","events_url":"https://api.github.com/users/glycerine/events{/privacy}","received_events_url":"https://api.github.com/users/glycerine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-23T19:20:36Z","updated_at":"2016-01-23T23:18:37Z","closed_at":null,"body":"With regards to capnproto, capnproto bytes actually requires much less time (no additional beyond the I/O time for C++ code, and minimal for Go) to decode. \r\n\r\nYour application code example is introducing extra unnecessary copying. To avoid this, use the Bytes() methods commented below to point to the strings in memory rather than copy them unnecessarily.\r\n\r\nfrom https://github.com/alecthomas/go_serialization_benchmarks/blob/master/serialization_benchmarks_test.go#L496\r\n\r\n~~~\r\nfunc (x *CapNProtoSerializer) Unmarshal(d []byte, i interface{}) error {\r\n\ta := i.(*A)\r\n\ts, _, _ := capn.ReadFromMemoryZeroCopy(d)\r\n\to := ReadRootCapnpA(s)\r\n\ta.Name = string(o.Name())  // declare Name to be []byte, and use NameBytes() to minimize copying/allocation\r\n\ta.BirthDay = time.Unix(o.BirthDay(), 0)\r\n\ta.Phone = string(o.Phone())  // as above, use PhoneBytes()\r\n\ta.Siblings = int(o.Siblings())\r\n\ta.Spouse = o.Spouse()\r\n\ta.Money = o.Money()\r\n\treturn nil\r\n}\r\n~~~\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/alecthomas/go_serialization_benchmarks/issues/comments/174231322","html_url":"https://github.com/alecthomas/go_serialization_benchmarks/issues/42#issuecomment-174231322","issue_url":"https://api.github.com/repos/alecthomas/go_serialization_benchmarks/issues/42","id":174231322,"user":{"login":"alecthomas","id":41767,"avatar_url":"https://avatars.githubusercontent.com/u/41767?v=3","gravatar_id":"","url":"https://api.github.com/users/alecthomas","html_url":"https://github.com/alecthomas","followers_url":"https://api.github.com/users/alecthomas/followers","following_url":"https://api.github.com/users/alecthomas/following{/other_user}","gists_url":"https://api.github.com/users/alecthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/alecthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alecthomas/subscriptions","organizations_url":"https://api.github.com/users/alecthomas/orgs","repos_url":"https://api.github.com/users/alecthomas/repos","events_url":"https://api.github.com/users/alecthomas/events{/privacy}","received_events_url":"https://api.github.com/users/alecthomas/received_events","type":"User","site_admin":false},"created_at":"2016-01-23T23:18:37Z","updated_at":"2016-01-23T23:18:37Z","body":"Thanks for letting me know, though in future a pull request probably would have been much more expedient for all concerned. You can create a pull request directly from GitHub by editing the file."}}