{"id":15665238,"url":"https://github.com/jeromewu/wasm-perf","last_synced_at":"2025-05-06T19:43:29.840Z","repository":{"id":74168374,"uuid":"529078650","full_name":"jeromewu/wasm-perf","owner":"jeromewu","description":"Explore how to achieve maximum performance in WebAssembly","archived":false,"fork":false,"pushed_at":"2022-09-01T13:41:06.000Z","size":12,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T02:13:48.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeromewu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-08-26T01:52:01.000Z","updated_at":"2024-12-07T08:06:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0f2c27c-9a71-4c9d-8c0c-495f19892fc6","html_url":"https://github.com/jeromewu/wasm-perf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromewu%2Fwasm-perf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromewu%2Fwasm-perf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromewu%2Fwasm-perf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromewu%2Fwasm-perf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeromewu","download_url":"https://codeload.github.com/jeromewu/wasm-perf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252755972,"owners_count":21799403,"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","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-03T13:45:29.351Z","updated_at":"2025-05-06T19:43:29.814Z","avatar_url":"https://github.com/jeromewu.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebAssembly Performance\n\nExplore how to achieve maximum performance in WebAssembly.\n\nFull post: [https://jeromewu.github.io/improving-performance-using-webassembly-simd-intrinsics/](https://jeromewu.github.io/improving-performance-using-webassembly-simd-intrinsics/)\n\n## Setup\n\nWe benchmark the performance by measuring time to complete 10,000 times of two\n64 x 64 matrix multiplication with various implementation and flags:\n\n**Implementation**:\n\n- [mul_mats.js](./mul_mats.js): JavaScript version\n- [mul_mats.c](./mul_mats.c): C version\n- [mul_mats_intrin.c](./mul_mats_intrin.c): C version with SIMD intrinsics\n\n**Flags**:\n\n- `-O3`: optimize code and enable vectorization\n- `-msimd128`: enable SIMD 128 optimization\n\n## Performance\n\n**Environment**:\n\n- Hardware\n  - CPU: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz\n  - RAM: 16 GB\n- Software\n  - Linux Kernel: 5.19.1-3-MANJARO\n  - NodeJS: v16.16.0\n  - Emscripten: 3.1.18\n  - GCC: 12.2.0\n\nHere we use mul_mats.js as baseline to compare the speed / time.\n\n| Implementation | Flags | Time |\n| -------------- | ----- | ---- |\n| mul_mats.js | | 5.768s (+-0%) |\n| mul_mats-wasm.js | | 6.865s (+19%) |\n| mul_mats-wasm-simd.js | -msimd128 | 6.964s (+21%) |\n| mul_mats_intrin-wasm-simd.js | -msimd128 | 4.718s (-18%) |\n| mul_mats-wasm-O3.js | -O3 | 2.012s (-65%) |\n| mul_mats-wasm-O3-simd.js | -O3 -msimd128 | 0.278s (-95.2%) |\n| **mul_mats_intrin-wasm-simd-O3.js** | **-O3 -msimd128** | **0.245s (-95.8%)** |\n| mul_mats (gcc) | | 7.697s (+33%) |\n| mul_mats-O3 (gcc) | -O3 | 0.401s (-93%) |\n| mul_mats-O3-avx (gcc) | -O3 -mavx2 | 0.119s (-98%) |\n\nUse SIMD intrinsics with `-O3` and `-msimd128` flags can be **95.8%** faster than pure\nJavaScript implementation. :tada:\n\n## Try it\n\nTo build binaries, you need to install Docker 19.03+ and run:\n\n```bash\nmake\n```\n\nYou should find all binaries in `dist/` folder.\n\nTo run all of them, simply hit:\n\n```bash\nmake run-all\n```\n\n\u003e Some of the execution might failed you are NOT using Linux, check\n\u003e [Makefile](./Makefile) to see how to run a specific case.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromewu%2Fwasm-perf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeromewu%2Fwasm-perf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromewu%2Fwasm-perf/lists"}