{"action":"created","issue":{"url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/129","repository_url":"https://api.github.com/repos/alexhultman/uWebSockets","labels_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/129/comments","events_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/129/events","html_url":"https://github.com/alexhultman/uWebSockets/issues/129","id":157281383,"number":129,"title":"Optimize memory usage of JavaScript code","user":{"login":"alexhultman","id":3397140,"avatar_url":"https://avatars.githubusercontent.com/u/3397140?v=3","gravatar_id":"","url":"https://api.github.com/users/alexhultman","html_url":"https://github.com/alexhultman","followers_url":"https://api.github.com/users/alexhultman/followers","following_url":"https://api.github.com/users/alexhultman/following{/other_user}","gists_url":"https://api.github.com/users/alexhultman/gists{/gist_id}","starred_url":"https://api.github.com/users/alexhultman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexhultman/subscriptions","organizations_url":"https://api.github.com/users/alexhultman/orgs","repos_url":"https://api.github.com/users/alexhultman/repos","events_url":"https://api.github.com/users/alexhultman/events{/privacy}","received_events_url":"https://api.github.com/users/alexhultman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/alexhultman/uWebSockets/labels/help%20wanted","name":"help wanted","color":"159818"},{"url":"https://api.github.com/repos/alexhultman/uWebSockets/labels/js","name":"js","color":"1d76db"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-27T20:05:42Z","updated_at":"2016-05-28T18:19:26Z","closed_at":null,"body":"Longstanding issue. I need someone who is an absolute expert at JavaScript who can help me optimize the JavaScript code. It consumes extreme amounts of memory per socket compared to the native server. There is absolutely no reason for the binding to bloat the server with 95% of its memory usage alone (this is purely insane).\r\n\r\nIf you want to point me in the right direction on how to minimize memory usage, please do."},"comment":{"url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/comments/222322309","html_url":"https://github.com/alexhultman/uWebSockets/issues/129#issuecomment-222322309","issue_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/129","id":222322309,"user":{"login":"alexhultman","id":3397140,"avatar_url":"https://avatars.githubusercontent.com/u/3397140?v=3","gravatar_id":"","url":"https://api.github.com/users/alexhultman","html_url":"https://github.com/alexhultman","followers_url":"https://api.github.com/users/alexhultman/followers","following_url":"https://api.github.com/users/alexhultman/following{/other_user}","gists_url":"https://api.github.com/users/alexhultman/gists{/gist_id}","starred_url":"https://api.github.com/users/alexhultman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexhultman/subscriptions","organizations_url":"https://api.github.com/users/alexhultman/orgs","repos_url":"https://api.github.com/users/alexhultman/repos","events_url":"https://api.github.com/users/alexhultman/events{/privacy}","received_events_url":"https://api.github.com/users/alexhultman/received_events","type":"User","site_admin":false},"created_at":"2016-05-28T18:19:26Z","updated_at":"2016-05-28T18:19:26Z","body":"So I think I know why this is happening now, at least it makes sense.\r\n\r\nThe `uwsHttp` option makes use of the built-in uws HTTP server (native code, does not spill memory to the GC). In other cases, the Node.js HTTP server is used (JS code, makes heavy use of GC, spills destroyed sockets to be reclaimed by the GC).\r\n\r\nThe HTTP server is only used to receive the HTTP upgrade header, so the memory usage should be identical after this (which is the case according to heapdumps). I'm pretty sure the heapdumps only show reachable memory, that is, it doesn't show memory that is to be reclaimed by the GC (this would make no sense to show, I guess).\r\n\r\nBy adding the option `--gc_global` to node, the memory usage is reduced from ~550mb to 290 - 320mb. This is a lot more reasonable, even if it still is not as good as when using the `uwsHttp` option (but pretty damn close).\r\n\r\nIt seems, the GC sucks more than I thought. The reason for the `uwsHttp` option being more efficient in memory seems to be simply because it never really makes any use of the GC at all."}}
{"actor":{"display_login":"alexhultman"}}