{"id":112509,"date":"2023-12-26T15:10:22","date_gmt":"2023-12-26T13:10:22","guid":{"rendered":"https:\/\/prohoster.info\/blog\/novosti-interneta\/dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch"},"modified":"2023-12-26T15:10:22","modified_gmt":"2023-12-26T13:10:22","slug":"dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/news\/dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch","title":{"rendered":"A JIT compiler has been proposed for Python, utilizing the copy-and-patch technique","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Brandt Bucher from Microsoft, a core developer of CPython and part of the team focused on enhancing the performance of the CPython interpreter, has published an implementation of a JIT compiler for Python, utilizing the Copy-and-Patch technique. The JIT publication is timed for Christmas, and the announcement is written in verse.     <\/p>\n<p>The proposed JIT is notable for its very high code generation speed, ease of maintenance, and full integration with the interpreter. The proposed method allows for the automatic transformation of a C-written interpreter into a JIT compiler, without separate code generation logic development and without manually creating assembly representations. With this approach, fixing a bug in the interpreter will automatically resolve the same issue in the JIT, as a common code generator is used.    <\/p>\n<p>The operation of the Copy-and-Patch method is based on the fact that code relocation in memory during object file linking and substituting machine instructions for bytecode in the JIT are similar tasks. When the JIT operates during program execution, it iterates over the bytecode instructions generated by the interpreter and copies precompiled machine code for each instruction into the executable memory area, while also modifying instructions on the fly to substitute processed data (the JIT copies ready-made templates of already compiled functions and plugs in necessary values, such as arguments and constants). Object file loading also involves copying machine code into memory and substituting external symbols.    <\/p>\n<p>In Copy-and-Patch JIT, an object file in ELF format is created using LLVM, containing data about bytecode instructions and information about necessary data replacements. The JIT replaces the bytecode instructions generated during program interpretation with representations in machine code, while simultaneously substituting necessary data for calculations. The JIT implementation requires LLVM as a dependency during the build stage, but runtime components are not linked to external dependencies and consist of approximately 300 manually written lines in C and 3000 generated lines of C code.        <\/p>\n<p>Compared to traditional JIT tools (LLVM -O0), the proposed JIT offers 100 times faster code generation and 15% faster resulting code. When compared to compilation in WebAssembly (Liftoff), the new JIT generates code 5 times faster, and the resulting code runs 50% faster. When comparing the new JIT with an optimizing JIT (LuaJIT) that uses manually written assembly code, the proposed option outperformed it in 13 out of 44 tests, though it lagged in overall performance by 35%, while significantly simplifying maintenance and reducing implementation complexity.            <center>  <div class=\"youtube-placeholder\" data-id=\"HxSHIpEQRjs\" onclick=\"loadVideo(this)\">\r\n        <img decoding=\"async\" src=\"https:\/\/img.youtube.com\/vi\/HxSHIpEQRjs\/hqdefault.jpg\" alt=\"Play video\" loading=\"lazy\" width=\"480\" height=\"360\" style=\"width:100%;height:auto;\">\r\n        <div class=\"play-button\"><\/div>\r\n    <\/div><\/center><br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/www.opennet.ru\/opennews\/art.shtml?num=60352\">opennet.ru<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0411\u0440\u0430\u043d\u0434\u0442 \u0411\u0443\u043a\u0435\u0440 (Brandt Bucher) \u0438\u0437 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Microsoft, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432 \u0447\u0438\u0441\u043b\u043e core-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 CPython \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 CPython, \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u043b\u044f Python, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0443 Copy-and-Patch. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f JIT \u043f\u0440\u0438\u0443\u0440\u043e\u0447\u0435\u043d\u0430 \u043a \u0420\u043e\u0436\u0434\u0435\u0441\u0442\u0432\u0443 \u0438 \u0430\u043d\u043e\u043d\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u0441\u0442\u0438\u0445\u0430\u0445. \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 JIT \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u0435\u043d \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430, \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0435\u0439 \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c. \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[702],"tags":[],"class_list":["post-112509","post","type-post","status-publish","format-standard","hentry","category-news"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0411\u0440\u0430\u043d\u0434\u0442 \u0411\u0443\u043a\u0435\u0440 (Brandt Bucher) \u0438\u0437 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Microsoft, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432 \u0447\u0438\u0441\u043b\u043e core-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 CPython \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 CPython, \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/news\/dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0414\u043b\u044f Python \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0443 copy-and-patch | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0411\u0440\u0430\u043d\u0434\u0442 \u0411\u0443\u043a\u0435\u0440 (Brandt Bucher) \u0438\u0437 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Microsoft, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432 \u0447\u0438\u0441\u043b\u043e core-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 CPython \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 CPython, \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/news\/dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2023-12-26T13:10:22+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2023-12-26T13:10:22+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47A JIT compiler has been proposed for Python that utilizes the copy-and-patch technique | ProHoster","description":"Brandt Bucher from Microsoft, one of the core developers of CPython and a member of the team focused on enhancing the performance of the CPython interpreter, has published the implementation.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/news\/dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0414\u043b\u044f Python \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0443 copy-and-patch | ProHoster","og:description":"\u0411\u0440\u0430\u043d\u0434\u0442 \u0411\u0443\u043a\u0435\u0440 (Brandt Bucher) \u0438\u0437 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Microsoft, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432 \u0447\u0438\u0441\u043b\u043e core-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 CPython \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 CPython, \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.","og:url":"https:\/\/prohoster.info\/en\/blog\/news\/dlya-python-predlozhen-jit-kompilyator-ispolzuyushhij-tehniku-copy-and-patch","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2023-12-26T13:10:22+00:00","article:modified_time":"2023-12-26T13:10:22+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":[],"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/112509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=112509"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/112509\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=112509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=112509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=112509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}