{"action":"created","issue":{"url":"https://api.github.com/repos/jparyani/pycapnp/issues/99","repository_url":"https://api.github.com/repos/jparyani/pycapnp","labels_url":"https://api.github.com/repos/jparyani/pycapnp/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/jparyani/pycapnp/issues/99/comments","events_url":"https://api.github.com/repos/jparyani/pycapnp/issues/99/events","html_url":"https://github.com/jparyani/pycapnp/issues/99","id":154565348,"number":99,"title":"Performance Issues","user":{"login":"brunsgaard","id":815816,"avatar_url":"https://avatars.githubusercontent.com/u/815816?v=3","gravatar_id":"","url":"https://api.github.com/users/brunsgaard","html_url":"https://github.com/brunsgaard","followers_url":"https://api.github.com/users/brunsgaard/followers","following_url":"https://api.github.com/users/brunsgaard/following{/other_user}","gists_url":"https://api.github.com/users/brunsgaard/gists{/gist_id}","starred_url":"https://api.github.com/users/brunsgaard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunsgaard/subscriptions","organizations_url":"https://api.github.com/users/brunsgaard/orgs","repos_url":"https://api.github.com/users/brunsgaard/repos","events_url":"https://api.github.com/users/brunsgaard/events{/privacy}","received_events_url":"https://api.github.com/users/brunsgaard/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-12T19:46:09Z","updated_at":"2016-05-13T21:02:53Z","closed_at":"2016-05-13T21:02:53Z","body":"@jparyani Are these numbers expected? I am surprised that Msgpack is soo much faster than Cap'n Proto. The benchmark code is available [here](https://gist.github.com/brunsgaard/1291b8bfd02c4d0df2e706290c96ce0a) and the results below is obtained with Python 3.5.1 on FreeBSD.\r\n\r\n```\r\nTesting Msgpack:\r\nbuild datastructure:   1097 ms\r\nserialize:             6836 ms\r\ndeserialize:           3008 ms\r\ntotaltime:            10942 ms\r\nsize:                 72.48 MB\r\n\r\nTesting Capnp:\r\nbuild datastructure:  68327 ms\r\nserialize:             4610 ms\r\ndeserialize:           1519 ms\r\ntotaltime:            74456 ms\r\nsize:                 70.77 MB\r\n\r\nTesting Protobuf:\r\nbuild datastructure:  59912 ms\r\nserialize:            73065 ms\r\ndeserialize:         100671 ms\r\ntotaltime:           233649 ms\r\nsize:                 41.96 MB\r\n```"},"comment":{"url":"https://api.github.com/repos/jparyani/pycapnp/issues/comments/219158438","html_url":"https://github.com/jparyani/pycapnp/issues/99#issuecomment-219158438","issue_url":"https://api.github.com/repos/jparyani/pycapnp/issues/99","id":219158438,"user":{"login":"jparyani","id":1595880,"avatar_url":"https://avatars.githubusercontent.com/u/1595880?v=3","gravatar_id":"","url":"https://api.github.com/users/jparyani","html_url":"https://github.com/jparyani","followers_url":"https://api.github.com/users/jparyani/followers","following_url":"https://api.github.com/users/jparyani/following{/other_user}","gists_url":"https://api.github.com/users/jparyani/gists{/gist_id}","starred_url":"https://api.github.com/users/jparyani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jparyani/subscriptions","organizations_url":"https://api.github.com/users/jparyani/orgs","repos_url":"https://api.github.com/users/jparyani/repos","events_url":"https://api.github.com/users/jparyani/events{/privacy}","received_events_url":"https://api.github.com/users/jparyani/received_events","type":"User","site_admin":false},"created_at":"2016-05-13T21:02:53Z","updated_at":"2016-05-13T21:02:53Z","body":"It's worth noting that msgpack is doing something very different here. It is \"just\" serializing a python dictionary object into essentially a binary json blob. It has no type checking, no schema defined object that you can inspect at runtime, no default values, etc. Essentially, if you added all of that stuff on, I'd expect msgpack to perform closer to pycapnp. Msgpack would probably still be faster, since they've put a ton of time and effort into optimization, whereas I've only had time to fix up the bigger slowdowns that I can find in pycapnp.\r\n\r\nAlso, worth noting a couple of speedups to pycapnp for your benchmark:\r\n```python\r\n\r\nimport capnp\r\nimport addressbook_capnp\r\nMOBILE_TYPE = addressbook_capnp.Person.PhoneNumber.Type.mobile # This is a number under the hood\r\n\r\nn = 1000\r\naddresses = addressbook_capnp.AddressBook.new_message()\r\npeople = addresses.init('people', n)\r\nfor alice in people: # you can iterate over pycapnp lists, and its actually faster than the alternative\r\n    alice.id = 123\r\n    alice.name = 'Alice'\r\n    alice.email = 'alice@example.com'\r\n    alicePhone = alice.init('phones', 1)[0] # accessing the [0] element twice is inefficient\r\n    alicePhone.number = \"555-1212\"\r\n    alicePhone.type = MOBILE_TYPE\r\n```"}}