Title: Optinally wrap msgpack_object instead of converting to V8 object · Issue #40 · msgpack/msgpack-node · GitHub
Open Graph Title: Optinally wrap msgpack_object instead of converting to V8 object · Issue #40 · msgpack/msgpack-node
X Title: Optinally wrap msgpack_object instead of converting to V8 object · Issue #40 · msgpack/msgpack-node
Description: Currently msgpack.unpack(), converts the msgpack_object from C/C++ lib into a V8 object visiting the msgpack_object entirely with recursion. Such an approach is known to be ~ 3.5 times slower than JSON.parse(). I could get approximately ...
Open Graph Description: Currently msgpack.unpack(), converts the msgpack_object from C/C++ lib into a V8 object visiting the msgpack_object entirely with recursion. Such an approach is known to be ~ 3.5 times slower than ...
X Description: Currently msgpack.unpack(), converts the msgpack_object from C/C++ lib into a V8 object visiting the msgpack_object entirely with recursion. Such an approach is known to be ~ 3.5 times slower than ...
Opengraph URL: https://github.com/msgpack/msgpack-node/issues/40
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Optinally wrap msgpack_object instead of converting to V8 object","articleBody":"Currently `msgpack.unpack()`, converts the `msgpack_object` from C/C++ lib into a V8 object visiting the `msgpack_object` entirely with recursion.\r\nSuch an approach is known to be ~ 3.5 times [slower](https://github.com/msgpack/msgpack-node#performance) than `JSON.parse()`. I could get approximately the same performance on nodejs 7.5 with msgpack 1.0.2.\r\n\r\nIn `msgpack.cc`, the recursive implementation of `msgpack_to_v8` repeatedly calls `Nan::New`.\r\nBuilding the V8 object is the most expensive part and disabling V8 object creation (C library `msgpack_unpack`) still being called, I could get encouraging numbers:\r\n\r\n`json: 723.140ms\r\nmsgpack: 458.431ms`\r\n\r\nmedian out of 10 runs of:\r\n\r\n```javascript\r\nconsole.time('json');\r\nvar sj = JSON.stringify(data);\r\nfor (let i = 0; i \u003c 500000; i++) {\r\n JSON.parse(sj);\r\n}\r\nconsole.timeEnd('json');\r\nvar sj = msgpack.pack(data);\r\nconsole.time('msgpack');\r\nfor (let i = 0; i \u003c 500000; i++) {\r\n msgpack.unpack(sj);\r\n}\r\nconsole.timeEnd('msgpack');\r\n```\r\n\r\nsuggesting that most of the time is spent to build a V8 object.\r\n\r\nIn some use cases where the full object is not needed or not repeatedly accessed, better performance could be achieved wrapping the `msgpack_object` struct within a V8 object with getters of computed property names (not sure how transparent that can be).\r\n\r\nIf an `msgpack_object` representing:\r\n\r\n```javascript\r\nvar o = {\"a\" : 1, \"b\" : 2, \"c\" : [1, 2, 3]};\r\n```\r\n\r\nis given, `o.c[1]` only creates and returns a number instead of the full object structure.\r\nAssumption is to have less overhead and performance comparable to direct use of C library.\r\nWas this ever tried? Does it make sense at all?","author":{"url":"https://github.com/comick","@type":"Person","name":"comick"},"datePublished":"2017-02-26T13:59:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/40/msgpack-node/issues/40"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:133f1efd-da48-23ee-fa49-5c2ed28af8f6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7BA:8D4A2:173131D:1DD1A8A:698FF12C |
| html-safe-nonce | 6ab288572c23b1b79a494bfe666215872d3e80f147b5318503b2f4eff53798d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0JBOjhENEEyOjE3MzEzMUQ6MUREMUE4QTo2OThGRjEyQyIsInZpc2l0b3JfaWQiOiI1ODcyODU1NTYxMjUxMzIwMTA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4421e1a78a8396c4e7229959845a06057922a19073bc84ff5b5e6d6ec99b045c |
| hovercard-subject-tag | issue:210320137 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/msgpack/msgpack-node/40/issue_layout |
| twitter:image | https://opengraph.githubassets.com/57594c4d72ba3d3ece6e402221bc1fe7ccd66b4d1cc7d8be2c767e7413343e21/msgpack/msgpack-node/issues/40 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/57594c4d72ba3d3ece6e402221bc1fe7ccd66b4d1cc7d8be2c767e7413343e21/msgpack/msgpack-node/issues/40 |
| og:image:alt | Currently msgpack.unpack(), converts the msgpack_object from C/C++ lib into a V8 object visiting the msgpack_object entirely with recursion. Such an approach is known to be ~ 3.5 times slower than ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | comick |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/msgpack/msgpack-node git https://github.com/msgpack/msgpack-node.git |
| octolytics-dimension-user_id | 198264 |
| octolytics-dimension-user_login | msgpack |
| octolytics-dimension-repository_id | 7430783 |
| octolytics-dimension-repository_nwo | msgpack/msgpack-node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7430783 |
| octolytics-dimension-repository_network_root_nwo | msgpack/msgpack-node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width