{"id":333586,"date":"2022-05-24T15:01:30","date_gmt":"2022-05-24T15:01:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333586"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333586","title":{"rendered":"<span>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443. \u0427\u0430\u0441\u0442\u044c 2: SIMD + \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/post\/663936\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/oo\/zp\/ie\/oozpieh1_7uno_ju9jynjaiikia.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/oo\/zp\/ie\/oozpieh1_7uno_ju9jynjaiikia.jpeg\" data-blurred=\"true\"\/><\/div>\n<p><\/a><br \/>  \u0421\u043d\u043e\u0432\u0430 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/662363\/\">\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0438 \u0444\u0440\u0430\u043a\u0442\u0430\u043b \u041d\u044c\u044e\u0442\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e WebAssembly \u043d\u0430 Rust. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c <abbr title=\"Single instruction, multiple data\">SIMD<\/abbr> \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0412\u0436\u0438\u0432\u0443\u044e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/alordash.github.io\/newton-fractal\/www\/\">\u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u0435\u043c\u043e<\/a>. \u041d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043e\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 ~900% \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 wasm.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0422\u0435\u043c, \u043a\u0442\u043e \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0441\u043b\u044b\u0448\u0438\u0442 \u043e WebAssembly \u043d\u0430 Rust \u0438\u043b\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/662363\/\">\u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c<\/a>. \u0422\u0430\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0435 \u041d\u044c\u044e\u0442\u043e\u043d\u0430.<\/p>\n<h2><font color=\"#3AC1EF\">\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"#simd\">\u041a\u043e\u0440\u043e\u0442\u043a\u043e \u043e SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445<\/a><\/li>\n<li><a href=\"#rust_wasm_simd\">SIMD \u0432 Rust-<abbr title=\"WebAssembly\">WASM<\/abbr><\/a><\/li>\n<li><a href=\"#browser_multithreading\">\u041c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445<\/a><\/li>\n<li><a href=\"#conclusion\">\u0412\u044b\u0432\u043e\u0434<\/a><\/li>\n<\/ul>\n<p>  <a name=\"simd\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">\u041a\u043e\u0440\u043e\u0442\u043a\u043e \u043e SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445<\/font><\/h2>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/SIMD\">SIMD \u2014 single instruction, multiple data<\/a>. SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u0440\u0430\u0437\u0443 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0432\u043e\u0441\u0435\u043c\u044c \u0447\u0438\u0441\u0435\u043b \u0437\u0430 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439.<\/p>\n<p>  \u041d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0438\u0442 64-, 128-, 256-, \u0438 \u0443\u0436\u0435 \u0434\u0430\u0436\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/AVX-512\">512-\u0431\u0438\u0442\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440<\/a>, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c, \u0438 \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SIMD \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0432\u0435\u043a\u0442\u043e\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b. \u0414\u043b\u044f \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0441\u044c\u043c\u0438 32-\u0431\u0438\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u0432\u0430 128-\u0431\u0438\u0442\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u0430: \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e 4 \u0447\u0438\u0441\u043b\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0445:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/cy\/p_\/kn\/cyp_kn8-a_7lec4o-xggbsfc1us.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/cy\/p_\/kn\/cyp_kn8-a_7lec4o-xggbsfc1us.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SIMD&#8217;\u043e\u0432 \u0440\u0430\u0432\u0435\u043d \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043e\u0434\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435: 128 \/ 32 = 4). \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043e\u0434\u0438\u043d \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c\u0438, \u0430 \u0442\u0435, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u043c\u0438.<\/p>\n<p>  <a name=\"rust_wasm_simd\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">SIMD \u0432 Rust-WASM<\/font><\/h2>\n<p>  \u0412 WebAssembly <a href=\"https:\/\/v8.dev\/features\/simd\">\u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430<\/a> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 128-\u0431\u0438\u0442\u043d\u044b\u0445 SIMD \u043a\u043e\u043c\u0430\u043d\u0434. \u0412 Rust-wasm \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0432\u0441\u0435\u0445 SIMD \u043a\u043e\u043c\u0430\u043d\u0434 \u0438\u0437 wasm. \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0445 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d <a href=\"https:\/\/doc.rust-lang.org\/core\/arch\/wasm32\/index.html\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 Rust-wasm, \u043d\u0443\u0436\u043d\u043e \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 lib.rs \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>#![cfg(target_arch = \"wasm32\")]<\/code>. \u041e\u043d \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 wasm32, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u0442\u0443\u0434\u0430.<\/p>\n<pre><code class=\"rust\">#![cfg(target_arch = \"wasm32\")]  use geometry::{transform_point_to_plot_scale, PlotScale}; use memory_management::create_u32_buffer; ...<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/font><\/h3>\n<p>  \u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 SIMD \u0432 wasm \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u044e \u0447\u0438\u0441\u0435\u043b \u0438\u0437 \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 \u0442\u0440\u0435\u0442\u0438\u0439. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e), \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u2014 \u043f\u043e \u0447\u0435\u0442\u044b\u0440\u0435 (\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e).<\/p>\n<p>  \u0421\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 \u0442\u0440\u0435\u0442\u0438\u0439. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432.<\/p>\n<pre><code class=\"rust\">#[wasm_bindgen] pub fn sum_numbers_scalar(arr1: Vec&lt;f32>, arr2: Vec&lt;f32>) -> Vec&lt;f32> {     let length = arr1.len();     let mut result = vec![0f32; length];     for i in 0..length {         result[i] = arr1[i] + arr2[i];     }     return result; }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u00ab\u0445\u0430\u043a\u0430\u043c\u00bb. \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 <code><a href=\"https:\/\/doc.rust-lang.org\/std\/vec\/struct.Vec.html\">Vec&lt;T><\/a><\/code> \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043a\u0443\u0447\u0435 \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c. \u041c\u044b \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>f32<\/code> \u043a\u0430\u043a \u043e\u0434\u0438\u043d SIMD-\u0432\u0435\u043a\u0442\u043e\u0440 <code>v128<\/code>. \u0417\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code><a href=\"https:\/\/doc.rust-lang.org\/core\/arch\/wasm32\/fn.f32x4_add.html\">f32x4_add<\/a><\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 f32 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f f32. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u0433\u043e\u0432, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043f\u043b\u044e\u0441, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0438 \u043c\u0438\u043d\u0443\u0441, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0442\u0435\u043d \u0447\u0435\u0442\u044b\u0440\u0451\u043c, \u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u041d\u043e \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043b-\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u0440\u0430\u0442\u043d\u043e 4. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f (\u0441 \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445):<\/p>\n<pre><code class=\"rust\">\/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b use std::arch::wasm32::*; \/\/ \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b #[target_feature(enable = \"simd128\")] #[wasm_bindgen] pub fn sum_numbers_vector(arr1: Vec&lt;f32>, arr2: Vec&lt;f32>) -> Vec&lt;f32> {     let length = arr1.len();     let mut result = vec![0f32; length];      \/\/ \u0411\u0435\u0440\u0451\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 (f32) \u0438 \u043a\u0430\u0441\u0442\u0443\u0435\u043c \u0438\u0445 \u043a \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c \u043d\u0430 v128     let result_vec_ptr = result.as_mut_ptr() as *mut v128;     let arr1_vec_ptr = arr1.as_ptr() as *mut v128;     let arr2_vec_ptr = arr2.as_ptr() as *mut v128;      \/\/ \u041a\u043e\u0434 \u043f\u043e\u043c\u0435\u0447\u0435\u043c \u043e\u043f\u0430\u0441\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e     unsafe {         \/\/ \u0428\u0430\u0433\u043e\u0432 \u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435         for i in 0..(length \/ 4) {             \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f ptr.add(i) \u0441\u043c\u0435\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c ptr \u043d\u0430 i * sizeof(T), \u0433\u0434\u0435 T \u2014 \u0442\u0438\u043f             \/\/ \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e v128.             *result_vec_ptr.add(i) =             f32x4_add(                 *arr1_vec_ptr.add(i),                 *arr2_vec_ptr.add(i)             );         }     }     return result; }<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0438\u0445 SIMD \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">JS \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import {sum_numbers_scalar, sum_numbers_vector } from '..\/pkg\/project_name.js';  const TEST_SUM_LENGTH = 10 * 4; const TEST_SUM_COEF = 100; \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432, \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 function createRandomArray(length, coef) {     return Array.from(         { length },         () => {             return (Math.random() - 0.5) * 2 * coef;         }     ); }  function testSum() {     let arr1 = createRandomArray(TEST_SUM_LENGTH, TEST_SUM_COEF);     let arr2 = createRandomArray(TEST_SUM_LENGTH, TEST_SUM_COEF);     let sumScalar = sum_numbers_scalar(arr1, arr2);     let sumVector = sum_numbers_vector(arr1, arr2);     console.log('sumScalar :>> ', sumScalar);     console.log('sumVector :>> ', sumVector); }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/qn\/rj\/a_\/qnrja_0qrmm9hvtckdgc6rg2hgi.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/qn\/rj\/a_\/qnrja_0qrmm9hvtckdgc6rg2hgi.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">JS \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import {sum_numbers_scalar, sum_numbers_vector } from '..\/pkg\/project_name.js';  function testSum() {     let arr1 = createRandomArray(TEST_SUM_LENGTH, TEST_SUM_COEF);     let arr2 = createRandomArray(TEST_SUM_LENGTH, TEST_SUM_COEF);      let scalarStart = performance.now();     let sumScalar = sum_numbers_scalar(arr1, arr2);     let scalarEnd = performance.now();      let vectorStart = performance.now();     let sumVector = sum_numbers_vector(arr1, arr2);     let vectorEnd = performance.now();      let scalarElapsed = (scalarEnd - scalarStart).toFixed(2);     let vectorElapsed = (vectorEnd - vectorStart).toFixed(2);      console.log(`Elapsed: scalar: ${scalarElapsed}ms, vector: ${vectorElapsed}ms`); }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0418 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438\u2026 \u0447\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/r_\/dc\/ar\/r_dcar6klmjfrx_wq8h27kxh7ig.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/r_\/dc\/ar\/r_dcar6klmjfrx_wq8h27kxh7ig.png\"\/><\/p>\n<p>  \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043e \u0442\u043e\u0433\u043e \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0448 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d: \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0443\u043c\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0445 \u043f\u0440\u044f\u043c\u043e \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432:<\/p>\n<pre><code class=\"rust\">#[target_feature(enable = \"simd128\")] #[wasm_bindgen] pub fn sum_numbers_vector(mut arr1: Vec&lt;f32>, arr2: Vec&lt;f32>) -> Vec&lt;f32> {     let length = arr1.len();     \/\/ let mut result = vec![0f32; length];      \/\/ let result_vec_addr = result.as_mut_ptr() as *mut v128;     let arr1_vec_addr = arr1.as_mut_ptr() as *mut v128;     let arr2_vec_addr = arr2.as_ptr() as *mut v128;      unsafe {         for i in 0..(length \/ 4) {             \/\/ \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432             *arr1_vec_addr.add(i) = f32x4_add(*arr1_vec_addr.add(i), *arr2_vec_addr.add(i));         }     }     return arr1; }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0435\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0442\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u044b:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ky\/f5\/2y\/kyf52ywi9spgb617i5d_i36fzjs.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/ky\/f5\/2y\/kyf52ywi9spgb617i5d_i36fzjs.png\"\/><\/p>\n<p>  \u041d\u043e \u043d\u0430\u043c \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f SIMD! \u0427\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 0 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"rust\"># \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 Cargo.toml [profile.release] opt-level = 0<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0421\u043e\u0431\u0435\u0440\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u044d\u0442\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tbody>\n<tr>\n<td>Chrome scalar, ms<\/td>\n<td>Chrome vector, ms<\/td>\n<td>Chrome speed boost<\/td>\n<td>Firefox scalar, ms<\/td>\n<td>Firefox vector, ms<\/td>\n<td>Firefox speed boost<\/td>\n<\/tr>\n<tr>\n<td>261<\/td>\n<td>55<\/td>\n<td>474%<\/td>\n<td>173<\/td>\n<td>41<\/td>\n<td>421%<\/td>\n<\/tr>\n<tr>\n<td>254<\/td>\n<td>54<\/td>\n<td>470%<\/td>\n<td>173<\/td>\n<td>36<\/td>\n<td>480%<\/td>\n<\/tr>\n<tr>\n<td>261<\/td>\n<td>57<\/td>\n<td>457%<\/td>\n<td>174<\/td>\n<td>36<\/td>\n<td>483%<\/td>\n<\/tr>\n<tr>\n<td>258<\/td>\n<td>52<\/td>\n<td>496%<\/td>\n<td>173<\/td>\n<td>38<\/td>\n<td>455%<\/td>\n<\/tr>\n<tr>\n<td>256<\/td>\n<td>54<\/td>\n<td>474%<\/td>\n<td>174<\/td>\n<td>37<\/td>\n<td>470%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u0440\u043e\u0441\u043b\u0430 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0432 4.7 \u0440\u0430\u0437\u0430, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435<\/font><\/h3>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u0443 SIMD \u043a\u043e\u043c\u0430\u043d\u0434 \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2014 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u0437\u0430\u0431\u043b\u0430\u0433\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u043a\u0430\u0441\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9aa\/e08\/704\/9aae087046a60218262bab4a00522adc.svg\" alt=\"$N$\" data-tex=\"inline\"\/> \u0447\u0438\u0441\u0435\u043b. \u0412\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0435 \u0438\u0445 \u043d\u0430 \u0441\u0430\u043c\u0438\u0445 \u0441\u0435\u0431\u044f <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/117\/5ef\/b8b\/1175efb8bee3e7b48fb17482fa0cd6e7.svg\" alt=\"$K$\" data-tex=\"inline\"\/> \u0440\u0430\u0437. \u0415\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ffe\/7fb\/ad9\/ffe7fbad9e8131a5d99bf8feffe52f62.svg\" alt=\"$L$\" data-tex=\"inline\"\/>, \u0442\u043e \u0432\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0435 \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0435 \u043d\u043e\u043c\u0435\u0440 \u044d\u0442\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"rust\">#[wasm_bindgen] fn process_numbers(mut numbers: Vec&lt;f32>, N: usize, K: usize, L: f32) -> Vec&lt;usize> {     let mut iterations = vec![usize::MAX; N];     for i in 0..N {         \/\/ \u041f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443         for j in 0..K {     \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0438\u0441\u043b\u0430 K \u0440\u0430\u0437             numbers[i] *= numbers[i];             if numbers[i] > L {                 iterations[i] = j; \/\/ \u0417\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430                 break;             }         }     }     return iterations; }<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0443 \u043c\u044b \u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430 \u041d\u044c\u044e\u0442\u043e\u043d\u0430. \u0422\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043d\u0438\u043c\u0438. <\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e SIMD \u043a\u043e\u043c\u0430\u043d\u0434. \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b \u0437\u0430 \u0440\u0430\u0437, \u0442\u043e \u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0446\u0438\u043a\u043b \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0447\u0438\u0441\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u043d\u0435\u043f\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441 \u0442\u0435\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u0430\u0436\u0434\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 simd-\u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f: \u0430) \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u043e\u043b-\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0431) \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0432 simd-\u0432\u0435\u043a\u0442\u043e\u0440, \u0432) \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u0447\u0438\u0441\u0435\u043b \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0435. <\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e, \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">#[wasm_bindgen] #[target_feature(enable = \"simd128\")] pub fn simd_process_numbers(mut numbers: Vec&lt;f32>, N: usize, K: usize, L: f32) -> Vec&lt;usize> {     let mut iterations = vec![usize::MAX; N];     let numbers_ptr = numbers.as_mut_ptr() as *mut v128;        \/\/ [[n1, n2, n3, n4], ...]     let iterations_ptr = iterations.as_mut_ptr() as *mut v128;  \/\/ [[i1, i2, i3, i4], ...]     let _L = f32x4_splat(L);                                    \/\/ [L, L, L, L]     for i in 0..(N \/ 4) {                                       \/\/ \u041f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043a\u0435 \u0447\u0438\u0441\u0435\u043b         for j in 0..K {                                         \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043a\u0438 \u0447\u0438\u0441\u0435\u043b K \u0440\u0430\u0437             unsafe {                 let _iteration = u32x4_splat(j as u32);         \/\/ [j, j, j, j]                 let num_ptr = numbers_ptr.add(i);               \/\/ [n1, n2, n3, n4]                 let iter_ptr = iterations_ptr.add(i);           \/\/ [i1, i2, i3, i4]                  *num_ptr = f32x4_mul(*num_ptr, *num_ptr);       \/\/ [n1 * n1, ..., n4 * n4]                 let _gt_check = f32x4_gt(*num_ptr, _L);         \/\/ [n1 > L, ..., n4 > L]                  *iter_ptr = v128_bitselect(                     \/\/ \u0417\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b, \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0432\u0448\u0438\u0445 \u043f\u043e\u0440\u043e\u0433                     u32x4_min(_iteration, *iter_ptr),           \/\/ \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f: [min(i1, j), ..., min(i4, j)]                     *iter_ptr,                                  \/\/ \u0441\u0442\u0430\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f                     _gt_check,                 );                 if i32x4_all_true(_gt_check) {                  \/\/ \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 [n1, n2, n3, n4] \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c L,                     break;                                      \/\/ \u0442\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c \u0446\u0438\u043a\u043b                 }             }         }     }     return iterations; }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0435\u0435. \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0432 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>v128_bitselect<\/code>: \u043e\u043d\u0430 \u0431\u0435\u0440\u0451\u0442 \u0431\u0438\u0442\u044b \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0435\u0441\u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0442\u044b \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0440\u0430\u0432\u043d\u044b 1, \u0438\u043d\u0430\u0447\u0435 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u043e\u0432 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"rust\">fn bitselect(bit1: bool, bit2: bool, bit3: bool) {     let bit: bool;     if bit3 {         bit = bit1;     } else {         bit = bit2;     } }<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438, \u0432\u043e\u043e\u0431\u0449\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">JS \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import {process_numbers, simd_process_numbers} from '..\/pkg\/project_name.js';  const TEST_COEF = 2.5; const N = 2 * 4; const K = 6; const L = 1000  function createRandomArray(length, coef) {     return Array.from(         { length },         () => {             return (Math.random() - 0.5) * 2 * coef;         }     ); }  function testNumsProcessing() {     let arr = createRandomArray(N, TEST_COEF);      let scalar = Array.from(process_numbers(arr, N, K, L));     let vector = Array.from(simd_process_numbers(arr, N, K, L));      console.log('scalar :>> ', scalar);     console.log('vector :>> ', vector); }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/f-\/yy\/re\/f-yyrelytu35x1tyuy_obj06cpk.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/f-\/yy\/re\/f-yyrelytu35x1tyuy_obj06cpk.png\"\/><\/p>\n<p>  \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0427\u0442\u043e \u043d\u0430\u0441\u0447\u0451\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438?<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">JS \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import {process_numbers, simd_process_numbers} from '..\/pkg\/project_name.js';  const TEST_COEF = 2.5; const N = 100_000 * 4; const K = 6; const L = 10000  function createRandomArray(length, coef) {     return Array.from(         { length },         () => {             return (Math.random() - 0.5) * 2 * coef;         }     ); }  function testNumsProcessing() {     let arr = createRandomArray(N, TEST_COEF);      let scalarStart = performance.now();     let scalar = Array.from(process_numbers(arr, N, K, L));     let scalarEnd = performance.now();      let vectorStart = performance.now();     let vector = Array.from(simd_process_numbers(arr, N, K, L));     let vectorEnd = performance.now();      let scalarElapsed = (scalarEnd - scalarStart).toFixed(2);     let vectorElapsed = (vectorEnd - vectorStart).toFixed(2);      console.log(`Elapsed: scalar: ${scalarElapsed}ms, vector: ${vectorElapsed}ms`); }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0411\u0435\u0437 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 (opt-level = 0), \u0442\u0435 \u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b 400000, \u0430 \u043d\u0435 8:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/7a\/be\/op\/7abeopcd0b3ri_xdxnkigz7yay4.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/7a\/be\/op\/7abeopcd0b3ri_xdxnkigz7yay4.png\"\/><\/p>\n<p>  \u0412 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 540%. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 <code>opt-level = 3<\/code>, \u0442\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ky\/f5\/2y\/kyf52ywi9spgb617i5d_i36fzjs.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/ky\/f5\/2y\/kyf52ywi9spgb617i5d_i36fzjs.png\"\/>  <\/div>\n<\/p><\/div>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443 \u0432\u0430\u0441 \u0440\u0435\u0437\u043e\u043d\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0410 \u0437\u0430\u0447\u0435\u043c \u0441\u0430\u043c\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SIMD \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u0430\u043c \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c?\u00bb. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0443\u043c\u0435\u0435\u0442 \u0434\u043e \u043d\u0435\u0451 \u0434\u043e\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0430\u043c\u0438\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u043e\u043d\u0443\u0441<\/b>                         <\/p>\n<div class=\"spoiler_text\">\u042d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0438 \u0431\u0435\u0437 \u0446\u0438\u043a\u043b\u043e\u0432. \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/4cc\/fd4\/32e\/4ccfd432ea4f2a64f3a5c8c7378517af.svg\" alt=\"$x$\" data-tex=\"inline\"\/> \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430 \u0441\u0435\u0431\u044f <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/117\/5ef\/b8b\/1175efb8bee3e7b48fb17482fa0cd6e7.svg\" alt=\"$K$\" data-tex=\"inline\"\/> \u0440\u0430\u0437 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6cc\/06f\/660\/6cc06f660ff7cd1bb11a702780a4f7e0.svg\" alt=\"$f(x,K)=x^{2^{K-1}}$\" data-tex=\"display\"\/><\/p>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0443\u0437\u043d\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/fce\/525\/2bd\/fce5252bde946816c2cf744d932890f7.svg\" alt=\"$k$\" data-tex=\"inline\"\/> \u0447\u0438\u0441\u043b\u043e <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/096\/ed7\/65c\/096ed765c8bbbc1f1e34d3b19d3550ed.svg\" alt=\"$X$\" data-tex=\"inline\"\/> \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ffe\/7fb\/ad9\/ffe7fbad9e8131a5d99bf8feffe52f62.svg\" alt=\"$L$\" data-tex=\"inline\"\/>:  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f42\/eea\/128\/f42eea12890a3c2ce201dd6b21da40c2.svg\" alt=\"$X^{2^{k-1}} \\geq L \\\\ 2^{k - 1} \\ln X \\geq \\ln L \\\\ \\\\ 2^{k - 1} \\geq \\frac{\\ln L}{\\ln X} \\\\ (k-1)\\ln 2 \\geq \\ln\\left( \\frac{\\ln L}{\\ln X} \\right) \\\\ k \\geq \\frac{\\ln\\left( \\frac{\\ln L}{\\ln X} \\right)}{\\ln 2} - 1$\" data-tex=\"display\"\/><\/p>\n<p>  \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/fce\/525\/2bd\/fce5252bde946816c2cf744d932890f7.svg\" alt=\"$k$\" data-tex=\"inline\"\/> \u2014 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043e\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u043a:  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ad5\/ba4\/928\/ad5ba49289084cc4131d495911fe767d.svg\" alt=\"$k = \\left \\lceil \\frac{\\ln\\left( \\frac{\\ln L}{\\ln X} \\right)}{\\ln 2} - 1 \\right \\rceil$\" data-tex=\"display\"\/><\/p>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430 \u041d\u044c\u044e\u0442\u043e\u043d\u0430<\/font><\/h3>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430 \u041d\u044c\u044e\u0442\u043e\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"rust\">#[wasm_bindgen] pub fn generate_fractal_image(     roots: JsValue,     roots_colors: JsValue,     plot_scale: &amp;PlotScale,     iterations_count: usize, ) -> *mut [u8; 4] {     let roots: Vec&lt;Complex32> = roots         .into_serde::&lt;Vec&lt;MyComplex32>>()         .unwrap()         .into_iter()         .map(|z| z.into())         .collect();     let roots_colors: Vec&lt;[u8; 4]> = roots_colors.into_serde().unwrap();      let &amp;PlotScale { width, height, .. } = plot_scale;     let (width, height) = (width as usize, height as usize);     let length = width * height;     let image_data = create_u32_buffer(length) as *mut [u8; 4];      for i in 0..length {         let x = i % width;         let y = i \/ width;         let (re, im) = transform_point_to_plot_scale(x as f32, y as f32, &amp;plot_scale);         let z = Complex32 { re, im };          let root_id = get_root_id(z, &amp;roots, iterations_count);         unsafe {             *image_data.add(i) = roots_colors[root_id];         }     }      return image_data; }<\/code><\/pre>\n<p>  \u041f\u043e\u0438\u0441\u043a \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0440\u043d\u044f:<\/p>\n<pre><code class=\"rust\">pub fn get_root_id(mut z: Complex32, roots: &amp;[Complex32], iterations_count: usize) -> usize {     for _ in 0..iterations_count {         let mut sum = Complex32::new(0.0, 0.0);         for (i, root) in roots.iter().enumerate() {             let mut diff = z - root;             let square_norm = diff.norm_sqr();             if square_norm &lt; MIN_DIFF {                 return i;             }             diff.re \/= square_norm;             diff.im \/= -square_norm;             sum += diff;         }         z -= 1.0 \/ sum;     }      let mut min_distance = f32::MAX;     let mut closest_root_id: usize = 0;      for (i, root) in roots.iter().enumerate() {         let distance = (z - root).norm_sqr();         if distance &lt; min_distance {             min_distance = distance;             closest_root_id = i;         }     }     closest_root_id }<\/code><\/pre>\n<p>  \u041e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/662363\/#wasm_scalar\">\u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e<\/a> \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043d\u0438 \u0441\u0442\u0430\u043b\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0430 \u0435\u0449\u0451 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f SIMD-\u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, <s>\u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044f \u0441\u0430\u043c \u043d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a<\/s> \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d \u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u044f \u0432\u044b\u043d\u0435\u0441 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">SIMD: \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\"><a href=\"https:\/\/github.com\/alordash\/newton-fractal\/blob\/1a8471bda76fcf3c7c1d4918c1a07176432350b6\/src\/fractal_plotting.rs#L111-L166\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>.<\/p>\n<pre><code class=\"rust\">#[target_feature(enable = \"simd128\")] pub fn fill_pixels_simd(     roots: Vec&lt;Complex32>,     roots_colors: Vec&lt;u32>,     plot_scale: &amp;PlotScale,     iterations_count: usize,     image_data: *mut (u32, u32, u32, u32),  \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e 4 \u043f\u0438\u043a\u0441\u0435\u043b\u044f ) {     let PlotScale {         x_display_range: width,         y_display_range: height,         ..     } = *plot_scale;     let (w_int, h_int) = (width as usize, height as usize);     let length = w_int * h_int;      \/\/ [width, width, width, width]     let _width = f32x4_splat(width);     unsafe {         let simd_length = length \/ 4;         for i in 0..simd_length {             \/\/ [4i, 4i, 4i, 4i] (\u0442\u0443\u0442 i - \u044d\u0442\u043e \u043d\u0435 \u043c\u043d\u0438\u043c\u0430\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430)             let mut _i = f32x4_splat((4 * i) as f32);             \/\/ [4i + 0, 4i + 1, 4i + 2, 4i + 3]             _i = f32x4_add(_i, f32x4(0.0, 1.0, 2.0, 3.0));             \/\/ [(4i + 0) % width, ..., (4i + 3) % width ]             let _xs = SimdMath::f32x4_mod(_i, _width);      \/\/ \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u0439 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 SIMD \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 - \u043d\u0438\u0436\u0435             \/\/ [\u230a(4i + 0) \/ width\u230b, ..., \u230a(4i + 3) \/ width\u230b]             let _ys = f32x4_floor(f32x4_div(_i, _width));              \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440\u0430 \u043a\u043e\u0440\u043d\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439             let (id0, id1, id2, id3) =                 simd_get_root_id(_xs, _ys, roots.as_ref(), iterations_count, &amp;plot_scale);              \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0446\u0432\u0435\u0442\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439             *(image_data.add(i)) = transmute([                 roots_colors[id0 as usize],                 roots_colors[id1 as usize],                 roots_colors[id2 as usize],                 roots_colors[id3 as usize],             ]);         }         \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043d\u0435\u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u043f\u0430\u0447\u043a\u0438 \u043f\u043e \u0447\u0435\u0442\u044b\u0440\u0435         \/\/ \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438         let image_data_as_u32 = image_data as *mut u32;         for i in (simd_length * 4)..length {             let (x, y) =                 transform_point_to_plot_scale((i % w_int) as f32, (i \/ w_int) as f32, &amp;plot_scale);             *image_data_as_u32.add(i) =                 roots_colors[get_root_id(Complex32::new(x, y), roots.as_ref(), iterations_count)];         }     } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">SIMD: \u043f\u043e\u0438\u0441\u043a \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0440\u043d\u044f<\/b>                         <\/p>\n<div class=\"spoiler_text\"><a href=\"https:\/\/github.com\/alordash\/newton-fractal\/blob\/1a8471bda76fcf3c7c1d4918c1a07176432350b6\/src\/fractal_calculation.rs#L63-L106\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>.<\/p>\n<pre><code class=\"rust\">\/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 4 \u0442\u043e\u0447\u043a\u0438 \u0437\u0430 \u0440\u0430\u0437 #[target_feature(enable = \"simd128\")] pub unsafe fn simd_get_root_id(     _xs: v128,     _ys: v128,     roots: &amp;[Complex32],     iterations_count: usize,     plot_scale: &amp;PlotScale, ) -> (u32, u32, u32, u32) {     let mut _min_distances = SimdMath::_F32_MAX;     let mut _closest_root_ids = SimdMath::_I32_ZERO;      \/\/ \u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0442\u043e\u0447\u043a\u0438     let mut _points1 = f32x4(         f32x4_extract_lane::&lt;0>(_xs),         f32x4_extract_lane::&lt;0>(_ys),         f32x4_extract_lane::&lt;1>(_xs),         f32x4_extract_lane::&lt;1>(_ys),     );     \/\/ \u0412\u0442\u043e\u0440\u044b\u0435 \u0434\u0432\u0435 \u0442\u043e\u0447\u043a\u0438     let mut _points2 = f32x4(         f32x4_extract_lane::&lt;2>(_xs),         f32x4_extract_lane::&lt;2>(_ys),         f32x4_extract_lane::&lt;3>(_xs),         f32x4_extract_lane::&lt;3>(_ys),     );     \/\/ \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u0435\u043a \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     \/\/ \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430     _points1 = simd_transform_point_to_plot_scale(_points1, &amp;plot_scale);     _points2 = simd_transform_point_to_plot_scale(_points2, &amp;plot_scale);     for _ in 0..iterations_count {         \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u041d\u044c\u044e\u0442\u043e\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u0442\u043e\u0447\u0435\u043a.         \/\/ \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043f\u0440\u0435\u0436\u0434\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430!         _points1 = simd_newton_method_approx_for_two_numbers(_points1, &amp;roots);         _points2 = simd_newton_method_approx_for_two_numbers(_points2, &amp;roots);     }     \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u043a\u043e\u0440\u043d\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u0442\u043e\u0447\u0435\u043a     for (i, &amp;root) in roots.iter().enumerate() {         \/\/ [i, i, i, i]         let _ids = i32x4_splat(i as i32);         \/\/ [rx, ry, rx, ry] - \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u0440\u043d\u0435\u0439         let _roots = v128_load64_splat(addr_of!(root) as *const u64);          \/\/ [dist(p1, r), dist(p1, r), dist(p2, r), dist(p2, r)] - \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0430\u0440\u044b \u0442\u043e\u0447\u0435\u043a \u0434\u043e \u043a\u043e\u0440\u043d\u044f         let _dists1 = SimdMath::calculate_squared_distances(_points1, _roots);         \/\/ [dist(p3, r), dist(p3, r), dist(p4, r), dist(p4, r)] - \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u044b \u0442\u043e\u0447\u0435\u043a \u0434\u043e \u043a\u043e\u0440\u043d\u044f         let _dists2 = SimdMath::calculate_squared_distances(_points2, _roots);         \/\/ [dist(p1, r), dist(p2, r), dist(p3, r), dist(p4, r)] - \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043e \u043a\u043e\u0440\u043d\u044f         let _distances = i32x4_shuffle::&lt;0, 2, 4, 6>(_dists1, _dists2);          \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438 \u043d\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435         let _le_check = f32x4_lt(_distances, _min_distances);         \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438         _min_distances = v128_bitselect(_distances, _min_distances, _le_check);         \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0440\u043d\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438         _closest_root_ids = v128_bitselect(_ids, _closest_root_ids, _le_check);     }     \/\/ \u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c v128 \u043a\u0430\u043a \u0447\u0435\u0442\u044b\u0440\u0435 u32     return transmute::&lt;v128, (u32, u32, u32, u32)>(_closest_root_ids); }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">SIMD: \u043c\u0435\u0442\u043e\u0434 \u041d\u044c\u044e\u0442\u043e\u043d\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\"><a href=\"https:\/\/github.com\/alordash\/newton-fractal\/blob\/1a8471bda76fcf3c7c1d4918c1a07176432350b6\/src\/fractal_calculation.rs#L108-L188\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>.<\/p>\n<pre><code class=\"rust\">\/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u041d\u044c\u044e\u0442\u043e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \/\/ \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0440\u043d\u044f \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \/\/ \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 #[inline] #[target_feature(enable = \"simd128\")] pub unsafe fn simd_newton_method_approx_for_two_numbers(two_z: v128, roots: &amp;[Complex32]) -> v128 {     let ptr = addr_of!(two_z) as *const u64;     u64x2(         simd_newton_method_approx(*ptr, roots),         simd_newton_method_approx(*(ptr.offset(1)), roots),     ) }  #[inline] #[target_feature(enable = \"simd128\")] pub fn simd_newton_method_approx(z: u64, roots: &amp;[Complex32]) -> u64 {     \/\/ [re1: 0, im1: 0, re2: 0, im2: 0]     let mut _sums = SimdMath::_F32_ZERO;     \/\/ [re, im, re, im]     let _z = unsafe { v128_load64_splat(&amp;z) };      \/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e 2 \u043a\u043e\u0440\u043d\u044f \u0437\u0430 \u0440\u0430\u0437     \/\/ [r1.re, r1.im, r2.re, r2.im]: r1, r2 - \u043a\u043e\u0440\u043d\u0438     let roots_chunks_iter = roots.chunks_exact(2);     let rem = roots_chunks_iter.remainder();     for roots_chunk in roots_chunks_iter {         unsafe {             \/\/ \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435: sum += 1.0 \/ (z - root)             \/\/ 1. \u0412\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435: z - root             let _diffs = f32x4_sub(_z, *(roots_chunk.as_ptr() as *const v128));             let _square_norms = SimdMath::calculate_square_norms(_diffs);              \/\/ 1*. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430: if (difference &lt; 0.001) => z - \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0440\u043d\u0435\u0439             if v128_any_true(f32x4_lt(_square_norms, _MIN_DIFFS)) {                 return z;             }              \/\/ 2. \u0418\u043d\u0432\u0435\u0440\u0441\u0438\u044f: 1.0 \/ (z - root)             let mut _inversions = f32x4_mul(_diffs, SimdMath::_NEGATION_MASK_FOR_INVERSION);             _inversions = f32x4_div(_inversions, _square_norms);              \/\/ 3. \u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435: sum += 1.0 \/ (z - root)             _sums = f32x4_add(_sums, _inversions);         }     }     \/\/ [re2, im2, re1, im1]     let _sums_shifted = i8x16_swizzle(         _sums,         i8x16(8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7),     );      \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0435\u0441\u0442\u044c     if let Some(rem) = rem.get(0) {         unsafe {             \/\/ \u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0434\u0435\u043b\u0430\u0451\u0442\u0441\u044f \u0432\u0441\u0451 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0446\u0438\u043a\u043b,             \/\/ \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435             \/\/ \u0440\u0430\u0432\u043d\u043e 0: [r1.re, r1.im, 0, 0]             let _diffs = f32x4_sub(_z, v128_load64_zero(addr_of!(*rem) as *const u64));             let _square_norms = SimdMath::calculate_square_norms(_diffs);             if (i8x16_extract_lane::&lt;0>(f32x4_lt(_square_norms, _MIN_DIFFS)) &amp; 1) == 1 {                 return z;             }             let mut _inversions = f32x4_mul(_diffs, SimdMath::_NEGATION_MASK_FOR_INVERSION);             _inversions = f32x4_div(_inversions, _square_norms);             _sums = f32x4_add(_sums, _inversions);         }     }      \/\/ [re1 + re2, im1 + im2, re1 + re2, im1 + im2]     _sums = f32x4_add(_sums, _sums_shifted);      \/\/ z - 1.0 \/ sum     unsafe {         \/\/ 1.0 \/ sum         let _inversions = SimdMath::complex_numbers_inversion(_sums);         \/\/ z - (1.0 \/ sum)         let _subs = f32x4_sub(_z, _inversions);         *(addr_of!(_subs) as *const u64)     } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">SIMD: \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"rust\">pub struct SimdMath;  impl SimdMath {     pub const _F32_ZERO: v128 = f32x4(0.0, 0.0, 0.0, 0.0);     pub const _F32_MAX: v128 = f32x4(f32::MAX, f32::MAX, f32::MAX, f32::MAX);     pub const _I32_ZERO: v128 = i32x4(0, 0, 0, 0);     pub const _NEGATION_MASK_FOR_INVERSION: v128 = f32x4(1.0, -1.0, 1.0, -1.0);      \/\/ a % b = a - b * floor(a \/ b)     #[target_feature(enable = \"simd128\")]     pub fn f32x4_mod(_a: v128, _b: v128) -> v128 {         f32x4_sub(_a, f32x4_mul(_b, f32x4_floor(f32x4_div(_a, _b))))     }      \/\/ \u041a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0430\u044f \u043d\u043e\u0440\u043c\u0430 z (a: re, b: im) = a^2 + b^2     #[target_feature(enable = \"simd128\")]     pub fn calculate_square_norms(_vec: v128) -> v128 {         \/\/ [a^2, b^2, a^2, b^2]         let _squares = f32x4_mul(_vec, _vec);          \/\/ [b^2, a^2, b^2, a^2]         let _shifted_squares = i8x16_swizzle(             _squares,             i8x16(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11),         );          \/\/ [         \/\/     a^2 + b^2,         \/\/     a^2 + b^2,         \/\/     a^2 + b^2,         \/\/     a^2 + b^2         \/\/ ]         f32x4_add(_squares, _shifted_squares)     }      \/\/ \u0424\u043e\u0440\u043c\u0443\u043b\u0430:     \/\/   1 \/ z     \/\/ = 1 \/ (a + bi)     \/\/ = a \/ (a^2 + b^2) - bi \/ (a^2 + b^2)     \/\/ Real:        a \/ (a^2 + b^2)     \/\/ Imagine:    -b \/ (a^2 + b^2)     #[target_feature(enable = \"simd128\")]     pub fn complex_numbers_inversion(_vec: v128) -> v128 {         \/\/ [a, -b, a, -b]         let _numerators = f32x4_mul(_vec, SimdMath::_NEGATION_MASK_FOR_INVERSION);          \/\/ [         \/\/     a^2 + b^2,         \/\/     a^2 + b^2,         \/\/     a^2 + b^2,         \/\/     a^2 + b^2         \/\/ ]         let _denumerators = SimdMath::calculate_square_norms(_numerators);          \/\/ [         \/\/       a \/ (a^2 + b^2),         \/\/      -b \/ (a^2 + b^2),         \/\/       a \/ (a^2 + b^2),         \/\/      -b \/ (a^2 + b^2)         \/\/ ]         f32x4_div(_numerators, _denumerators)     }      \/\/ \u0424\u043e\u0440\u043c\u0443\u043b\u0430:     \/\/ \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 = sqrt((x1 - x2)^2 + (y1 - y2)^2)     \/\/ _points1: (x1, y1, x3, y3)     \/\/ _points2: (x2, y2, x4, y4)     #[target_feature(enable = \"simd128\")]     pub fn calculate_squared_distances(_points1: v128, _points2: v128) -> v128 {         \/\/ [         \/\/      x1 - x2 (= A),         \/\/      y1 - y2 (= B),         \/\/      x3 - x4 (= C),         \/\/      y3 - y4 (= D)         \/\/ ]         let _diffs = f32x4_sub(_points1, _points2);          \/\/ [         \/\/     A^2 + B^2,         \/\/     A^2 + B^2,         \/\/     C^2 + D^2,         \/\/     C^2 + D^2         \/\/ ]         SimdMath::calculate_square_norms(_diffs)     } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430 \u0440\u0430\u0437, \u0432\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u0440\u0430\u0437 \u0441\u0442\u0440\u0430\u0448\u043d\u0435\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u0434 \u0441 \u043d\u0438\u043c\u0438. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043e\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 ~2.2 \u0440\u0430\u0437\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/alordash.github.io\/newton-fractal\/www\/\">\u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u0435\u043c\u043e<\/a>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0439\u0442\u0435 \u043e\u043f\u0446\u0438\u0438 \u00abCPU-wasm-scalar\u00bb \u0438 \u00abCPU-wasm-simd\u00bb.<br \/>  \u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e: \u0435\u0441\u043b\u0438 \u0432 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0446\u0432\u0435\u0442 \u0434\u043b\u044f \u0442\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043a\u043e\u0440\u043d\u044f\u043c \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u041d\u044c\u044e\u0442\u043e\u043d\u0430\u2026<\/p>\n<pre><code class=\"rust\">if square_norm &lt; MIN_DIFF {     return 3;  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 } ... if v128_any_true(f32x4_lt(_square_norms, _MIN_DIFFS)) {     return 3;  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 }<\/code><\/pre>\n<p>  \u2026 \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/rs\/vn\/jv\/rsvnjvbeugswrqwgah-d0tb6pgk.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/rs\/vn\/jv\/rsvnjvbeugswrqwgah-d0tb6pgk.png\"\/><\/p>\n<p>  \u0412\u0441\u0435 \u0436\u0451\u043b\u0442\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043a\u043e\u0440\u043d\u044f\u043c \u043f\u043e\u0441\u043b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u043f\u0440\u0435\u0436\u0434\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430. \u0414\u043b\u044f \u043d\u0438\u0445 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0441\u044f \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0440\u043d\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 15% \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0443\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 SIMD-\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c<\/b>                         <\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zj\/ad\/fe\/zjadfezd6l72etwz1mnv6x5zlqy.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/zj\/ad\/fe\/zjadfezd6l72etwz1mnv6x5zlqy.png\"\/>  <\/div>\n<\/p><\/div>\n<p>  \u041d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c <b><font color=\"#3AC1EF\">4.9 FPS<\/font><\/b> \u0443 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0438 <b><font color=\"#3AC1EF\">18.4 FPS<\/font><\/b> \u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 ~375%, \u0447\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c 400% (\u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430 \u0440\u0430\u0437 128 \u0431\u0438\u0442 \u0432\u043c\u0435\u0441\u0442\u043e 32). \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e SIMD \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043f\u043b\u0430\u043d\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u042f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043d\u043e \u043c\u043d\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0443\u0434\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0442\u043e\u0433\u043e \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435. \u041f\u0443\u0441\u043a\u0430\u0439 \u043a\u043e\u0434 \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c, \u043d\u043e, \u0437\u0430\u0442\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u043d \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>  <a name=\"browser_multithreading\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">\u041c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445<\/font><\/h2>\n<p>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u2014 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/Web_Workers_API\/Using_web_workers\">WebWorker<\/a>&#8216;\u044b. \u0412\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 JS \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <code>new Worker(\"worker.js\")<\/code>. \u042d\u0442\u043e\u0442 \u043f\u043e\u0442\u043e\u043a \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c. \u041e\u0431\u043c\u0435\u043d \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438 \u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code><a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/Worker\/postMessage\">postMessage<\/a><\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043a\u043e\u043b\u0431\u044d\u043a <code><a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/Worker\/message_event\">onmessage<\/a><\/code> \u0441 \u043e\u0431\u0435\u0438\u0445 \u0441\u0442\u043e\u0440\u043e\u043d, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 postMessage.<\/p>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u0435\u043d WebAssembly (\u0438 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d-\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0435\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c JS \u043a\u043e\u0434 \u043d\u0430 \u0432\u0441\u0435\u0445 \u044f\u0434\u0440\u0430\u0445), \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u044b \u0431\u043e\u0440\u0435\u0442\u0435\u0441\u044c \u0437\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0430 wasm \u2014 \u043e\u0441\u043d\u043e\u0432\u0430 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043b\u044c\u0448\u0435 \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043e \u043d\u044e\u0430\u043d\u0441\u0430\u0445, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u0441 Rust-wasm. \u0418 \u0445\u043e\u0442\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/GoogleChromeLabs\/wasm-bindgen-rayon\">rayon \u0432 wasm<\/a>), \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0437\u0430 \u043d\u0438\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d Rust-wasm \u0432 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u0430\u0445<\/font><\/h3>\n<p>  JS \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 JS \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u041e\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WorkerGlobalScope\/importScripts\">importScripts<\/a><\/code>. \u0422\u0430\u043a\u0436\u0435 JS \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 ECMAScript \u043c\u043e\u0434\u0443\u043b\u0435\u0439 (\u0447\u0435\u0440\u0435\u0437 <code>import<\/code>), \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f <a href=\"https:\/\/html.spec.whatwg.org\/#module-worker-example\">\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435<\/a> \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u044b. \u041e\u043d\u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 <a href=\"https:\/\/caniuse.com\/mdn-api_worker_worker_ecmascript_modules\">\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 Firefox<\/a>. \u042d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0430 \u043d\u0430\u0448\u0443 html \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 <a href=\"https:\/\/unpkg.com\/module-workers-polyfill@0.3.2\/module-workers-polyfill.min.js\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u00ab\u043f\u043e\u043b\u0438\u0444\u0438\u043b\u00bb<\/a>. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c wasm \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0432\u043e\u0440\u043a\u0435\u0440\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u043e\u0440\u043a\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 id \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e wasm:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0424\u0430\u0439\u043b worker.js import init, { sum } from '..\/pkg\/project_name.js';  async function run() {     \/\/ \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 wasm \u043c\u043e\u0434\u0443\u043b\u044f     await init(\"..\/pkg\/project_name_bg.wasm\"); } run();  \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0431\u044d\u043a \u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0435 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f onmessage = function (message) {     let data = message.data;     let id = data.id;     let nums = data.nums;     let [a, b] = [nums[0], nums[1]];      \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 wasm \u043c\u043e\u0434\u0443\u043b\u044f     let result = sum(a, b);     console.log(`Worker #${id}: ${a} + ${b} = ${result}`); }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c JS \u0441\u043a\u0440\u0438\u043f\u0442\u0435:<\/p>\n<pre><code class=\"javascript\">const WORKERS_COUNT = 4; for (let i = 0; i &lt; WORKERS_COUNT; i++) {     let worker = new Worker('worker.js', { type: 'module' });     \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0441 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443,     \/\/ \u0447\u0442\u043e\u0431\u044b wasm \u043c\u043e\u0434\u0443\u043b\u044c \u0443\u0441\u043f\u0435\u043b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f     setTimeout(() => {         \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u043e\u0440\u043a\u0435\u0440\u0443         \/\/ \u041f\u0440\u043e\u0441\u0438\u043c \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c i + i*i         worker.postMessage({ id: i, nums: [i, i * i] });     }, 1000); }<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/re\/th\/f0\/rethf0jr3bhuxt8bkryddb6ory4.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/re\/th\/f0\/rethf0jr3bhuxt8bkryddb6ory4.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u043e\u0440\u043a\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 wasm \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0446\u0432\u0435\u0442\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f) \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432, \u043f\u043e\u0442\u043e\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u0445 \u043e\u0442\u0442\u0443\u0434\u0430 \u0432 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a, \u0433\u0434\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043e\u0434\u0438\u043d \u043c\u0430\u0441\u0441\u0438\u0432\/\u0441\u0442\u0440\u043e\u043a\u0443\/\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0435\u0435 \u0431\u044b\u043b\u043e \u0431\u044b, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0441\u0435 \u0432\u043e\u0440\u043a\u0435\u0440\u044b \u043e\u0431\u043b\u0430\u0434\u0430\u043b\u0438 \u0435\u0434\u0438\u043d\u043e\u0439 wasm \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0438\u0441\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0438 wasm \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 <code><a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/SharedArrayBuffer\">SharedArrayBuffer<\/a><\/code>. \u042d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 <code>ArrayBuffer<\/code>, \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043d\u0435\u043c\u0443 \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0432\u0441\u0435 \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <code>postMessage<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044f\u0434\u0440\u0430\u0445 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ol>\n<li>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>SharedArrayBuffer<\/code>.<\/li>\n<li>\u041f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c wasm \u043c\u043e\u0434\u0443\u043b\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c.<\/li>\n<\/ol>\n<p>  <\/p>\n<h4><font color=\"#3AC1EF\">\u258d \u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>SharedArrayBuffer<\/code> \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/font><\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>SharedArrayBuffer<\/code>, \u0442\u043e \u0443 \u0432\u0430\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/l9\/n2\/jh\/l9n2jh3gdp2c8biaysf7xavkra8.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/l9\/n2\/jh\/l9n2jh3gdp2c8biaysf7xavkra8.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 <code>SharedArrayBuffer<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Secure_Contexts\">\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435<\/a>. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f, \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0445\u0438\u0434\u0435\u0440\u044b:<\/p>\n<pre><code class=\"plaintext\">Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/SharedArrayBuffer#security_requirements\">\u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442<\/a>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0445\u0438\u0434\u0435\u0440\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435 \u0441\u0430\u0439\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043b\u0438 \u0433\u0438\u0442\u0445\u0430\u0431), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043b\u0430\u0439\u0444\u0445\u0430\u043a\u043e\u043c.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0445\u0438\u0434\u0435\u0440\u044b, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\u041d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/Service_Worker_API\">\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0432\u043e\u0440\u043a\u0435\u0440<\/a> \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u044b\u0435 \u0445\u0438\u0434\u0435\u0440\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 serviceWorker.js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">self.addEventListener(\"install\", function () {     self.skipWaiting(); });  self.addEventListener(\"activate\", (event) => {     event.waitUntil(self.clients.claim()); });  self.addEventListener(\"fetch\", function (event) {     if (event.request.cache === \"only-if-cached\" &amp;&amp; event.request.mode !== \"same-origin\") {         return;     }      event.respondWith(         fetch(event.request)             .then(function (response) {                 if (response.status == 0) {                     return response;                 }                  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0445\u0438\u0434\u0435\u0440\u044b                 const newHeaders = new Headers(response.headers);                 newHeaders.set(\"Cross-Origin-Embedder-Policy\", \"require-corp\");                 newHeaders.set(\"Cross-Origin-Opener-Policy\", \"same-origin\");                  const moddedResponse = new Response(response.body, {                     status: response.status,                     statusText: response.statusText,                     headers: newHeaders,                 });                  return moddedResponse;             })             .catch(function (e) {                 console.error(e);             })     ); });<\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 \u043d\u0430\u0448\u0443 html \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code class=\"javascript\">&lt;script type=\"module\">     if (\"serviceWorker\" in navigator) {         \/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u0432\u043e\u0440\u043a\u0435\u0440\u0430         navigator.serviceWorker.register(new URL(\".\/serviceWorker.js\", import.meta.url)).then(             function (registration) {                 console.log(\"COOP\/COEP Service Worker registered\", registration.scope);                  if (!navigator.serviceWorker.controller) {                     window.location.reload();                 }             },             function (err) {                 console.log(\"COOP\/COEP Service Worker failed to register\", err);             }         );     } else {         console.warn(\"Cannot register a service worker\");     } &lt;\/script> <\/code><\/pre>\n<p>  \u0412\u0441\u0451! \u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442 (\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043b\u0443\u0447\u0448\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u0443\u043a\u0438 \u0438 \u043a\u044d\u0448), \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c <code>SharedArrayBuffer<\/code>.<br \/>  P. S. \u0418\u0434\u0435\u044f \u2014 \u043d\u0435 \u043c\u043e\u044f, \u044f \u0435\u0451 <a href=\"https:\/\/dev.to\/stefnotch\/enabling-coop-coep-without-touching-the-server-2d3n\">\u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0442\u0443\u0442<\/a>.  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4><font color=\"#3AC1EF\">\u258d \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 wasm \u043c\u043e\u0434\u0443\u043b\u0435\u043c<\/font><\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u0431\u043e\u0440\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e wasm \u043c\u043e\u0434\u0443\u043b\u044f \u043c\u043e\u0433\u043b\u0430 \u0431\u0430\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u044f\u0434 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u00abnightly\u00bb \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u00ab\u041d\u043e\u0447\u043d\u0430\u044f\u00bb \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u044f\u0437\u044b\u043a\u0430. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/rust-lang.github.io\/rustup\/overrides.html#overrides\">\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438<\/a>, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0432\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"plaintext\">rusutp override set nightly <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438\u0441\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0443\u043b\u0447\u0435\u0439\u043d \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f \u043d\u0430 \u00ab\u043d\u043e\u0447\u043d\u0443\u044e\u00bb \u0441\u0431\u043e\u0440\u043a\u0443 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 wasm. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 <code>.cargo<\/code>, \u0430 \u0432 \u043d\u0435\u0439 \u2014 \u0444\u0430\u0439\u043b <a href=\"https:\/\/doc.rust-lang.org\/cargo\/reference\/config.html\">\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/a> <code>config.toml<\/code> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"plaintext\">[target.wasm32-unknown-unknown] rustflags = [\"-C\", \"target-feature=+atomics,+bulk-memory,+mutable-globals\"]  [unstable] build-std = [\"panic_abort\", \"std\"] <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 \u044d\u0442\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 JS \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 wasm \u043c\u043e\u0434\u0443\u043b\u044f <code>init<\/code> \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 <code>WebAssembly.Memory<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 wasm \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/WebAssembly\/Memory#creating_a_shared_memory\">\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 wasm<\/a>.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u0442\u0443 \u043f\u0430\u043c\u044f\u0442\u044c \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0435\u0451 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0447\u0435\u0440\u0435\u0437 postMessage:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0441 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 \/\/ 100 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (6.4MB) \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u2014 1000 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (64MB) let sharedMemory = new WebAssembly.Memory({ initial: 100, maximum: 1000, shared: true });  const WORKERS_COUNT = 4; for (let i = 0; i &lt; WORKERS_COUNT; i++) {     let worker = new Worker('worker.js', { type: 'module' });     \/\/ \u0414\u0435\u043b\u0438\u043c\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0441 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u043c     worker.postMessage(sharedMemory);      setTimeout(() => {         worker.postMessage({ id: i, nums: [i, i * i] });     }, 1000); }<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u044c \u0432 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u0445 \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u044e \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 wasm \u043c\u043e\u0434\u0443\u043b\u0435\u0439:<\/p>\n<pre><code class=\"javascript\">import init, { sum } from '..\/pkg\/project_name.js';  \/\/ \u041a\u043e\u043b\u0431\u044d\u043a-\u0437\u0430\u0442\u044b\u0447\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f wasm \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0440\u0430\u0437. onmessage = async function(message) {     \/\/ \u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c     let sharedMemory = message.data;      \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f wasm \u043c\u043e\u0434\u0443\u043b\u044f \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e     await init(\"..\/pkg\/project_name_bg.wasm\", sharedMemory);      \/\/ \u041c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043b\u0431\u044d\u043a-\u0437\u0430\u0442\u044b\u0447\u043a\u0443 \u043d\u0430 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043a\u043e\u043b\u0431\u044d\u043a     onmessage = actualCallback; }  \/\/ \u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043a\u043e\u043b\u0431\u044d\u043a function actualCallback(message) {     let data = message.data;     let id = data.id;     let nums = data.nums;     let [a, b] = [nums[0], nums[1]];      \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 wasm \u043c\u043e\u0434\u0443\u043b\u044f     let result = sum(a, b);     console.log(`Worker #${id}: ${a} + ${b} = ${result}`); }<\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u0443\u0444\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432. \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0431\u0443\u0444\u0435\u0440 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0443\u0441\u043a\u0430 \u0438 \u043f\u0440\u0438\u043a\u0430\u0436\u0435\u043c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a.<\/p>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0431\u0443\u0444\u0435\u0440 u32 \u0447\u0438\u0441\u0435\u043b \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"rust\">\/\/ buff_ptr - \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 \/\/ buff_length - \u043a\u043e\u043b-\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 u32 \u0432 \u043d\u0451\u043c \/\/ buff_parts - \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0435\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0431\u0443\u0444\u0435\u0440 (\u0442. \u0435. \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0435\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c) \/\/ part_num - \u043d\u043e\u043c\u0435\u0440 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c #[wasm_bindgen] pub fn fill_buffer(buff_ptr: *mut u32, buff_length: usize, buff_parts: usize, part_num: usize) {     let offset = buff_length \/ buff_parts;     let begin = part_num * offset;     let end = (part_num + 1) * offset;      for i in begin..end {         unsafe {             \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0443\u0444\u0435\u0440             *buff_ptr.add(i) = i as u32;         }     } }<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u044b \u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438 \u043e\u0442\u0442\u0443\u0434\u0430 \u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442. \u0417\u0430\u0442\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0432\u043e\u0440\u043a\u0435\u0440\u044b \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a import init, { create_u32_buffer, free_u32_buffer } from '..\/pkg\/project_name.js';  const BUFF_LENGTH = 16; const WORKERS_COUNT = 4;  async function run() {     let sharedMemory = new WebAssembly.Memory({ initial: 100, maximum: 1000, shared: true });     await init(\"..\/pkg\/project_name_bg.wasm\", sharedMemory);      let buffPtr = create_u32_buffer(BUFF_LENGTH);      \/\/ \u041a\u043e\u043b-\u0432\u043e \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0432\u0448\u0438\u0445 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u0430     let doneWorkersCount = 0;     function workerCallback() {         doneWorkersCount += 1;         \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f         if (doneWorkersCount == WORKERS_COUNT) {             let u32Array = new Uint32Array(sharedMemory.buffer, buffPtr, BUFF_LENGTH);             console.log('u32Array :>> ', u32Array);             \/\/ ...\u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c             free_u32_buffer(buffPtr, BUFF_LENGTH);         }     }      for (let i = 0; i &lt; WORKERS_COUNT; i++) {         let worker = new Worker('worker.js', { type: 'module' });         \/\/ \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0432\u0448\u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u043d\u0430 1         \/\/ \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445         worker.onmessage = workerCallback;          worker.postMessage(sharedMemory);          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0431\u0443\u0444\u0435\u0440\u0435         setTimeout(() => {             worker.postMessage({                 buffPtr,                 buffLength: BUFF_LENGTH,                 buffParts: WORKERS_COUNT,                 partNum: i             });         }, 1000);     } } run();<\/code><\/pre>\n<p>  \u0412 \u0432\u043e\u0440\u043a\u0435\u0440\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440 import init, { fill_buffer } from '..\/pkg\/project_name.js';  onmessage = async function (message) {     let sharedMemory = message.data;      await init(\"..\/pkg\/project_name_bg.wasm\", sharedMemory);     onmessage = actualCallback; }  function actualCallback(message) {     let data = message.data;     let { buffPtr, buffLength, buffParts, partNum } = data;     \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c     fill_buffer(buffPtr, buffLength, buffParts, partNum);     postMessage(\"done\"); \/\/ \u041c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e }<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u0430\u0439\u0442\u0430 \u043c\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/sb\/l5\/o-\/sbl5o-zrwrbcepk1a58lmant-l8.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/sb\/l5\/o-\/sbl5o-zrwrbcepk1a58lmant-l8.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0430 \u0434\u043e 1 \u043c\u043b\u043d \u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0447\u0438\u0441\u0435\u043b \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0432 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0435 \u0437\u0430\u0434\u0430\u0447 \u0432\u043e\u0437\u0440\u043e\u0441\u0448\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430:<\/p>\n<pre><code class=\"javascript\">... \/\/ \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a const BUFF_LENGTH = 1_000_000; ...<\/code><\/pre>\n<pre><code class=\"rust\">fn fibonacci(n: u32) -> u32 {     let (mut a, mut b) = (0, 1);     for _ in 0..n {         (a, b) = (b, a + b);     }     return a; }  #[wasm_bindgen] pub fn fill_buffer(buff_ptr: *mut u32, buff_length: usize, buff_parts: usize, part_num: usize) {     let offset = buff_length \/ buff_parts;     let begin = part_num * offset;     let end = (part_num + 1) * offset;      for i in begin..end {         unsafe {             \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438             *buff_ptr.add(i) = fibonacci(i as u32);         }     } }<\/code><\/pre>\n<p>  \u041d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0431\u0443\u0444\u0435\u0440 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f ~1-2 \u043c\u0438\u043d\u0443\u0442\u044b. \u0412 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u0435 CPU \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/o5\/vh\/el\/o5vhel3jika8q6pbzzrwzeir0jc.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/o5\/vh\/el\/o5vhel3jika8q6pbzzrwzeir0jc.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0431\u044b\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 100%. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0438\u0434\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0430\u0434\u043e\u0432 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u2014 \u044d\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u043b \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u0430, \u0442\u0435\u043c \u0434\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0447\u0438\u0441\u0435\u043b \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0440\u043a\u0435\u0440\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0430 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0449\u0451 \u0438 \u0442\u043e, \u0447\u0442\u043e, \u0445\u043e\u0442\u044f \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432\u0441\u0435\u0433\u043e 4 \u0432\u043e\u0440\u043a\u0435\u0440\u0430, \u043c\u043e\u0439 8-\u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u044b\u043b \u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043d\u0430 ~90%. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u0438 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0436\u0435\u043b\u0435\u0437\u0430. \u0418\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u041e\u0421.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441 \u043e\u0434\u043d\u0438\u043c \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u043c (\u0431\u0443\u0444\u0435\u0440 \u0431\u044b\u043b \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d \u0437\u0430 ~3-4 \u043c\u0438\u043d\u0443\u0442\u044b):<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">1 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440<\/b>                         <\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/bz\/g-\/xq\/bzg-xqynlat7u2vksq8edhkwie0.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/bz\/g-\/xq\/bzg-xqynlat7u2vksq8edhkwie0.jpeg\" data-blurred=\"true\"\/>  <\/div>\n<\/p><\/div>\n<p>  \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430 \u041d\u044c\u044e\u0442\u043e\u043d\u0430 \u043d\u0430 \u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u0435\u043c\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0435\u0433\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442, \u0432\u0441\u0435 \u0432\u0435\u0431-\u0432\u043e\u0440\u043a\u0435\u0440\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <a name=\"conclusion\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">\u0412\u044b\u0432\u043e\u0434<\/font><\/h2>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c, \u043c\u0430\u043b\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043a\u043e\u043b\u043e-\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e WebAssembly, \u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SIMD \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0434\u043e 400%. \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438-\u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438. \u0412\u0440\u0443\u0447\u043d\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u043d\u043e \u0437\u0430\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0433\u043e\u043d\u043a\u0438 \u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0441\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u043d\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0430\u0432\u0440\u044f\u0434 \u043b\u0438 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432 <code>CORES_COUNT * REGISTERS_COUNT<\/code> \u0440\u0430\u0437 \u0438\u0437-\u0437\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0438 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u2014 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442.<\/p>\n<p>  <a href=\"https:\/\/github.com\/alordash\/newton-fractal\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u0435\u043c\u043e<\/a>.<\/p>\n<p>  <a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=alordash&amp;utm_content=ispolzuem_klientskij_processor_po_maksimumu_chast_2_simd_multipotochnost\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ou\/g5\/kh\/oug5kh6sjydt9llengsiebnp40w.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ou\/g5\/kh\/oug5kh6sjydt9llengsiebnp40w.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/663936\/\"> https:\/\/habr.com\/ru\/company\/ruvds\/blog\/663936\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/post\/663936\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/oo\/zp\/ie\/oozpieh1_7uno_ju9jynjaiikia.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/oo\/zp\/ie\/oozpieh1_7uno_ju9jynjaiikia.jpeg\" data-blurred=\"true\"\/><\/div>\n<p><\/a><br \/>  \u0421\u043d\u043e\u0432\u0430 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/662363\/\">\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0438 \u0444\u0440\u0430\u043a\u0442\u0430\u043b \u041d\u044c\u044e\u0442\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e WebAssembly \u043d\u0430 Rust. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c <abbr title=\"Single instruction, multiple data\">SIMD<\/abbr> \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0412\u0436\u0438\u0432\u0443\u044e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/alordash.github.io\/newton-fractal\/www\/\">\u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u0435\u043c\u043e<\/a>. \u041d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043e\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 ~900% \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 wasm.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-333586","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333586"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333586\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}