{"id":316776,"date":"2021-01-22T15:00:24","date_gmt":"2021-01-22T15:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316776"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316776","title":{"rendered":"\u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 Python GIL"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bw\/9l\/5d\/bw9l5dh0hycrc3t-_317ox9xoqy.jpeg\"><\/p>\n<p>  \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0445, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d Python GIL (The Global Interpreter Lock) (\u044f \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e CPython). \u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e GIL \u043d\u0435 \u0434\u0430\u0451\u0442 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c\u0443 \u0447\u0438\u0441\u0442\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043d\u0430 Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0432 Vaex \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0441 \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u044b\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 \u0421++ \u0441 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c GIL. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 Python\u2014\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 Python \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0440\u043e\u043b\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0432\u0435\u043d\u0430.<\/p>\n<p>  GIL \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044f\u0432\u043d\u043e, \u0438 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0431\u044b\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0430\u043c \u043f\u043e\u0431\u044b\u0432\u0430\u043b \u0432 \u0440\u043e\u043b\u0438 \u0437\u0430\u0431\u044b\u0432\u0448\u0435\u0433\u043e, \u0438 \u043d\u0430\u0448\u0451\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432 <a href=\"https:\/\/github.com\/apache\/arrow\/pull\/7756\">Apache Arrow<\/a> (\u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c Vaex, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 GIL \u043d\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 Arrow, \u043c\u044b (\u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435) \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438).<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043d\u0430 64 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c Vaex \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u043b\u0435\u043a\u0430 \u043e\u0442 \u0438\u0434\u0435\u0430\u043b\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 4000 % \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432\u043c\u0435\u0441\u0442\u043e 6400 %, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0443\u0433\u0430\u0434 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0438 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430, \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 GIL, \u0442\u043e \u0445\u043e\u0447\u0443 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438 \u043a\u0430\u043a \u043e\u043d \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 Vaex.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u044d\u0442\u043e \u043f\u0438\u0448\u0443<\/h2>\n<p>  \u042f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430\u0445 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 Python \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b Python \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u043e\u043c \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u043e\u043c GIL.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443, \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u044f\u0437\u044b\u043a\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435\u0439 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b Python.<\/p>\n<h2>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<h3>Linux<\/h3>\n<p>  \u0412\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a Linux-\u043c\u0430\u0448\u0438\u043d\u0435 \u0441 root-\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u044f\u043c\u0438 (sudo \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e). \u0418\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0441\u0438\u0441\u0430\u0434\u043c\u0438\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0441 \u043d\u0438\u0436\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439.<\/p>\n<h3>Perf<\/h3>\n<p>  \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d perf, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043d\u0430 Ubuntu \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$ sudo yum install perf <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u044f\u0434\u0440\u0430<\/h3>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a \u0432 \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"bash\"># Enable users to run perf (use at own risk) $ sudo sysctl kernel.perf_event_paranoid=-1  # Enable users to see schedule trace events: $ sudo mount -o remount,mode=755 \/sys\/kernel\/debug $ sudo mount -o remount,mode=755 \/sys\/kernel\/debug\/tracing <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0430\u043a\u0435\u0442\u044b Python<\/h3>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/gaogaotiantian\/viztracer\/\">VizTracer<\/a> \u0438<a href=\"https:\/\/github.com\/maartenbreddels\/per4m\"> per4m<\/a><\/p>\n<pre><code class=\"bash\">$ pip install &quot;viztracer&gt;=0.11.2&quot; &quot;per4m&gt;=0.1,&lt;0.2&quot; <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e perf<\/h2>\n<p>  \u0412 Python \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 GIL (\u043a\u0440\u043e\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/github.com\/chrisjbillington\/gil_load\/\">\u043f\u043e\u043b\u043b\u0438\u043d\u0433\u0430<\/a>), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0442 API. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437 \u044f\u0434\u0440\u0430, \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <strong>perf<\/strong>.<\/p>\n<p>  \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e (\u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043a\u0430\u043a perf_events) \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0441\u044b\u043f\u0430\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435) \u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. Perf \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0443\u0433\u0430\u044e\u0449\u0435, \u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u043d\u0451\u043c \u0431\u043e\u043b\u044c\u0448\u0435, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/jvns.ca\/blog\/2018\/04\/16\/new-perf-zine\/\">\u0441\u0442\u0430\u0442\u044c\u044e \u0414\u0436\u0443\u043b\u0438\u0438 \u042d\u0432\u0430\u043d\u0441<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/www.brendangregg.com\/perf.html\">\u0441\u0430\u0439\u0442 \u0411\u0440\u0435\u043d\u0434\u0430\u043d\u0430 \u0413\u0440\u0435\u0433\u0433\u0430<\/a>.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c perf \u043a <a href=\"https:\/\/github.com\/maartenbreddels\/per4m\/blob\/master\/per4m\/example0.py\">\u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435<\/a>:<\/p>\n<pre><code class=\"python\">import time from threading import Thread  def sleep_a_bit():     time.sleep(1)  def main():     t = Thread(target=sleep_a_bit)     t.start()     t.join()  main() <\/code><\/pre>\n<p>  \u041c\u044b \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0437\u0430\u0448\u0443\u043c\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 (wildcards)):<\/p>\n<pre><code class=\"bash\">$ perf record -e sched:sched_switch  -e sched:sched_process_fork \\         -e 'sched:sched_wak*' -- python -m per4m.example0 [ perf record: Woken up 2 times to write data ] [ perf record: Captured and wrote 0,032 MB perf.data (33 samples) ] <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 perf \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">$ perf script         :3040108 3040108 [032] 5563910.979408:                sched:sched_waking: comm=perf pid=3040114 prio=120 target_cpu=031         :3040108 3040108 [032] 5563910.979431:                sched:sched_wakeup: comm=perf pid=3040114 prio=120 target_cpu=031           python 3040114 [031] 5563910.995616:                sched:sched_waking: comm=kworker\/31:1 pid=2502104 prio=120 target_cpu=031           python 3040114 [031] 5563910.995618:                sched:sched_wakeup: comm=kworker\/31:1 pid=2502104 prio=120 target_cpu=031           python 3040114 [031] 5563910.995621:                sched:sched_waking: comm=ksoftirqd\/31 pid=198 prio=120 target_cpu=031           python 3040114 [031] 5563910.995622:                sched:sched_wakeup: comm=ksoftirqd\/31 pid=198 prio=120 target_cpu=031           python 3040114 [031] 5563910.995624:                sched:sched_switch: prev_comm=python prev_pid=3040114 prev_prio=120 prev_state=R+ ==&gt; next_comm=kworker\/31:1 next_pid=2502104 next_prio=120           python 3040114 [031] 5563911.003612:                sched:sched_waking: comm=kworker\/32:1 pid=2467833 prio=120 target_cpu=032           python 3040114 [031] 5563911.003614:                sched:sched_wakeup: comm=kworker\/32:1 pid=2467833 prio=120 target_cpu=032           python 3040114 [031] 5563911.083609:                sched:sched_waking: comm=ksoftirqd\/31 pid=198 prio=120 target_cpu=031           python 3040114 [031] 5563911.083612:                sched:sched_wakeup: comm=ksoftirqd\/31 pid=198 prio=120 target_cpu=031           python 3040114 [031] 5563911.083613:                sched:sched_switch: prev_comm=python prev_pid=3040114 prev_prio=120 prev_state=R ==&gt; next_comm=ksoftirqd\/31 next_pid=198 next_prio=120           python 3040114 [031] 5563911.108984:                sched:sched_waking: comm=node pid=2446812 prio=120 target_cpu=045           python 3040114 [031] 5563911.109059:                sched:sched_waking: comm=node pid=2446812 prio=120 target_cpu=045           python 3040114 [031] 5563911.112250:          sched:sched_process_fork: comm=python pid=3040114 child_comm=python child_pid=3040116           python 3040114 [031] 5563911.112260:            sched:sched_wakeup_new: comm=python pid=3040116 prio=120 target_cpu=037           python 3040114 [031] 5563911.112262:            sched:sched_wakeup_new: comm=python pid=3040116 prio=120 target_cpu=037           python 3040114 [031] 5563911.112273:                sched:sched_switch: prev_comm=python prev_pid=3040114 prev_prio=120 prev_state=S ==&gt; next_comm=swapper\/31 next_pid=0 next_prio=120           python 3040116 [037] 5563911.112418:                sched:sched_waking: comm=python pid=3040114 prio=120 target_cpu=031           python 3040116 [037] 5563911.112450:                sched:sched_waking: comm=python pid=3040114 prio=120 target_cpu=031           python 3040116 [037] 5563911.112473: sched:sched_wake_idle_without_ipi: cpu=31          swapper     0 [031] 5563911.112476:                sched:sched_wakeup: comm=python pid=3040114 prio=120 target_cpu=031           python 3040114 [031] 5563911.112485:                sched:sched_switch: prev_comm=python prev_pid=3040114 prev_prio=120 prev_state=S ==&gt; next_comm=swapper\/31 next_pid=0 next_prio=120           python 3040116 [037] 5563911.112485:                sched:sched_waking: comm=python pid=3040114 prio=120 target_cpu=031           python 3040116 [037] 5563911.112489:                sched:sched_waking: comm=python pid=3040114 prio=120 target_cpu=031           python 3040116 [037] 5563911.112496:                sched:sched_switch: prev_comm=python prev_pid=3040116 prev_prio=120 prev_state=S ==&gt; next_comm=swapper\/37 next_pid=0 next_prio=120          swapper     0 [031] 5563911.112497:                sched:sched_wakeup: comm=python pid=3040114 prio=120 target_cpu=031           python 3040114 [031] 5563911.112513:                sched:sched_switch: prev_comm=python prev_pid=3040114 prev_prio=120 prev_state=S ==&gt; next_comm=swapper\/31 next_pid=0 next_prio=120          swapper     0 [037] 5563912.113490:                sched:sched_waking: comm=python pid=3040116 prio=120 target_cpu=037          swapper     0 [037] 5563912.113529:                sched:sched_wakeup: comm=python pid=3040116 prio=120 target_cpu=037           python 3040116 [037] 5563912.113595:                sched:sched_waking: comm=python pid=3040114 prio=120 target_cpu=031           python 3040116 [037] 5563912.113620:                sched:sched_waking: comm=python pid=3040114 prio=120 target_cpu=031          swapper     0 [031] 5563912.113697:                sched:sched_wakeup: comm=python pid=3040114 prio=120 target_cpu=031 <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 (\u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445): \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0441\u043d\u0443\u043b\u0430 (\u043f\u0440\u043e\u0448\u043b\u0430 \u043e\u0434\u043d\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0430). \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u0445\u043e\u0434 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u043d\u0430:<\/p>\n<pre><code class=\"bash\">python 3040114 [031] 5563911.112513: sched:sched_switch: prev_comm=python prev_pid=3040114 prev_prio=120 prev_state=S ==&gt; next_comm=swapper\/31 next_pid=0 next_prio=120 <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044f\u0434\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 Python \u043d\u0430 <code>S<\/code> (=sleeping).<\/p>\n<p>  \u0421\u0435\u043a\u0443\u043d\u0434\u0443 \u0441\u043f\u0443\u0441\u0442\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u043e\u0431\u0443\u0434\u0438\u043b\u0430\u0441\u044c:<\/p>\n<pre><code class=\"bash\">swapper 0 [031] 5563912.113697: sched:sched_wakeup: comm=python pid=3040114 prio=120 target_cpu=031 <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439. \u0414\u0430, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/github.com\/maartenbreddels\/per4m\/\">per4m<\/a>, \u043d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c, \u0445\u043e\u0447\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/github.com\/gaogaotiantian\/viztracer\/\">VizTracer<\/a> \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h2>VizTracer<\/h2>\n<p>  \u042d\u0442\u043e \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a Python, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0435\u0433\u043e \u043a <a href=\"https:\/\/github.com\/maartenbreddels\/per4m\/blob\/master\/per4m\/example1.py\">\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435<\/a>:<\/p>\n<pre><code class=\"python\">import threading import time  def some_computation():     total = 0        for i in range(1_000_000):         total += i     return total  def main():     thread1 = threading.Thread(target=some_computation)     thread2 = threading.Thread(target=some_computation)     thread1.start()     thread2.start()     time.sleep(0.2)     for thread in [thread1, thread2]:         thread.join()  main() <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430:<\/p>\n<pre><code class=\"bash\">$ viztracer -o example1.html --ignore_frozen -m per4m.example1 Loading finish                                         Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/per4m\/example1.html ... Dumping trace data to json, total entries: 94, estimated json file size: 11.0KiB Generating HTML report Report saved. <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f HTML: <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/16b\/8c3\/5db\/16b8c35dbb7f4d09a6f7de2a84dbb9af.png\"><\/div>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, <code>some_computation<\/code> \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e (\u0434\u0432\u0430\u0436\u0434\u044b), \u0445\u043e\u0442\u044f \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e GIL \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442. \u0427\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?<\/p>\n<h2>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b VizTracer \u0438 perf<\/h2>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 perf, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 example0.py. \u0422\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>-k CLOCK_MONOTONIC<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/gaogaotiantian\/viztracer\/blob\/3321ba4024afe5623f938a601d7f7db3b08f534d\/src\/viztracer\/modules\/snaptrace.c#L91\">\u0442\u0435 \u0436\u0435 \u0447\u0430\u0441\u044b, \u0447\u0442\u043e \u0438 VizTracer<\/a>, \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c \u0435\u0433\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c JSON \u0432\u043c\u0435\u0441\u0442\u043e HTML:<\/p>\n<pre><code class=\"bash\">$ perf record -e sched:sched_switch  -e sched:sched_process_fork -e 'sched:sched_wak*' \\    -k CLOCK_MONOTONIC  -- viztracer -o viztracer1.json --ignore_frozen -m per4m.example1 <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e per4m \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430 perf \u0432 JSON, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c VizTracer:<\/p>\n<pre><code class=\"bash\">$ perf script | per4m perf2trace sched -o perf1.json Wrote to perf1.json <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e VizTracer \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0434\u0432\u0430 JSON-\u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"bash\">$ viztracer --combine perf1.json viztracer1.json -o example1_state.html Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/per4m\/example1.html ... Dumping trace data to json, total entries: 131, estimated json file size: 15.4KiB Generating HTML report Report saved. <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438: <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/327\/995\/572\/327995572f04183f791ebfffde3fa261.png\"><\/div>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0437\u0430\u0441\u044b\u043f\u0430\u044e\u0442 \u0438\u0437-\u0437\u0430 GIL \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  <strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u0434\u043b\u0438\u043d\u0430 \u0444\u0430\u0437\u044b \u0441\u043d\u0430 \u043e\u043a\u043e\u043b\u043e 5 \u043c\u0441, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <a href=\"https:\/\/docs.python.org\/3\/library\/sys.html#sys.getswitchinterval\">sys.getswitchinterval<\/a><\/p>\n<h2>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 GIL<\/h2>\n<p>  \u041d\u0430\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442, \u043d\u043e \u043c\u044b \u043d\u0435 \u0432\u0438\u0434\u0438\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u0441\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>time.sleep<\/code> \u0438\u043b\u0438 GIL. \u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<h3>\u0427\u0435\u0440\u0435\u0437 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0435\u043a\u0430<\/h3>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>perf record -g<\/code> (\u0430 \u043b\u0443\u0447\u0448\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>perf record --call-graph dwarf<\/code>, \u0447\u0442\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 <code>-g<\/code>), \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f perf.<\/p>\n<pre><code class=\"bash\">$ perf record -e sched:sched_switch  -e sched:sched_process_fork -e 'sched:sched_wak*'\\    -k CLOCK_MONOTONIC  --call-graph dwarf -- viztracer -o viztracer1-gil.json --ignore_frozen -m per4m.example1 Loading finish                                         Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/per4m\/viztracer1-gil.json ... Dumping trace data to json, total entries: 94, estimated json file size: 11.0KiB Report saved. [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0,991 MB perf.data (164 samples) ] <\/code><\/pre>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 perf (\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 <code>--no-inline<\/code>), \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f <a href=\"https:\/\/github.com\/python\/cpython\/blob\/1a9f51ed12feb4d95ad6d0faf610a030c05b9f5e\/Python\/ceval_gil.h#L215\">take_gil<\/a>!<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">$ perf script --no-inline | less ... viztracer 3306851 [059] 5614683.022539:                sched:sched_switch: prev_comm=viztracer prev_pid=3306851 prev_prio=120 prev_state=S ==&gt; next_comm=swapper\/59 next_pid=0 next_prio=120         ffffffff96ed4785 __sched_text_start+0x375 ([kernel.kallsyms])         ffffffff96ed4785 __sched_text_start+0x375 ([kernel.kallsyms])         ffffffff96ed4b92 schedule+0x42 ([kernel.kallsyms])         ffffffff9654a51b futex_wait_queue_me+0xbb ([kernel.kallsyms])         ffffffff9654ac85 futex_wait+0x105 ([kernel.kallsyms])         ffffffff9654daff do_futex+0x10f ([kernel.kallsyms])         ffffffff9654dfef __x64_sys_futex+0x13f ([kernel.kallsyms])         ffffffff964044c7 do_syscall_64+0x57 ([kernel.kallsyms])         ffffffff9700008c entry_SYSCALL_64_after_hwframe+0x44 ([kernel.kallsyms])         7f4884b977b1&lt;a href=&quot;https:\/\/www.maartenbreddels.com\/cdn-cgi\/l\/email-protection&quot;&gt; [email protected]@GLIBC_2.3.2+0x271 (\/usr\/lib\/x86_64-linux-gnu\/libpthread-2.31.so)             55595c07fe6d take_gil+0x1ad (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfaa0b3 PyEval_RestoreThread+0x23 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c000872 lock_PyThread_acquire_lock+0x1d2 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfe71f3 _PyMethodDef_RawFastCallKeywords+0x263 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfe7313 _PyCFunction_FastCallKeywords+0x23 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d657 call_function+0x3b7 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfb6db1 _PyEval_EvalCodeWithName+0x251 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6b00 _PyFunction_FastCallKeywords+0x520 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d334 call_function+0x94 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfb6db1 _PyEval_EvalCodeWithName+0x251 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6b00 _PyFunction_FastCallKeywords+0x520 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d334 call_function+0x94 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6766 _PyFunction_FastCallKeywords+0x186 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d334 call_function+0x94 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6766 _PyFunction_FastCallKeywords+0x186 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060ae4 _PyEval_EvalFrameDefault+0x3f4 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfb6db1 _PyEval_EvalCodeWithName+0x251 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c074e5d builtin_exec+0x33d (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfe7078 _PyMethodDef_RawFastCallKeywords+0xe8 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfe7313 _PyCFunction_FastCallKeywords+0x23 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c066c39 _PyEval_EvalFrameDefault+0x6549 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfb77e0 _PyEval_EvalCodeWithName+0xc80 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6b62 _PyFunction_FastCallKeywords+0x582 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d334 call_function+0x94 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6766 _PyFunction_FastCallKeywords+0x186 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d334 call_function+0x94 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6766 _PyFunction_FastCallKeywords+0x186 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c01d334 call_function+0x94 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060d00 _PyEval_EvalFrameDefault+0x610 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfd6766 _PyFunction_FastCallKeywords+0x186 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c060ae4 _PyEval_EvalFrameDefault+0x3f4 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfb6db1 _PyEval_EvalCodeWithName+0x251 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595bfb81e2 PyEval_EvalCode+0x22 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c0c51d1 run_mod+0x31 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c0cf31d PyRun_FileExFlags+0x9d (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c0cf50a PyRun_SimpleFileExFlags+0x1ba (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c0d05f0 pymain_main+0x3e0 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             55595c0d067b _Py_UnixMain+0x3b (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)             7f48849bc0b2 __libc_start_main+0xf2 (\/usr\/lib\/x86_64-linux-gnu\/libc-2.31.so)             55595c075100 _start+0x28 (\/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7) \u2026 <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f <code>pthread_cond_timedwait<\/code>, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/sumerc\/gilstats.py\">https:\/\/github.com\/sumerc\/gilstats.py<\/a> \u0434\u043b\u044f eBPF, \u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b.<\/p>\n<p>  <strong>\u0415\u0449\u0451 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 Python, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0451 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 <code>_PyEval_EvalFrameDefault<\/code> \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u043a\u0430\u043a \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0435\u043a\u0430.<\/p>\n<p>  \u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>per4m perf2trace<\/code> \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u043e \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 <code>take_gil<\/code>:<\/p>\n<pre><code class=\"bash\">$ perf script --no-inline | per4m perf2trace sched -o perf1-gil.json Wrote to perf1-gil.json $ viztracer --combine perf1-gil.json viztracer1-gil.json -o example1-gil.html Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/per4m\/example1.html ... Dumping trace data to json, total entries: 131, estimated json file size: 15.4KiB Generating HTML report Report saved. <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c: <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/95b\/00a\/067\/95b00a0673680d656de7c828bf140dd7.png\"><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0432\u0438\u0434\u0438\u043c, \u0433\u0434\u0435 GIL \u0438\u0433\u0440\u0430\u0435\u0442 \u0440\u043e\u043b\u044c!<\/p>\n<h3>\u0427\u0435\u0440\u0435\u0437 \u0437\u043e\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (kprobes\/uprobes)<\/h3>\n<p>  \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0437\u0430\u0441\u044b\u043f\u0430\u044e\u0442 (\u0438\u0437-\u0437\u0430 GIL \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u043f\u0440\u0438\u0447\u0438\u043d), \u043d\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f GIL, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b <code>take_gil<\/code> \u0438 <code>drop_gil<\/code>. \u0422\u0430\u043a\u0443\u044e \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0437\u043e\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e perf. \u0412 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0437\u043e\u043d\u0434\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f uprobes, \u044d\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433 kprobes, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0441\u0440\u0435\u0434\u0435 \u044f\u0434\u0440\u0430. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u2014 <a href=\"https:\/\/jvns.ca\/blog\/2017\/07\/09\/linux-tracing-zine\/\">\u0414\u0436\u0443\u043b\u0438\u044f \u042d\u0432\u0430\u043d\u0441<\/a>.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c 4 \u0437\u043e\u043d\u0434\u0430:<\/p>\n<pre><code class=\"bash\">sudo perf probe -f -x `which python` python:take_gil=take_gil sudo perf probe -f -x `which python` python:take_gil=take_gil%return sudo perf probe -f -x `which python` python:drop_gil=drop_gil sudo perf probe -f -x `which python` python:drop_gil=drop_gil%return  Added new events:    python:take_gil      (on take_gil in \/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)   python:take_gil_1    (on take_gil in \/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)  You can now use it in all perf tools, such as:          perf record -e python:take_gil_1 -aR sleep 1  Failed to find &quot;take_gil%return&quot;,  because take_gil is an inlined function and has no return point. Added new event:   python:take_gil__return (on take_gil%return in \/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)  You can now use it in all perf tools, such as:          perf record -e python:take_gil__return -aR sleep 1  Added new events:   python:drop_gil      (on drop_gil in \/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)   python:drop_gil_1    (on drop_gil in \/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)  You can now use it in all perf tools, such as:          perf record -e python:drop_gil_1 -aR sleep 1  Failed to find &quot;drop_gil%return&quot;,  because drop_gil is an inlined function and has no return point. Added new event:   python:drop_gil__return (on drop_gil%return in \/home\/maartenbreddels\/miniconda\/envs\/dev\/bin\/python3.7)  You can now use it in all perf tools, such as:          perf record -e python:drop_gil__return -aR sleep 1 <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0436\u0430\u043b\u043e\u0431\u044b, \u0430 \u0438\u0437-\u0437\u0430 \u0438\u043d\u043b\u0430\u0439\u043d\u0435\u043d\u043d\u044b\u0445 <code>drop_gil<\/code> \u0438 <code>take_gil<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043e\u043d\u0434\u043e\u0432\/\u0441\u043e\u0431\u044b\u0442\u0438\u0439 (\u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437), \u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  <strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u0447\u0442\u043e \u043c\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a Python (\u043e\u0442 conda-forge) \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0442\u0430\u043a, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <code>take_gil<\/code>\/<code>drop_gil<\/code> (\u0438 \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b), \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0435, \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0437\u043e\u043d\u0434\u044b \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u00ab\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u00bb (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0445 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043c \u0438\u0437 perf), \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043a\u043e\u0434 \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0435\u0442\u043a\u0435. \u041f\u0440\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0430 <a href=\"https:\/\/lwn.net\/Articles\/499190\/\">\u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438<\/a> (INT3 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 x86). \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u043b\u044f perf \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c\u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0431\u0440\u0430\u0442\u044c \u0437\u043e\u043d\u0434\u044b, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">$ sudo perf probe --del 'python*' <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c perf \u0437\u043d\u0430\u0435\u0442 \u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u043e\u0432\u0430 \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c <code>-e 'python:*gil*'<\/code>:<\/p>\n<pre><code class=\"bash\">$ perf record -e sched:sched_switch  -e sched:sched_process_fork -e 'sched:sched_wak*' -k CLOCK_MONOTONIC  \\   -e 'python:*gil*' -- viztracer  -o viztracer1-uprobes.json --ignore_frozen -m per4m.example1 <\/code><\/pre>\n<p>  <strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u043c\u044b \u0443\u0431\u0440\u0430\u043b\u0438 <code>--call-graph dwarf<\/code>, \u0438\u043d\u0430\u0447\u0435 perf \u043d\u0435 \u0443\u0441\u043f\u0435\u0435\u0442 \u0438 \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e per4m perf2trace \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432 JSON, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0434\u043b\u044f VizTracer, \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.<\/p>\n<pre><code class=\"bash\">$ perf script --no-inline | per4m perf2trace gil -o perf1-uprobes.json ... Summary of threads:  PID         total(us)    no gil%    has gil%    gil wait% --------  -----------  -----------  ------------  ------------- 3353567*     164490.0         65.9          27.3            6.7 3353569       66560.0          0.3          48.2           51.5 3353570       60900.0          0.0          56.4           43.6  High 'no gil' is good, we like low 'has gil',  and we don't want 'gil wait'. (* indicates main thread) ...  Wrote to perf1-uprobes.json <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>per4m perf2trace gil<\/code> \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 <a href=\"https:\/\/github.com\/chrisjbillington\/gil_load\">gil_load<\/a>. \u0418\u0437 \u043d\u0435\u0433\u043e \u043c\u044b \u0443\u0437\u043d\u0430\u0451\u043c, \u0447\u0442\u043e \u043e\u0431\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0436\u0434\u0443\u0442 GIL \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u0433\u043e \u0436\u0435 \u0444\u0430\u0439\u043b\u0430 perf.data, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e perf, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438 \u0431\u0435\u0437 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043e\u043a \u0441\u0442\u0435\u043a\u0430, \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u0437\u0430\u0441\u043d\u0443\u043b \u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0437-\u0437\u0430 GIL \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<pre><code class=\"bash\">$ perf script --no-inline | per4m perf2trace sched -o perf1-state.json Wrote to perf1-state.json <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430:<\/p>\n<pre><code class=\"bash\">$ viztracer --combine perf1-state.json perf1-uprobes.json viztracer1-uprobes.json -o example1-uprobes.html  Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/per4m\/example1-uprobes.html ... Dumping trace data to json, total entries: 10484, estimated json file size: 1.2MiB Generating HTML report Report saved. <\/code><\/pre>\n<p>  VizTracer \u0434\u0430\u0451\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0443 \u043a\u043e\u0433\u043e \u0431\u044b\u043b GIL \u0438 \u043a\u0442\u043e \u0435\u0433\u043e \u0436\u0434\u0430\u043b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/27a\/576\/e29\/27a576e29122f3375a06f1b77521285f.png\"><\/div>\n<p>  \u041d\u0430\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u043e\u043a \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0436\u0434\u0451\u0442 GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u0442\u043e\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f (\u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043e \u043a\u0430\u043a LOCK). \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u043e\u043a \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <strong>\u043d\u0435 <\/strong>\u0441\u043f\u0438\u0442 (\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f!). \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u0430\u043a \u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u0437-\u0437\u0430 GIL. <\/p>\n<p>  \u0412\u0440\u0435\u043c\u044f \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 <code>take_gil<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 (\u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0441\u044b\u043f\u0430\u043d\u0438\u0435\u043c \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435\u043c), \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0436\u0435, \u043a\u0430\u043a \u0432 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 gil wait%. \u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f GIL \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a LOCK, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 gil%.<\/p>\n<h2>\u0412\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u041a\u0440\u0430\u043a\u0435\u043d\u0430\u2026 \u0433\u0445\u043c, GIL<\/h2>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u043f\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Python GIL \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 (\u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 Python, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e (\u0441\u0443\u0431)\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430). \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c GIL, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 NumPy.<\/p>\n<p>  \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f <code>some_numpy_computation<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e NumPy M=4 \u0440\u0430\u0437 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0432 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Python.<\/p>\n<pre><code class=\"python\">import threading import time import numpy as np  N = 1024*1024*32 M = 4 x = np.arange(N, dtype='f8')  def some_numpy_computation():     total = 0     for i in range(M):         total += x.sum()     return total  def main(args=None):     thread1 = threading.Thread(target=some_numpy_computation)     thread2 = threading.Thread(target=some_numpy_computation)     thread1.start()     thread2.start()     total = 0     for i in range(2_000_000):         total += i     for thread in [thread1, thread2]:         thread.join() main() <\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e perf \u0438 VizTracer \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <code>per4m giltracer<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b. \u041e\u043d\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u0435\u0435. \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u044b \u0434\u0432\u0430\u0436\u0434\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c perf, \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0431\u0435\u0437 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u0442\u0435\u043a\u0430, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u0441 \u043d\u0435\u0439, \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c\/\u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u0440\u043e\u0434\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<pre><code class=\"bash\">$ giltracer --state-detect -o example2-uprobes.html -m per4m.example2 ... <\/code><\/pre>\n<p>  \u0418\u0442\u043e\u0433\u0438 \u043f\u043e \u043f\u043e\u0442\u043e\u043a\u0430\u043c:<\/p>\n<pre><code class=\"bash\">PID         total(us)    no gil%    has gil%    gil wait% --------  -----------  -----------  ------------  ------------- 3373601*    1359990.0         95.8           4.2            0.1 3373683       60276.4         84.6           2.2           13.2 3373684       57324.0         89.2           1.9            8.9  High 'no gil' is good, we like low 'has gil',  and we don't want 'gil wait'. (* indicates main thread) ... Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/per4m\/example2-uprobes.html ... ... <\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a25\/2bc\/d8e\/a252bcd8e3d9714f42ad2e7ad04446da.png\"><\/div>\n<p>  \u0425\u043e\u0442\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u043d\u0430 Python (\u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0451\u043d GIL, \u0447\u0442\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u043e\u043c LOCK), \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u0447\u0438\u0441\u0442\u044b\u043c Python \u0443 \u043d\u0430\u0441 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0410 \u0437\u0434\u0435\u0441\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0438 \u043f\u043e\u0442\u043e\u043a\u0430. \u042d\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b NumPy, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 C\/C++\/Fortran, \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 GIL.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e GIL \u0432\u0441\u0451 \u0436\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u043e\u0442\u043e\u043a\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f NumPy \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 Python, \u0435\u0439 \u0441\u043d\u043e\u0432\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c GIL, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 <code>take_gil<\/code>. \u041d\u0430 \u044d\u0442\u043e \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f 10 % \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<h2>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Jupyter<\/h2>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043e\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 MacBook (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442 perf, \u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 dtrace), \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u043e\u043c \u043a Linux-\u043c\u0430\u0448\u0438\u043d\u0435, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Jupyter notebook \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0418 \u0440\u0430\u0437 \u044f Jupyter-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>cell magic<\/code>.<\/p>\n<pre><code class=\"bash\"># this registers the giltracer cell magic %load_ext per4m  %%giltracer # this call the main define above, but this can also be a multiline code cell main()  Saving report to \/tmp\/tmpvi8zw9ut\/viztracer.json ... Dumping trace data to json, total entries: 117, estimated json file size: 13.7KiB Report saved.  [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0,094 MB \/tmp\/tmpvi8zw9ut\/perf.data (244 samples) ]  Wait for perf to finish... perf script -i \/tmp\/tmpvi8zw9ut\/perf.data --no-inline --ns | per4m perf2trace gil -o \/tmp\/tmpvi8zw9ut\/giltracer.json -q -v  Saving report to \/home\/maartenbreddels\/github\/maartenbreddels\/fastblog\/_notebooks\/giltracer.html ... Dumping trace data to json, total entries: 849, estimated json file size: 99.5KiB Generating HTML report Report saved. <\/code><\/pre>\n<p>  <a href=\"https:\/\/www.maartenbreddels.com\/perf\/jupyter\/python\/tracing\/gil\/2021\/01\/14\/giltracer.html\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c giltracer.html<\/a><\/p>\n<p>  <a href=\"https:\/\/www.maartenbreddels.com\/perf\/jupyter\/python\/tracing\/gil\/2021\/01\/14\/giltracer.html\">\u041e\u0442\u043a\u0440\u044b\u0442\u044c giltracer.html \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435<\/a> (\u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438)<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e perf \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438\u043b\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0443 \u043a\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u0432\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f GIL \u0432 Python. \u0410 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043e\u043a \u0441\u0442\u0435\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u043d\u0430 \u0431\u044b\u043b GIL, \u0430 \u043d\u0435 <code>time.sleep<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>  \u0421\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 uprobes \u0441 perf \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>take_gil<\/code> \u0438 <code>drop_gil<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u043b\u0438\u044f\u043d\u0438\u0438 GIL \u043d\u0430 \u0432\u0430\u0448\u0443 Python-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/p>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u043c \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 per4m, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 perf \u0432 JSON-\u0444\u043e\u0440\u043c\u0430\u0442 VizTracer, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u041c\u043d\u043e\u0433\u043e \u0431\u0443\u043a\u0430\u0444, \u043d\u0435 \u043e\u0441\u0438\u043b\u0438\u043b<\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 GIL, \u0442\u043e \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"bash\">sudo yum install perf sudo sysctl kernel.perf_event_paranoid=-1 sudo mount -o remount,mode=755 \/sys\/kernel\/debug sudo mount -o remount,mode=755 \/sys\/kernel\/debug\/tracing sudo perf probe -f -x `which python` python:take_gil=take_gil sudo perf probe -f -x `which python` python:take_gil=take_gil%return sudo perf probe -f -x `which python` python:drop_gil=drop_gil sudo perf probe -f -x `which python` python:drop_gil=drop_gil%return pip install &quot;viztracer&gt;=0.11.2&quot; &quot;per4m&gt;=0.1,&lt;0.2&quot; <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\"># module $ giltracer per4m\/example2.py # script $ giltracer -m per4m.example2 # add thread\/process state detection $ giltracer --state-detect -m per4m.example2 # without uprobes (in case that fails) $ giltracer --state-detect --no-gil-detect -m per4m.example2 <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041f\u043b\u0430\u043d\u044b \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435<\/h2>\n<p>  \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043c\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0433\u043e-\u0442\u043e \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432, \u0447\u0435\u043c \u043c\u043e\u0438. \u042f \u0445\u043e\u0447\u0443 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043f\u043b\u0430\u043d\u044b \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\u0420\u0430\u0441\u043a\u043e\u043f\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 VizTracer, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u043c\u0430\u0445\u0438 \u043a\u0435\u0448\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/li>\n<li>\u0412\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0435\u043a\u0430 Python \u0432 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 perf, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 <a href=\"http:\/\/www.brendangregg.com\/offcpuanalysis.html\">http:\/\/www.brendangregg.com\/offcpuanalysis.html<\/a><\/li>\n<li>\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u043e \u0436\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dtrace, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 MacOS.<\/li>\n<li>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 C-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>\u043d\u0435<\/strong> \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0442 GIL (<a href=\"https:\/\/github.com\/vaexio\/vaex\/pull\/1114\">https:\/\/github.com\/vaexio\/vaex\/pull\/1114<\/a>, <a href=\"https:\/\/github.com\/apache\/arrow\/pull\/7756\">https:\/\/github.com\/apache\/arrow\/pull\/7756<\/a> )<\/li>\n<li>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/h5py\/h5py\/issues\/1516\">https:\/\/github.com\/h5py\/h5py\/issues\/1516<\/a><\/li>\n<\/ul>\n<\/div>\n<p> \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\/mailru\/blog\/538706\/\"> https:\/\/habr.com\/ru\/company\/mailru\/blog\/538706\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bw\/9l\/5d\/bw9l5dh0hycrc3t-_317ox9xoqy.jpeg\"><\/p>\n<p>  \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0445, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d Python GIL (The Global Interpreter Lock) (\u044f \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e CPython). \u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e GIL \u043d\u0435 \u0434\u0430\u0451\u0442 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c\u0443 \u0447\u0438\u0441\u0442\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043d\u0430 Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0432 Vaex \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0441 \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u044b\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 \u0421++ \u0441 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c GIL. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 Python\u2014\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 Python \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0440\u043e\u043b\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0432\u0435\u043d\u0430.<\/p>\n<p>  GIL \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044f\u0432\u043d\u043e, \u0438 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0431\u044b\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0430\u043c \u043f\u043e\u0431\u044b\u0432\u0430\u043b \u0432 \u0440\u043e\u043b\u0438 \u0437\u0430\u0431\u044b\u0432\u0448\u0435\u0433\u043e, \u0438 \u043d\u0430\u0448\u0451\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432 <a href=\"https:\/\/github.com\/apache\/arrow\/pull\/7756\">Apache Arrow<\/a> (\u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c Vaex, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 GIL \u043d\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 Arrow, \u043c\u044b (\u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435) \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438).<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043d\u0430 64 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c Vaex \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u043b\u0435\u043a\u0430 \u043e\u0442 \u0438\u0434\u0435\u0430\u043b\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 4000 % \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432\u043c\u0435\u0441\u0442\u043e 6400 %, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0443\u0433\u0430\u0434 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0438 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430, \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 GIL, \u0442\u043e \u0445\u043e\u0447\u0443 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438 \u043a\u0430\u043a \u043e\u043d \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 Vaex.  <\/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-316776","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316776","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=316776"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316776\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}