{"id":16701495,"url":"https://github.com/ansd/packet-parser","last_synced_at":"2025-08-31T14:03:59.837Z","repository":{"id":99680498,"uuid":"504603750","full_name":"ansd/packet-parser","owner":"ansd","description":"Compare performance of Erlang's socket option {packet, 0} vs {packet, 4}","archived":false,"fork":false,"pushed_at":"2022-06-24T14:09:31.000Z","size":229,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T06:41:51.021Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ansd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-17T16:31:44.000Z","updated_at":"2022-06-20T15:18:32.000Z","dependencies_parsed_at":"2023-04-01T13:05:23.382Z","dependency_job_id":null,"html_url":"https://github.com/ansd/packet-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ansd/packet-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansd%2Fpacket-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansd%2Fpacket-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansd%2Fpacket-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansd%2Fpacket-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ansd","download_url":"https://codeload.github.com/ansd/packet-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansd%2Fpacket-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272988919,"owners_count":25026961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T18:44:18.741Z","updated_at":"2025-08-31T14:03:59.821Z","avatar_url":"https://github.com/ansd.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Performance comparison of Erlang socket option `{packet, 0}` and `{packet, 4}`\n\nHere, we compare peformance of **receiving** from a TCP socket using \n1. `{packet, 0}` and parsing the packets in the application code vs.\n2. `{packet, 4}` having the Erlang runtime parse the packet for us.\n\nIn both cases, we want to end up with a single binary per packet.\n\n### Usage\nStart server with only a single scheduler:\n```\nerlc packet.erl \u0026\u0026 erl +S 1 +SDcpu 1 +SDio 1\n1\u003e packet:server0(). %% compare against packet:server4()\n```\n\nIn a second Erlang shell, start the client.\nGive it more schedulers since we do not want the client to be the bottleneck.\n```\nerl +S 4 +SDcpu 4 +SDio 10\n1\u003e packet:client().\n```\n\n### Results\nExecuted on an Intel NUC 11 with 8 cores and 32GB of RAM running Ubuntu 22.04 and Erlang 25.0.1.\n\nThe columns show number of messages received across 2 different runs of 30 seconds each.\n(For example `26,800,000 - 27,800,000` means in one of the 30 second runs, the server received 26,800,000 messages in the other 30 second run it received 27,800,000 messages.)\n\n| MSG_BYTES           | [{packet, 0}, {active, once}] | [{packet, 4}, {active, once}] | [{packet, 4}, {active, 40}] | [{packet, 4}, {active, true}]|\n| ------------------- | ----------------------------- | ----------------------------- | ----------------------------| -----------------------------|\n| 10                  | 26,800,000 - 27,800,000 | 27,000,000 - 28,700,000 | 34,330,000 - 36,730,000 | 29,330,000 - 31,270,000 |\n| 1,000               | 26,390,000 - 27,100,000 | 25,100,000 - 26,300,000 | | |\n| 1,400               | 24,280,000 - 25,520,000 | 23,170,000 - 25,030,000 | 8,950,000 - 9,100,000 -  | 15,670,000 - 16,690,000 |\n| 1,500               | 23,290,000 - 24,890,000 | 4,290,000 - 4,300,000 | 6,230,000 - 6,380,000 | 9,470,000 - 9,260,000 |\n| 2,000               | 19,190,000 - 19,360,000 | 4,110,000 - 4,200,000 | | |\n| 3,000               | 14,130,000 - 14,370,000 | 3,910,000 - 3,940,000 | | |\n| 5,000               | 8,770,000 - 9,070,000   | 3,990,000 - 4,110,000 | | |\n| 10,000              | 4,480,000 - 4,690,000   | 3,630,000 - 3,660,000 | | |\n| 100,000             | 488,000 - 493,000       | 892,000 - 892,000 | | |\n| 1,000,000,000 (1GB) | 16 - 16                 | 70 - 72 | 73 - 74 | 77 - 77 |\n\n### Discussion\nSee https://erlangforums.com/t/performance-of-socket-option-packet-4/1562\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansd%2Fpacket-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fansd%2Fpacket-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansd%2Fpacket-parser/lists"}