{"id":22564,"date":"2026-02-20T18:16:10","date_gmt":"2026-02-20T09:16:10","guid":{"rendered":"https:\/\/aireviewirush.com\/?p=22564"},"modified":"2026-02-20T18:16:11","modified_gmt":"2026-02-20T09:16:11","slug":"android-builders-weblog-below-the-hood-android-17s-lock-free-messagequeue","status":"publish","type":"post","link":"https:\/\/aireviewirush.com\/?p=22564","title":{"rendered":"Android Builders Weblog: Below the hood: Android 17\u2019s lock-free MessageQueue"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<meta content=\"https:\/\/your-image-url.jpg\" property=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEh9HS-x-dS4oIQSAyvQoXlWlwO1W37v5h5a__vVR-FebAvk6RbMsaUoYrVGb5StXntTWUxnpdOoKiSJoDaiJLywZ2Nzs9cA9sUFYePmZRapVre5ZpS1dG433g-gEIFsj83u6hvly1OMWc7oNGMSv-Kh7XdxsrfnsVn7YcggG4cRjRNlPUcjkLvuU9sNBCY\/s2469\/Android%2017's%20Lock-Free%20Message%20Queue%20_Meta.png\"\/><i><br \/>\nPosted by Shai Barack, Android Platform Efficiency Lead and Charles Munger, Principal Software program Engineer<\/i><\/p>\n<div class=\"separator\" style=\"clear: both;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhbF0aLhQt_qbYhTnODAOPjkVe_oX0gD1YcEGWy8oxv2dE705ei3plig3iKmoOZf6sd8c4x5VmrMNIOyIEy-dmFlaepcN-rz3B6_SSBqa_7VyEJ5FHR2eYcm-QDuYLOormMWbifm2x_X9_4-loSbaW1EQ4H8PKwDLBiIdvcfNNtNp1JeHacykoeTsS0TUk\/s16000\/Android%2017&#039;s%20Lock-Free%20Message%20Queue%20_Blog.png\" alt=\"\"><\/div>\n<p><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"color: #1f1f1f; font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">In Android 17, apps focusing on SDK 37 or increased will obtain a brand new implementation of MessageQueue the place the implementation is lock-free. The brand new implementation improves efficiency and reduces missed frames, however might break purchasers that mirror on MessageQueue personal fields and strategies. To be taught extra concerning the conduct change and how one can mitigate affect, <\/span><a href=\"http:\/\/developer.android.com\/about\/versions\/17\/changes\/messagequeue\" style=\"font-family: inherit; text-decoration-line: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline;\">try the MessageQueue conduct change documentation<\/span><\/a><span style=\"color: #1f1f1f; font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">. This technical weblog put up gives an summary of the MessageQueue rearchitecture and how one can analyze lock competition points utilizing Perfetto.<\/span><\/p>\n<p><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span id=\"docs-internal-guid-cb816bbb-7fff-c2c6-b98c-600b61b50e52\"><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">The <\/span><a href=\"https:\/\/developer.android.com\/reference\/android\/os\/Looper\" style=\"text-decoration-line: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline; white-space-collapse: preserve;\">Looper<\/span><\/a><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> drives the UI thread of each Android utility. It pulls work from a <\/span><a href=\"https:\/\/developer.android.com\/reference\/android\/os\/MessageQueue\" style=\"text-decoration-line: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline; white-space-collapse: preserve;\">MessageQueue<\/span><\/a><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">, dispatches it to a <\/span><a href=\"https:\/\/developer.android.com\/reference\/android\/os\/Handler\" style=\"text-decoration-line: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline; white-space-collapse: preserve;\">Handler<\/span><\/a><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">, and repeats. For twenty years, <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">MessageQueue<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"> used a single monitor lock (i.e. a <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">synchronized<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">code block) to guard its state.<\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Android 17 introduces a major replace to this part: a lock-free implementation named <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">DeliQueue<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">This put up explains how locks have an effect on UI efficiency, the way to analyze these points with Perfetto, and the particular algorithms and optimizations used to enhance the Android fundamental thread.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span id=\"docs-internal-guid-d608e40a-7fff-aa7d-5000-bff3d09fe2fe\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit; font-size: x-large;\">The issue: Lock Rivalry and Precedence Inversion<\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">The legacy <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">MessageQueue<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">functioned as a precedence queue protected by a single lock. If a background thread posts a message whereas the principle thread performs queue upkeep, the background thread blocks the principle thread.<\/span><\/span><\/p>\n<p><span id=\"docs-internal-guid-fb0fbba7-7fff-7e05-79e8-768946a417ef\"><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">When two or extra threads are competing for unique use of the identical lock, that is referred to as <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline; white-space-collapse: preserve;\">Lock competition<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">. This competition could cause\u00a0<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline; white-space-collapse: preserve;\">Precedence Inversion<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">, resulting in UI jank and different efficiency issues.<\/span><\/span><\/p>\n<p><\/span><span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">Precedence inversion can occur when a high-priority thread (just like the UI thread) is made to attend for a low-priority thread. Take into account this sequence:<\/span><\/span><\/p>\n<ol style=\"margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px;\">\n<li aria-level=\"1\" dir=\"ltr\" style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; margin-left: -12pt; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">A <\/span><span style=\"color: #1f1f1f; font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">low precedence<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\"> background thread acquires the<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">MessageQueue<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\"><span style=\"font-family: inherit;\">lock to put up the results of work that it did.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; margin-left: -12pt; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">A <\/span><span style=\"color: #1f1f1f; font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">medium precedence<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\"> thread turns into runnable and the Kernel&#8217;s scheduler allocates it CPU time, preempting the low precedence thread.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; margin-left: -12pt; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">The <\/span><span style=\"color: #1f1f1f; font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\">excessive precedence<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;\"> UI thread finishes its present process and makes an attempt to learn from the queue, however is blocked as a result of the low precedence thread holds the lock.<\/span><\/span><\/p>\n<\/li>\n<\/ol>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">The low-priority thread blocks the UI thread, and the medium-priority work delays it additional.<\/span><\/span><\/p>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><span id=\"docs-internal-guid-ff649ce9-7fff-0f0a-57eb-a7a10ef70f5b\"><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"border: none; display: inline-block; height: 213px; overflow: hidden; width: 610px;\"><img decoding=\"async\" alt=\"A visual representation of priority inversion. It shows 'Task L' (Low) holding a lock, blocking 'Task H' (High). 'Task M' (Medium) then preempts 'Task L', effectively delaying 'Task H' for the duration of 'Task M's' execution.\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEi5lpXcJrA3CKIi_DnPnYtJ8bfc3vCrdPHToFuPs6CBRpRCjILPIoTP8Z7m_tpfjLWByWLM1I0UlgacedkHg6iAhlj4Ls7v-EmmRAGvcj9WDB_j095S0SECKZkuU89Bb70vDw-B3CiOWkSuu1KAH6-Z-RLN7zjVJgtqitER1Gl6pMgGEnrWtLp9ebS36JY=s16000\" style=\"margin-left: 0px; margin-top: 0px;\"\/><\/span><\/span><\/span><\/div>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit; font-size: large;\"><span id=\"docs-internal-guid-187ea446-7fff-79b9-edff-f48938fe69c4\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">Analyzing competition with Perfetto<\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">You&#8217;ll be able to diagnose these points utilizing <\/span><a href=\"https:\/\/perfetto.dev\/\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #0b57d0; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">Perfetto<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">. In a typical hint, a thread blocked on a monitor lock enters the sleeping state, and Perfetto exhibits a slice indicating the lock proprietor.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Whenever you question hint information, search for slices named \u201cmonitor competition with \u2026\u201d adopted by the title of the thread that owns the lock and the code website the place the lock was acquired.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit; font-size: large;\"><span id=\"docs-internal-guid-800d4400-7fff-1521-47b3-09d8c8a6b964\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">Case research: Launcher jank<\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">As an example, let\u2019s analyze a hint the place a consumer skilled jank whereas navigating dwelling on a Pixel cellphone instantly after taking a photograph within the digital camera app. Under we see a screenshot of Perfetto displaying the occasions main as much as the missed body:<\/span><\/span><\/p>\n<p><\/span><\/p>\n<div class=\"separator\" style=\"clear: both;\"><span style=\"text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial;\"><br \/><img decoding=\"async\" alt=\"A Perfetto trace screenshot diagnosing the Launcher jank. The 'Actual Timeline' shows a red missed frame. Coinciding with this, the main thread track contains a large green slice labeled 'monitor contention with owner BackgroundExecutor,' indicating that the UI thread was blocked because a background thread held the MessageQueue lock.\" border=\"0\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEivHqJIUgTNsk5JKoL8qpiO3vjFfZp-78mTBYD6zWLWbIpQih5o2P-1YdJU57ZEQ2zT959seF1rPzzAmdOFUcMhZqUr67u3YFk5UlqR7UdgVMYpnGU-oFcpEhMtOzaD-8KxTGtaQyL1FpkUqsluy4-cz40e4yzqmiUvG06qmXYd66QnODo-IZJ0tdfps0Q\/s16000\/cTMPgSaPAotGcAJ.png\"\/><\/span><span><span style=\"color: #1f1f1f;\"\/><\/span><\/div>\n<p><span><\/p>\n<ul style=\"margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px;\">\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; margin-left: -12.75pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Symptom:<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> The Launcher fundamental thread missed its body deadline. It blocked for 18ms, which exceeds the 16ms deadline required for 60Hz rendering.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; margin-left: -12.75pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Analysis:<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> Perfetto confirmed the principle thread blocked on the<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">MessageQueue<\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">lock. A \u201cBackgroundExecutor\u201d thread owned the lock.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; margin-left: -12.75pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Root Trigger:<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> The BackgroundExecutor runs at <\/span><a href=\"https:\/\/developer.android.com\/reference\/android\/os\/Process#THREAD_PRIORITY_BACKGROUND\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">Course of.THREAD_PRIORITY_BACKGROUND<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> (very low precedence). It carried out a non-urgent process (checking <\/span><a href=\"https:\/\/www.android.com\/digital-wellbeing\/\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">app utilization limits<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">). Concurrently, medium precedence threads have been utilizing CPU time to course of information from the digital camera. The OS scheduler preempted the BackgroundExecutor thread to run the digital camera threads.<\/span><\/span><\/p>\n<\/li>\n<\/ul>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">This sequence prompted the Launcher\u2019s UI thread (excessive precedence) to change into not directly blocked by the digital camera employee thread (medium precedence), which was protecting the Launcher\u2019s background thread (low precedence) from releasing the lock.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span id=\"docs-internal-guid-88ee6413-7fff-8ea9-af00-483f1856b732\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit; font-size: large;\">Querying traces with PerfettoSQL<\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">You should utilize <\/span><a href=\"https:\/\/perfetto.dev\/docs\/analysis\/perfetto-sql-getting-started\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">PerfettoSQL<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> to <\/span><a href=\"https:\/\/perfetto.dev\/docs\/analysis\/batch-trace-processor\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">question hint information<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> for particular patterns. That is helpful when you&#8217;ve got a big financial institution of traces from consumer gadgets or assessments, and also you\u2019re looking for particular traces that display an issue.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span id=\"docs-internal-guid-009e7aa8-7fff-d370-99b0-84fdc6676791\"><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">For instance, this question finds <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 14.6667px; white-space-collapse: preserve;\">MessageQueue<\/span><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> competition coincident with dropped frames (jank):<\/span><\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">INCLUDE PERFETTO MODULE android.monitor_contention;\nINCLUDE PERFETTO MODULE android.frames.jank_type;\n\n<span style=\"color: blue;\">SELECT<\/span>\n  process_name,\n  <span style=\"color: green;\">-- Convert period from nanoseconds to milliseconds<\/span>\n  <span style=\"color: blue;\">SUM<\/span>(dur) \/ 1000000 <span style=\"color: blue;\">AS<\/span> sum_dur_ms,\n  <span style=\"color: blue;\">COUNT<\/span>(*) <span style=\"color: blue;\">AS<\/span> count_contention\n<span style=\"color: blue;\">FROM<\/span> android_monitor_contention\n<span style=\"color: blue;\">WHERE<\/span> is_blocked_thread_main\n<span style=\"color: blue;\">AND<\/span> short_blocked_method <span style=\"color: blue;\">LIKE<\/span> <span style=\"color: #a31515;\">\"%MessageQueue%\"<\/span> \n\n<span style=\"color: green;\">-- Solely take a look at app processes that had jank<\/span>\n<span style=\"color: blue;\">AND<\/span> upid <span style=\"color: blue;\">IN<\/span> (\n  <span style=\"color: blue;\">SELECT<\/span> <span style=\"color: blue;\">DISTINCT<\/span>(upid)\n  <span style=\"color: blue;\">FROM<\/span> actual_frame_timeline_slice\n  <span style=\"color: blue;\">WHERE<\/span> android_is_app_jank_type(jank_type) = <span style=\"color: blue;\">TRUE<\/span>\n)\n<span style=\"color: blue;\">GROUP<\/span> <span style=\"color: blue;\">BY<\/span> process_name\n<span style=\"color: blue;\">ORDER<\/span> <span style=\"color: blue;\">BY<\/span> <span style=\"color: blue;\">SUM<\/span>(dur) <span style=\"color: blue;\">DESC<\/span>;<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-cd23b24d-7fff-511d-91a4-3bfaf9572d06\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">On this extra complicated instance, be part of hint information that spans a number of tables to establish\u00a0<\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">MessageQueue<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">competition throughout app startup:<\/span><\/span><\/span><\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">INCLUDE PERFETTO MODULE android.monitor_contention; \nINCLUDE PERFETTO MODULE android.startup.startups; \n\n<span style=\"color: green;\">-- Be a part of bundle and course of info for startups<\/span>\n<span style=\"color: blue;\">DROP<\/span> <span style=\"color: blue;\">VIEW<\/span> <span style=\"color: blue;\">IF<\/span> <span style=\"color: blue;\">EXISTS<\/span> startups; \n<span style=\"color: blue;\">CREATE<\/span> <span style=\"color: blue;\">VIEW<\/span> startups <span style=\"color: blue;\">AS<\/span> \n<span style=\"color: blue;\">SELECT<\/span> startup_id, ts, dur, upid \n<span style=\"color: blue;\">FROM<\/span> android_startups \n<span style=\"color: blue;\">JOIN<\/span> android_startup_processes <span style=\"color: blue;\">USING<\/span>(startup_id); \n\n<span style=\"color: green;\">-- Intersect monitor competition with startups in the identical course of.<\/span>\n<span style=\"color: blue;\">DROP<\/span> <span style=\"color: blue;\">TABLE<\/span> <span style=\"color: blue;\">IF<\/span> <span style=\"color: blue;\">EXISTS<\/span> monitor_contention_during_startup; \n<span style=\"color: blue;\">CREATE<\/span> VIRTUAL <span style=\"color: blue;\">TABLE<\/span> monitor_contention_during_startup \n<span style=\"color: blue;\">USING<\/span> SPAN_JOIN(android_monitor_contention PARTITIONED upid, startups PARTITIONED upid); \n\n<span style=\"color: blue;\">SELECT<\/span> \n  process_name, \n  <span style=\"color: blue;\">SUM<\/span>(dur) \/ 1000000 <span style=\"color: blue;\">AS<\/span> sum_dur_ms, \n  <span style=\"color: blue;\">COUNT<\/span>(*) <span style=\"color: blue;\">AS<\/span> count_contention \n<span style=\"color: blue;\">FROM<\/span> monitor_contention_during_startup \n<span style=\"color: blue;\">WHERE<\/span> is_blocked_thread_main \n<span style=\"color: blue;\">AND<\/span> short_blocked_method <span style=\"color: blue;\">LIKE<\/span> <span style=\"color: #a31515;\">\"%MessageQueue%\"<\/span> \n<span style=\"color: blue;\">GROUP<\/span> <span style=\"color: blue;\">BY<\/span> process_name \n<span style=\"color: blue;\">ORDER<\/span> <span style=\"color: blue;\">BY<\/span> <span style=\"color: blue;\">SUM<\/span>(dur) <span style=\"color: blue;\">DESC<\/span>;<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-family: inherit; white-space-collapse: preserve;\">You should utilize your favourite LLM to put in writing PerfettoSQL queries to search out different patterns.<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">At Google, we use <\/span><a href=\"https:\/\/perfetto.dev\/docs\/deployment\/deploying-bigtrace-on-a-single-machine\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">BigTrace<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> to run PerfettoSQL queries throughout hundreds of thousands of traces. In doing so, we confirmed that what we noticed anecdotally was, in reality, a systemic difficulty. The information revealed that <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">MessageQueue<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">lock competition impacts customers throughout your complete ecosystem, substantiating the necessity for a elementary architectural change.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit; font-size: x-large;\"><span id=\"docs-internal-guid-caadd956-7fff-a29d-5997-34cb35714195\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">Answer: lock-free concurrency<\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-7c4e1ceb-7fff-d28b-b090-f03cebcd5def\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">We addressed the<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">MessageQueue<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-family: inherit;\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">competition downside by implementing a <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">lock-free information construction<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">, utilizing atomic reminiscence operations slightly than unique locks to synchronize entry to shared state. An information construction or algorithm is lock-free if a minimum of one thread can all the time make progress whatever the scheduling conduct of the opposite threads. This property is usually exhausting to attain, and is <\/span><a href=\"https:\/\/abseil.io\/docs\/cpp\/atomic_danger\" style=\"text-decoration-line: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline;\">often not price pursuing for many code<\/span><\/a><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">.<\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit; font-size: large;\"><span id=\"docs-internal-guid-297cca04-7fff-13f2-d589-739510c50dee\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">The atomic primitives<\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Lock-free software program typically depends on atomic Learn-Modify-Write primitives that the {hardware} gives.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">On older era ARM64 CPUs, atomics used a Load-Hyperlink\/Retailer-Conditional (LL\/SC) loop. The CPU masses a worth and marks the handle. If one other thread writes to that handle, the shop fails, and the loop retries. As a result of the threads can maintain making an attempt and succeed with out ready for an additional thread, this operation is lock-free.<\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">ARM64 LL\/SC loop instance\nretry:\n    ldxr    x0, [x1]        \/\/ <span style=\"color: blue;\">Load<\/span> <span style=\"color: blue;\">unique<\/span> <span style=\"color: blue;\">from<\/span> handle x1 <span style=\"color: blue;\">to<\/span> x0\n    <span style=\"color: blue;\">add<\/span>     x0, x0, #1      \/\/ <span style=\"color: blue;\">Increment<\/span> worth <span style=\"color: blue;\">by<\/span> 1\n    stxr    w2, x0, [x1]    \/\/ Retailer <span style=\"color: blue;\">unique<\/span>.\n                            \/\/ w2 will get 0 <span style=\"color: blue;\">on<\/span> success, 1 <span style=\"color: blue;\">on<\/span> failure\n    cbnz    w2, retry       \/\/ <span style=\"color: blue;\">If<\/span> w2 <span style=\"color: blue;\">is<\/span> non-zero (failed), department <span style=\"color: blue;\">to<\/span> retr<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(<\/span><a href=\"https:\/\/godbolt.org\/z\/GPs9GeGhG\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">view in Compiler Explorer<\/span><\/a><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">)<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span id=\"docs-internal-guid-5d564034-7fff-04d5-b5ed-235d2cce6df9\"><span style=\"font-family: inherit;\"><br \/><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Newer ARM architectures (ARMv8.1) help <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline; white-space-collapse: preserve;\">Giant System Extensions (LSE)<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> which embrace directions within the type of Evaluate-And-Swap (CAS) or Load-And-Add (demonstrated under). In Android 17 we added help to the Android Runtime (ART) compiler to detect when LSE is supported and emit optimized directions:<\/span><\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">\/ ARMv8.1 LSE <span style=\"color: blue;\">atomic<\/span> instance\nldadd   x0, x1, [x2]    \/\/ <span style=\"color: blue;\">Atomic<\/span> <span style=\"color: blue;\">load<\/span>-<span style=\"color: blue;\">add<\/span>.\n                        \/\/ Sooner, <span style=\"color: blue;\">no<\/span> loop required.<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"color: #1f1f1f; font-family: inherit; white-space-collapse: preserve;\">In our benchmarks, high-contention code that makes use of CAS achieves a ~3x speedup over the LL\/SC variant.<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">The Java programming language presents atomic primitives through<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><a href=\"https:\/\/developer.android.com\/reference\/java\/util\/concurrent\/atomic\/package-summary\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"-webkit-text-decoration-skip: none; background-color: transparent; color: #1155cc; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre;\">java.util.concurrent.atomic<\/span><\/a><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">that depend on these and different specialised CPU directions.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span id=\"docs-internal-guid-495eb21d-7fff-02a9-25c4-6546f5af6e15\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\"><span style=\"font-family: inherit; font-size: x-large;\">The Knowledge Construction: DeliQueue<\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">To take away lock competition from <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">MessageQueue<\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">, our engineers designed a novel information construction referred to as <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">DeliQueue<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">. DeliQueue separates <\/span><span style=\"background-color: transparent; color: #188038; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> insertion from<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">processing:<\/span><\/span><\/p>\n<ol style=\"margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px;\">\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; margin-left: -12pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">The checklist of <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">s (Treiber stack):<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> A lock-free stack. Any thread can push new <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s right here with out competition.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; margin-left: -12pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">The precedence queue (Min-heap):<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> A heap of<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s to deal with, solely owned by the Looper thread (therefore no synchronization or locks are wanted to entry).<\/span><\/span><\/p>\n<\/li>\n<\/ol>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_53 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\" role=\"button\"><label for=\"item-6a22c6cbb50e0\" ><span class=\"\"><span style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input aria-label=\"Toggle\" aria-label=\"item-6a22c6cbb50e0\"  type=\"checkbox\" id=\"item-6a22c6cbb50e0\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-3'><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/aireviewirush.com\/?p=22564\/#Enqueue_pushing_to_a_Treiber_stack\" title=\"Enqueue: pushing to a Treiber stack\">Enqueue: pushing to a Treiber stack<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/aireviewirush.com\/?p=22564\/#Dequeue_bulk_switch_to_a_min-heap\" title=\"Dequeue: bulk switch to a min-heap\">Dequeue: bulk switch to a min-heap<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/aireviewirush.com\/?p=22564\/#Traversal_benign_Java_reminiscence_mannequin_information_races\" title=\"Traversal: benign Java reminiscence mannequin information races\">Traversal: benign Java reminiscence mannequin information races<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/aireviewirush.com\/?p=22564\/#Testing_and_Validation\" title=\"Testing and Validation\">Testing and Validation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/aireviewirush.com\/?p=22564\/#Subsequent_steps\" title=\"Subsequent steps\">Subsequent steps<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/aireviewirush.com\/?p=22564\/#References\" title=\"References\">References<\/a><\/li><\/ul><\/nav><\/div>\n<h3 dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 6pt;\"><span class=\"ez-toc-section\" id=\"Enqueue_pushing_to_a_Treiber_stack\"><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit; font-size: large;\">Enqueue: pushing to a Treiber stack<\/span><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">The checklist of<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s is saved in a Treiber stack [1], a lock-free stack that makes use of a CAS loop to replace the top pointer.<\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\"><span style=\"color: blue;\">public<\/span> <span style=\"color: blue;\">class<\/span> <span style=\"color: #2b91af;\">TreiberStack<\/span> &lt;E&gt; {\n    AtomicReference&lt;Node&lt;E&gt;&gt; high =\n            <span style=\"color: blue;\">new<\/span> AtomicReference&lt;Node&lt;E&gt;&gt;();\n    <span style=\"color: blue;\">public<\/span> <span style=\"color: #2b91af;\">void<\/span> push(E merchandise) {\n        Node&lt;E&gt; newHead = <span style=\"color: blue;\">new<\/span> Node&lt;E&gt;(merchandise);\n        Node&lt;E&gt; oldHead;\n        <span style=\"color: blue;\">do<\/span> {\n            oldHead = high.get();\n            newHead.subsequent = oldHead;\n        } <span style=\"color: blue;\">whereas<\/span> (!high.compareAndSet(oldHead, newHead));\n    }\n\n    <span style=\"color: blue;\">public<\/span> E pop() {\n        Node&lt;E&gt; oldHead;\n        Node&lt;E&gt; newHead;\n        <span style=\"color: blue;\">do<\/span> {\n            oldHead = high.get();\n            <span style=\"color: blue;\">if<\/span> (oldHead == <span style=\"color: blue;\">null<\/span>) <span style=\"color: blue;\">return<\/span> <span style=\"color: blue;\">null<\/span>;\n            newHead = oldHead.subsequent;\n        } <span style=\"color: blue;\">whereas<\/span> (!high.compareAndSet(oldHead, newHead));\n        <span style=\"color: blue;\">return<\/span> oldHead.merchandise;\n    }\n}<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span id=\"docs-internal-guid-86bfc1f0-7fff-7ba3-667b-6338b7f6e2d2\"><span style=\"font-family: inherit;\"><span style=\"font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Supply code based mostly on Java Concurrency in Follow [2], <\/span><a href=\"https:\/\/jcip.net\/listings\/ConcurrentStack.java\" style=\"text-decoration-line: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc; font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline; white-space-collapse: preserve;\">accessible on-line<\/span><\/a><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> and launched to the general public area<\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Any producer can push new<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s to the stack at any time. That is like pulling a ticket at a deli counter &#8211; your quantity is decided by while you confirmed up, however the order you get your meals in does not should match. As a result of it is a linked stack, ever<\/span><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">y<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">is a sub-stack &#8211; you&#8217;ll be able to see what the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">queue was like at any cut-off date by monitoring the top and iterating forwards &#8211; you will not see any new<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s pushed on high, even when they&#8217;re being added throughout your traversal.<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"\/><\/p>\n<p><\/span><\/p>\n<h3 dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span class=\"ez-toc-section\" id=\"Dequeue_bulk_switch_to_a_min-heap\"><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit; font-size: large;\">Dequeue: bulk switch to a min-heap<\/span><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">To seek out the subsequent <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">to deal with, the<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">processes new<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">from the Treiber stack by strolling the stack ranging from the highest and iterating till it finds the final<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> that it beforehand processed. Because the<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> traverses down the stack, it inserts <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s into the deadline-ordered min-heap. For the reason that Looper solely owns the heap, it orders and processes<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s with out locks or atomics.<\/span><\/span><\/p>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><span style=\"border: none; display: inline-block; height: 91px; margin-left: 1em; margin-right: 1em; overflow: hidden; width: 610px;\"><img decoding=\"async\" alt=\"A system diagram illustrating the DeliQueue architecture. Concurrent producer threads (left) push messages onto a shared 'Lock-Free Treiber Stack' using atomic CAS operations. The single consumer 'Looper Thread' (right) claims these messages via an atomic swap, merges them into a private 'Local Min-heap' sorted by timestamp, and then executes them.\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEhknkVSDfMX-ZahCjfG4tSxzMtW4QHU0mzm_9vw2wXNMM1DY3oOy-sHeejjN-huSAGJAjVJzl47NUlVlVKNswK4KHkW0dTCEoeIZqYspMEI6KIy56S9d0AQWUMa1amuWA6WAWr1naU4_5SrqSr1GYzMsekgmJgjcs43lb4C5YGznm6g3AC3uwAQDFZJnLk=s16000\" style=\"margin-left: 0px; margin-top: 0px;\"\/><\/span><\/div>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">In strolling down the stack, the <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Looper<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">additionally creates hyperlinks from stacked<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Message<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">s again to their predecessors, thus forming a doubly-linked checklist. Creating the linked checklist is protected as a result of hyperlinks pointing down the stack are added through the Treiber stack algorithm with CAS, and hyperlinks up the stack are solely ever learn and modified by the<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Looper<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">thread. These back-links are then used to take away<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Message<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">s from arbitrary factors within the stack in O(1) time.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">This design gives<span style=\"font-family: inherit;\">\u00a0<\/span><\/span><\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><i>O<\/i>(1)<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"font-family: inherit;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">insertion for producers (threads posting work to the queue) and amortized <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><i>O<\/i>(log <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">N)<\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> processing for the buyer (the<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Looper<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">).<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Utilizing a min-heap to order <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s additionally addresses a elementary flaw within the legacy <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">MessageQueue<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">, <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">the place<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">s have been saved in a singly-linked checklist (rooted on the high). Within the legacy implementation, removing from the top was <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><i>O<\/i><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(1)<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">, however insertion had a worst case of <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><i>O(N)<\/i><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> \u2013 scaling poorly for overloaded queues! Conversely, insertion to and removing from the min-heap scale logarithmically, delivering aggressive common efficiency however actually excelling in tail latencies.<\/span><\/span><\/p>\n<div align=\"center\" dir=\"ltr\" style=\"margin-left: 0pt;\">\n<table style=\"border-collapse: collapse; border: none;\">\n<colgroup>\n<col width=\"233\"\/>\n<col width=\"233\"\/>\n<col width=\"233\"\/><\/colgroup>\n<tbody>\n<tr style=\"height: 0pt;\">\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\"><span style=\"font-family: inherit;\"><br \/><\/span><\/td>\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Legacy (locked) <\/span><span style=\"background-color: transparent; color: #188038; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">MessageQueue<\/span><\/span><\/p>\n<\/td>\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">DeliQueue<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"height: 0pt;\">\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Insert<\/span><\/span><\/p>\n<\/td>\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><i><span style=\"font-family: inherit;\">O(N)<\/span><\/i><\/span><\/p>\n<\/td>\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><i>O<\/i><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(1)<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> for calling thread<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><i>O(logN)<\/i><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> for <\/span><span style=\"background-color: transparent; color: #188038; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Looper<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> thread<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"height: 0pt;\">\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Take away from head<\/span><\/span><\/p>\n<\/td>\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"><i>O<\/i>(1)<\/span><\/span><\/p>\n<\/td>\n<td style=\"border-bottom: solid #000000 1pt; border-color: rgb(0, 0, 0); border-left: solid #000000 1pt; border-right: solid #000000 1pt; border-style: solid; border-top: solid #000000 1pt; border-width: 1pt; overflow-wrap: break-word; overflow: hidden; padding: 5pt; vertical-align: top;\">\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"><i>O(logN)<\/i><\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Within the legacy queue implementation, producers and the buyer used a lock to coordinate unique entry to the underlying singly-linked checklist. In DeliQueue, the Treiber stack handles concurrent entry, and the only client handles ordering its work queue.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span id=\"docs-internal-guid-7066d0a0-7fff-996d-8718-93fca15b620f\"><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\"><span style=\"font-family: inherit; font-size: large;\">Removing: consistency through tombstones<\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">DeliQueue is a hybrid information construction, becoming a member of a lock-free Treiber stack with a single-threaded min-heap. Protecting these two buildings in sync with no international lock presents a novel problem: a message is likely to be bodily current within the stack however logically faraway from the queue.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">To resolve this, DeliQueue makes use of a method referred to as \u201ctombstoning.\u201d Every <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">tracks its place within the stack through the backwards and forwards pointers, its index within the heap\u2019s array, and a boolean flag indicating whether or not it has been eliminated. When a<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">is able to run, the<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">thread will CAS its eliminated flag, then take away it from the heap and stack.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">When one other thread must take away a <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Message<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">, it does not instantly extract it from the info construction. As an alternative, it performs the next steps:<\/span><\/span><\/p>\n<ol style=\"margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px;\">\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Logical removing: the thread makes use of a CAS to atomically set the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">\u2019s removing flag from false to true. The<\/span><\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">stays within the information construction as proof of its pending removing, a so-called \u201ctombstone\u201d. As soon as a<\/span><\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">is flagged for removing, DeliQueue treats it as if it not exists within the queue at any time when it\u2019s discovered.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Deferred cleanup: The precise removing from the info construction is the accountability of the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Looper<\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">thread, and is deferred till later. Moderately than modifying the stack or heap, the remover thread provides the<\/span><\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> to a different lock-free freelist stack.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Structural removing: Solely the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Looper<\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">can work together with the heap or take away parts from the stack. When it wakes up, it clears the freelist and processes the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Messages<\/span><span face=\"Arial, sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">it contained. Every <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Message<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> is then unlinked from the stack and faraway from the heap.\u00a0<\/span><\/span><\/p>\n<\/li>\n<\/ol>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">This strategy retains all administration of the heap single-threaded. It minimizes the variety of concurrent operations and reminiscence boundaries required, making the important path quicker and easier.<\/span><\/span><\/p>\n<h3 dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 12pt; margin-top: 12pt;\"><span class=\"ez-toc-section\" id=\"Traversal_benign_Java_reminiscence_mannequin_information_races\"><\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit; font-size: x-large;\">Traversal: benign Java reminiscence mannequin information races<\/span><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span id=\"docs-internal-guid-7b3bd3a2-7fff-efe7-f706-1d994d79f9ed\" style=\"font-weight: normal;\"><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">Most concurrency APIs, similar to<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Future<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">within the Java normal library, or Kotlin\u2019s <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Job<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">and<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Deferred<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">, i<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">nclude a mechanism to cancel work earlier than it completes. An occasion of certainly one of these lessons matches 1:1 with a unit of underlying work, and calling<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">cancel<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">on an object cancels the particular operations related to them.<\/span><\/span><\/p>\n<p><span style=\"font-family: inherit;\"><br \/><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">Right this moment\u2019s Android gadgets have multi-core CPUs and concurrent, generational rubbish assortment. However when Android was first developed, it was too costly to allocate one object for every unit of labor. Consequently, Android\u2019s <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Handler<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">helps cancellation through quite a few overloads of <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">removeMessages<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> &#8211;<\/span><span style=\"font-family: inherit;\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> slightly than eradicating a <\/span><span style=\"font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">particular<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Message<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">, it removes all<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Message<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">s that match the desired standards. In apply, this requires iterating by all<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Message<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">s inserted earlier than<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">removeMessages<\/span><span face=\"Arial, sans-serif\" style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-size: 11pt;\"> <\/span><span style=\"font-family: inherit;\">w<\/span><\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">as referred to as and eradicating those that match.<\/span><\/span><\/p>\n<p><span style=\"font-family: inherit;\"><br \/><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">When iterating ahead, a thread solely requires one ordered atomic operation, to learn the present head of the stack. After that, unusual area reads are used to search out the subsequent<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Message<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">. If the<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Looper<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">thread modifies the<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">subsequent<\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">fields whereas eradicating<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Message<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">s, the<\/span><\/span><span face=\"Arial, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Looper<\/span><span style=\"font-family: inherit;\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">\u2019s write and one other thread\u2019s learn are unsynchronized &#8211; this can be a <\/span><span style=\"font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">information race<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">. Usually, an information race is a critical bug that may trigger large issues in your app &#8211; leaks, infinite loops, crashes, freezes, and extra. Nonetheless, beneath sure slim circumstances, information races could be benign throughout the Java Reminiscence Mannequin. Suppose we begin with a stack of:<\/span><\/span><\/span><\/span><\/div>\n<div class=\"separator\" style=\"clear: both; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><img decoding=\"async\" alt=\"A diagram showing the initial state of the message stack as a linked list. The 'Head' points to 'Message A', which links sequentially to 'Message B', 'Message C', and 'Message D'.\" border=\"0\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgD58rsF7QpfHdZD0-4Y4YT4yn7pyFUvRU8ngHUs2T748AcOKAPQYJ_rn_dUg28-Q_Rc0XH3O7qlD9dGwMdoURapme0STqflbdfgUFqz9xBIjkx1Mn0GW_2H357NtAjHDiFGMEsv-GxLQTTN8qq8UycW_l-liJ6EliM76rUdhX0kMU15DjTMbT60I0-d1w\/s16000\/graphviz_linked.png\"\/><span><span style=\"color: #1f1f1f;\"><span style=\"font-family: inherit;\"><span><span\/><\/span><\/span><\/span><\/span><\/div>\n<p><span><span style=\"color: #1f1f1f;\"><span style=\"font-family: inherit;\"><span><span><br \/><span style=\"font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span id=\"docs-internal-guid-d19b183b-7fff-69c0-a5e3-ff92ce37f956\"\/><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">We carry out an atomic learn of the top, and see A. A\u2019s <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">subsequent<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">pointer factors to B. Similtaneously we course of B, the looper may take away B and C, by updating A to level to C after which D.<\/span><\/span><\/p>\n<p><span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-da0e0bca-7fff-aea9-7d44-3ba98b9d79ec\"><span face=\"Arial, sans-serif\" style=\"color: black; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"border: none; display: inline-block; height: 176px; overflow: hidden; width: 610px;\"><img decoding=\"async\" alt=\"A diagram illustrating a benign data race during list traversal. The Looper thread has updated 'Message A' to point directly to 'Message D', effectively removing 'Message B' and 'Message C'. Simultaneously, a concurrent thread reads a stale 'next' pointer from A, traverses through the logically removed messages B and C, and eventually rejoins the live list at 'Message D'.\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEiBEhPBhBTaFMF-1L8t05OMQMm08iWVMG_HGWmCLG9gjEJN87ScZLxovnX8VrbO4RFbRi_Ctw1_0U_BeQVIqAZ3emlxkPhvzXIg3WB3ijOOHRnkqJnnqo43l4G7P1WVU-y8IfENFunduyHnfUewRh2yf_4EM7sbo7BIZDPG1wsDWoN6WbHEePS39mwq1ZE=s16000\" style=\"margin-left: 0px; margin-top: 0px;\"\/><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Although<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">B<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> and <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">C<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">are logically eliminated, <\/span><span style=\"background-color: transparent; color: #188038; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">B<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> retains its subsequent pointer to<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">C<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">,<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> and<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">C<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">to <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">D<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">. The studying thread continues traversing by the indifferent eliminated nodes and finally rejoins the dwell stack at <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">D<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">.<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">By designing DeliQueue to deal with races between traversal and removing, we permit for protected, lock-free iteration.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit; font-size: x-large;\"><span id=\"docs-internal-guid-b6b28ebe-7fff-e906-929e-1c17c3e00167\"><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">Quitting: Native refcount<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">is backed by a local allocation that should be manually freed as soon as the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\"> has stop. If another thread is including <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s whereas the<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">is quitting, it might use the native allocation after it\u2019s freed, a reminiscence security violation. We stop this utilizing a <\/span><span style=\"background-color: transparent; color: black; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">tagged refcount<\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">, the place one little bit of the atomic is used to point whether or not the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">is quitting.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Earlier than utilizing the native allocation, a thread reads the refcount atomic. If the quitting bit is about, it returns that the<\/span><\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">is quitting and the native allocation should not be used. If not, it makes an attempt a CAS to increment the variety of lively threads utilizing the native allocation. After doing what it must, it decrements the depend. If the quitting bit was set after its increment however earlier than the decrement, and the depend is now zero, then it wakes up the <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Looper<\/span><span face=\"Arial,sans-serif\" style=\"background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">thread.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">When the<\/span><\/span><span face=\"Arial, sans-serif\" style=\"color: black; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Looper<\/span><span face=\"Arial, sans-serif\" style=\"color: black; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">thread is able to stop, it makes use of CAS to set the quitting bit within the atomic. If the refcount was 0, it will possibly proceed to free its native allocation. In any other case, it parks itself, understanding that it is going to be woken up when the final consumer of the native allocation decrements the refcount. This strategy does imply that the <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Looper<\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"> thread waits for the progress of different threads, however solely when it\u2019s quitting. That solely occurs as soon as and isn&#8217;t efficiency delicate, and it retains the opposite code for utilizing the native allocation absolutely lock-free.<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-852f4e36-7fff-947e-9e8f-7e83afeba2c0\"><span face=\"Arial, sans-serif\" style=\"color: black; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"border: none; display: inline-block; height: 165px; overflow: hidden; width: 610px;\"><img decoding=\"async\" alt=\"A state diagram illustrating the tagged refcount mechanism for safe termination. It defines three states based on the atomic value's layout (Bit 63 for teardown, Bits 0-62 for refcount):  Active (Green): The teardown bit is 0. Workers successfully increment and decrement the reference count.  Draining (Yellow): The Looper has set the teardown bit to 1. New worker increments fail, but existing workers continue to decrement.  Terminated (Red): Occurs when the reference count reaches 0 while draining. The Looper is signaled that it is safe to destroy the native allocation.\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEhnTvDsIwwQfH8V_jK3KwyjtRolyycTjQqqezIEVYspluGZCVNIWpEJA7bFV2iEYXFpTF7XFfdoYaWVamWAre916Uv8nPhRJ7hOddqT2nEymLewlKXvRffzgYRneFMuxflq8GnPyaTf3-gMx-JDf3Jk6YIxP4fUAJ8TcSmGkcI82Pubf6R3YvSlcjoSd-U=s16000\" style=\"margin-left: 0px; margin-top: -1.9174px;\"\/><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">There\u2019s a number of different tips and complexity within the implementation. You&#8217;ll be able to be taught extra about DeliQueue by reviewing the <\/span><\/span><\/span><span style=\"font-family: inherit;\">supply code.<\/span><\/p>\n<p><span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit; font-size: x-large;\"><span id=\"docs-internal-guid-3b24281c-7fff-389c-3612-edc3b2f073fb\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">Optimization: branchless programming<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Whereas growing and testing DeliQueue, the workforce ran many benchmarks and thoroughly profiled the brand new code. One difficulty recognized utilizing the <\/span><a href=\"https:\/\/developer.android.com\/ndk\/guides\/simpleperf\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">simpleperf software<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> was pipeline flushes brought on by the<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">comparator code.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-d54d4939-7fff-59af-c65d-7f66993a98bb\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">A normal comparator makes use of conditional jumps, with the situation for deciding which<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Message<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">comes first simplified under:<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\"><span style=\"color: blue;\">static<\/span> <span style=\"color: #2b91af;\">int<\/span> compareMessages(@NonNull Message m1, @NonNull Message m2) {\n    <span style=\"color: blue;\">if<\/span> (m1 == m2) {\n        <span style=\"color: blue;\">return<\/span> 0;\n    }\n\n    <span style=\"color: green;\">\/\/ Major queue order is by when.<\/span>\n    <span style=\"color: green;\">\/\/ Messages with an earlier when ought to come first within the queue.<\/span>\n    <span style=\"color: blue;\">last<\/span> <span style=\"color: #2b91af;\">lengthy<\/span> whenDiff = m1.when - m2.when;\n    <span style=\"color: blue;\">if<\/span> (whenDiff &gt; 0) <span style=\"color: blue;\">return<\/span> 1;\n    <span style=\"color: blue;\">if<\/span> (whenDiff &lt; 0) <span style=\"color: blue;\">return<\/span> -1;\n\n    <span style=\"color: green;\">\/\/ Secondary queue order is by insert sequence.<\/span>\n    <span style=\"color: green;\">\/\/ If two messages have been inserted with the identical `when`, the one inserted<\/span>\n    <span style=\"color: green;\">\/\/ first ought to come first within the queue.<\/span>\n    <span style=\"color: blue;\">last<\/span> <span style=\"color: #2b91af;\">lengthy<\/span> insertSeqDiff = m1.insertSeq - m2.insertSeq;\n    <span style=\"color: blue;\">if<\/span> (insertSeqDiff &gt; 0) <span style=\"color: blue;\">return<\/span> 1;\n    <span style=\"color: blue;\">if<\/span> (insertSeqDiff &lt; 0) <span style=\"color: blue;\">return<\/span> -1;\n\n    <span style=\"color: blue;\">return<\/span> 0;\n}<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">This code compiles to conditional jumps (<\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">b.le<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">\u00a0<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">and\u00a0<\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">cbnz<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">\u00a0<\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">directions). When the CPU encounters a conditional department, it will possibly\u2019t know whether or not the department is taken till the situation is computed, so it doesn\u2019t know which instruction to learn subsequent, and has to guess, utilizing a method referred to as <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">department prediction<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">. In a case like binary search, the department path will likely be unpredictably totally different at every step, so it\u2019s probably that half the predictions will likely be incorrect. Department prediction is commonly ineffective in looking and sorting algorithms (such because the one utilized in a min-heap), as a result of the price of guessing incorrect is bigger than the development from guessing appropriately. When the department predictor guesses incorrect, it should throw away the work it did after assuming the expected worth, and begin once more from the trail that was truly taken &#8211; that is referred to as a <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">pipeline flush<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">To seek out this difficulty, we profiled our benchmarks utilizing the<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">branch-misses<\/span><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> efficiency counter, which data stack traces the place the department predictor guesses incorrect. We then visualized the outcomes with <\/span><a href=\"https:\/\/github.com\/google\/pprof\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">Google pprof<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">, as proven under:<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-514a00fc-7fff-6f2a-7a9a-dd53920fe6a1\"><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"border: none; display: inline-block; height: 293px; overflow: hidden; width: 610px;\"><img decoding=\"async\" alt=\"A screenshot from the pprof web UI showing branch misses in MessageQueue code to compare Message instances while performing heap operations.\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEhWzEoCloyBTPrjN-l1Z_g9erTzvYdJSAN_Kl03J5BqreA5Tdb_T9HG0LfenFzE2BkN5GTaeiIqAtQNqmcGjhTsu7vfEj2D-51hUjLaQssZo6pV8jiv8FtLFOmEnqZdfanKNYQ1oOWDAaKEzfSZbV9NVcxVYkXW_dw663Z5DDPUaS8NJwrXzSgTrxtT13k=s16000\" style=\"margin-left: -6.78561e-14px; margin-top: 0px;\"\/><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">Recall that the unique <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">MessageQueue<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">code used a singly-linked checklist for the ordered queue. Insertion would traverse the checklist in sorted order as a linear search, stopping on the first ingredient that\u2019s previous the purpose of insertion and linking the brand new <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">Message<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">forward of it. Removing from the top merely required unlinking the top. Whereas DeliQueue makes use of a min-heap, the place mutations require reordering some parts (sifting up or down) with logarithmic complexity in a balanced information construction, the place any comparability has a fair likelihood of directing the traversal to a left youngster or to a proper youngster. The brand new algorithm is asymptotically quicker, however exposes a brand new bottleneck because the search code stalls on department misses half the time.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-fd635632-7fff-cd6b-4491-00a8cba98612\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Realizing that department misses have been slowing down our heap code, we optimized the code utilizing <\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">branch-free programming<\/span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">:<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\"><span style=\"color: green;\">\/\/ Branchless Logic<\/span>\n<span style=\"color: blue;\">static<\/span> <span style=\"color: #2b91af;\">int<\/span> compareMessages(@NonNull Message m1, @NonNull Message m2)  (-num &gt;&gt;&gt; 63))<\/span>\n    <span style=\"color: blue;\">last<\/span> <span style=\"color: #2b91af;\">int<\/span> whenSign = Lengthy.signum(when1 - when2);\n    <span style=\"color: blue;\">last<\/span> <span style=\"color: #2b91af;\">int<\/span> insertSeqSign = Lengthy.signum(insertSeq1 - insertSeq2);\n\n    <span style=\"color: green;\">\/\/ whenSign takes priority over insertSeqSign,<\/span>\n    <span style=\"color: green;\">\/\/ so the method under is such that insertSeqSign solely issues<\/span>\n    <span style=\"color: green;\">\/\/ as a tie-breaker if whenSign is 0.<\/span>\n    <span style=\"color: blue;\">return<\/span> whenSign * 2 + insertSeqSign;\n<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">To know the optimization, <\/span><a href=\"https:\/\/godbolt.org\/z\/bvGh7aadG\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">disassemble the 2 examples in Compiler Explorer<\/span><\/a><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> and use <\/span><a href=\"https:\/\/llvm.org\/docs\/CommandGuide\/llvm-mca.html\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">LLVM-MCA<\/span><\/a><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">, a CPU simulator that may generate an <\/span><a href=\"https:\/\/godbolt.org\/z\/EYxn6MasE\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">estimated timeline of CPU cycles<\/span><\/a><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.<\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">The unique code:\n<span style=\"color: blue;\">Index<\/span>     01234567890123\n[0,0]     DeER .    .  .   sub  x0, x2, x3\n[0,1]     D=eER.    .  .   cmp  x0, #0\n[0,2]     D==eER    .  .   cset w0, ne\n[0,3]     .D==eER   .  .   cneg w0, w0, lt\n[0,4]     .D===eER  .  .   cmp  w0, #0\n[0,5]     .D====eER .  .   b.le #12\n[0,6]     . DeE<span style=\"color: green;\">---R .  .   mov  w1, #1<\/span>\n[0,7]     . DeE<span style=\"color: green;\">---R .  .   b    #48<\/span>\n[0,8]     . D==eE-R .  .   tbz  w0, #31, #12\n[0,9]     .  DeE<span style=\"color: green;\">--R .  .   mov  w1, #-1<\/span>\n[0,10]    .  DeE<span style=\"color: green;\">--R .  .   b    #36<\/span>\n[0,11]    .  D=eE-R .  .   sub  x0, x4, x5\n[0,12]    .   D=eER .  .   cmp  x0, #0\n[0,13]    .   D==eER.  .   cset w0, ne\n[0,14]    .   D===eER  .   cneg w0, w0, lt\n[0,15]    .    D===eER .   cmp  w0, #0\n[0,16]    .    D====eER.   csetm        w1, lt\n[0,17]    .    D===eE-R.   cmp  w0, #0\n[0,18]    .    .D===eER.   csinc        w1, w1, wzr, le\n[0,19]    .    .D====eER   mov  x0, x1\n[0,20]    .    .DeE<span style=\"color: green;\">----R   ret<\/span><\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-32bdaff2-7fff-460b-89b2-ff05a7840904\"><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">Observe the one conditional department, <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">b.le<\/span><span face=\"Arial, sans-serif\" style=\"color: black; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">,\u00a0 <\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">which avoids evaluating the<\/span><\/span><span face=\"Arial, sans-serif\" style=\"color: black; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">insertSeq <\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\">fields if the result&#8217;s already identified from evaluating the <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">when<\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"> fields.<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">The branchless code:\n<span style=\"color: blue;\">Index<\/span>     012345678\n[0,0]     DeER .  .   sub       x0, x2, x3\n[0,1]     DeER .  .   sub       x1, x4, x5\n[0,2]     D=eER.  .   cmp       x0, #0\n[0,3]     .D=eER  .   cset      w0, ne\n[0,4]     .D==eER .   cneg      w0, w0, lt\n[0,5]     .DeE<span style=\"color: green;\">--R .   cmp       x1, #0<\/span>\n[0,6]     . DeE-R .   cset      w1, ne\n[0,7]     . D=eER .   cneg      w1, w1, lt\n[0,8]     . D==eeER   <span style=\"color: blue;\">add<\/span>       w0, w1, w0, lsl #1\n[0,9]     .  DeE<span style=\"color: green;\">--R   ret<\/span><\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Right here, the branchless implementation takes fewer cycles and directions than even the shortest path by the branchy code &#8211; it\u2019s higher in all circumstances. The quicker implementation plus the elimination of mispredicted branches resulted in a 5x enchancment in a few of our benchmarks!<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><br \/><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">Nonetheless, this method just isn&#8217;t all the time relevant. Branchless approaches usually require doing work that will likely be thrown away, and if the department is predictable more often than not, that wasted work can gradual your code down. As well as, eradicating a department typically introduces a <\/span><span style=\"color: black; font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">information dependency<\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">. Trendy CPUs execute a number of operations per cycle, however they will\u2019t execute an instruction till its inputs from a earlier instruction are prepared. In distinction, a CPU can <\/span><span style=\"color: black; font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\">speculate<\/span><span style=\"color: black; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"> about information in branches, and work forward if a department is predicted appropriately.<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<h2 dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span class=\"ez-toc-section\" id=\"Testing_and_Validation\"><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit; font-size: x-large;\">Testing and Validation<\/span><\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">Validating the correctness of lock-free algorithms is notoriously troublesome!<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Along with normal unit assessments for steady validation throughout improvement, we additionally wrote rigorous <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">stress assessments<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> to confirm queue invariants and to aim to induce information races in the event that they existed. In our take a look at labs we might run hundreds of thousands of take a look at situations on emulated gadgets and on actual {hardware}.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">With <\/span><a href=\"https:\/\/github.com\/google\/java-thread-sanitizer\" style=\"text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"background-color: transparent; color: #1155cc; font-style: normal; font-variant: normal; font-weight: 700; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;\">Java ThreadSanitizer<\/span><\/a><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> (JTSan) instrumentation, we might use the identical assessments to additionally detect some information races in our code. JTSan didn&#8217;t discover any problematic information races in DeliQueue, however &#8211; surprisingly -actually detected two concurrency bugs within the Robolectric framework, which we promptly fastened.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 6pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">To enhance our debugging capabilities, we constructed new <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">evaluation instruments<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">. Under is an instance displaying a difficulty in Android platform code the place one thread is overloading one other thread with <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">Message<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">s, inflicting a big backlog, seen in Perfetto because of the<\/span><\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">MessageQueue<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">instrumentation function that we added.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\"><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit;\"><span id=\"docs-internal-guid-90c3fbfa-7fff-1a60-444e-9414aa435c50\"><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"border: none; display: inline-block; height: 471px; overflow: hidden; width: 610px;\"><img decoding=\"async\" alt=\"A screenshot of Perfetto UI, demonstrating flows and metadata for Messages being posted to a MessageQueue and delivered to a worker thread.\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEj6PDjipHRYCZTdaA0a9JAXFqW98l1DBKt1sJGKzSgxpYI9oevK5sjG7sdBHDCjwFyK9VZfTbmHmA5NK9Z5cJ5dLxFb7FP7Lw_07AmtaBT4yKs9Gsyz3QeeifZghO09Qk0ZTsbTIMVKmRrT34-VLQmB47qTTKPSm6BeSPiBSASooYIR5yR7AcoRV7utUKc=s16000\" style=\"margin-left: 0px; margin-top: 0px;\"\/><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">To allow <\/span><\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">MessageQueue<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">tracing within the<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\">system_server<\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"color: #1f1f1f; font-size: 11pt; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"> <\/span><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span style=\"font-family: inherit;\">course of, embrace the next in your Perfetto configuration:<\/span><\/span><\/p>\n<pre style=\"color: #333333; line-height: 16.25px; margin: 0px;\">data_sources {\n  config {\n    title: <span style=\"color: #a31515;\">\"track_event\"<\/span>\n    target_buffer: 0  <span style=\"color: green;\"># Change this per your buffers configuration<\/span>\n    track_event_config {\n      enabled_categories: <span style=\"color: #a31515;\">\"mq\"<\/span>\n    }\n  }\n}<\/pre>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"color: #1f1f1f; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;\"><span><span><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline;\"><span style=\"font-family: inherit; font-size: x-large;\"><span id=\"docs-internal-guid-9d707054-7fff-6660-7d56-bf741066320f\"><span style=\"font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline;\">Impression<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">DeliQueue improves system and app efficiency by eliminating locks from <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">MessageQueue<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">.<\/span><\/p>\n<ul style=\"margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px;\">\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; margin-left: -12.75pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Artificial benchmarks:<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> multi-threaded insertions into busy queues is as much as <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">5,000x quicker<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> than the legacy<\/span><\/span><span face=\"&quot;Google Sans Text&quot;, sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> <\/span><span style=\"background-color: transparent; color: #188038; font-family: &quot;Roboto Mono&quot;, monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">MessageQueue<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">, because of improved concurrency (the Treiber stack) and quicker insertions (the min-heap).<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; margin-left: -12.75pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"font-family: inherit;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">In <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Perfetto traces acquired from inner beta testers<\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">, we see a discount of 15% in app fundamental thread time spent in lock competition.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"1\" dir=\"ltr\" style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; margin-left: -12.75pt; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">On the identical take a look at gadgets, the diminished lock competition results in vital enhancements to the consumer expertise, similar to:<\/span><\/span><\/p>\n<\/li>\n<ul style=\"margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px;\">\n<li aria-level=\"2\" dir=\"ltr\" style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">-4% missed frames in apps.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"2\" dir=\"ltr\" style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">-7.7% missed frames in System UI and Launcher interactions.<\/span><\/span><\/p>\n<\/li>\n<li aria-level=\"2\" dir=\"ltr\" style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline; white-space: pre;\">\n<p dir=\"ltr\" role=\"presentation\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">-9.1% in time from app startup to the primary body drawn, on the 95percentile.<\/span><\/span><\/p>\n<\/li>\n<\/ul>\n<\/ul>\n<h2 dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 6pt;\"><span class=\"ez-toc-section\" id=\"Subsequent_steps\"><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit; font-size: large;\">Subsequent steps<\/span><\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">DeliQueue is rolling out to apps in Android 17. App builders ought to evaluate getting ready your app for the brand new lock-free <\/span><\/span><span style=\"background-color: transparent; color: #188038; font-family: 'Roboto Mono',monospace; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\">MessageQueue<\/span><span face=\"'Google Sans Text',sans-serif\" style=\"background-color: transparent; color: #1f1f1f; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;\"> <\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">on the Android Builders weblog to discover ways to take a look at their apps.<\/span><\/span><\/p>\n<h2 dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 6pt;\"><span class=\"ez-toc-section\" id=\"References\"><\/span><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit; font-size: large;\">References<\/span><\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">[1] Treiber, R.Okay., 1986. Programs programming: Dealing with parallelism. Worldwide Enterprise Machines Included, Thomas J. Watson Analysis Middle.<\/span><\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-top: 6pt;\"><span style=\"background-color: transparent; color: #1f1f1f; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: inherit;\">[2] Goetz, B., Peierls, T., Bloch, J., Bowbeer, J., Holmes, D., &amp; Lea, D. (2006). Java Concurrency in Follow. Addison-Wesley Skilled.<\/span><\/span><\/p>\n<p><\/span>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Posted by Shai Barack, Android Platform Efficiency Lead and Charles Munger, Principal Software program Engineer In Android 17, apps focusing on SDK 37 or increased will obtain a brand new implementation of MessageQueue the place the implementation is lock-free. The brand new implementation improves efficiency and reduces missed frames, however might break purchasers that mirror [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":22566,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-22564","post","type-post","status-publish","format-standard","has-post-thumbnail","category-mobile"],"_links":{"self":[{"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/posts\/22564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22564"}],"version-history":[{"count":1,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/posts\/22564\/revisions"}],"predecessor-version":[{"id":22565,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/posts\/22564\/revisions\/22565"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=\/wp\/v2\/media\/22566"}],"wp:attachment":[{"href":"https:\/\/aireviewirush.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aireviewirush.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}