From 261d2ceb06553465115419afed01dc4b0cbbf848 Mon Sep 17 00:00:00 2001
From: Kerollmops <clement@meilisearch.com>
Date: Wed, 4 Dec 2024 14:16:40 +0100
Subject: [PATCH] Yield the BBQueue writer instead of spin looping

---
 crates/milli/src/update/new/channel.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/crates/milli/src/update/new/channel.rs b/crates/milli/src/update/new/channel.rs
index ebd0ba429..7590c02ac 100644
--- a/crates/milli/src/update/new/channel.rs
+++ b/crates/milli/src/update/new/channel.rs
@@ -661,6 +661,11 @@ where
         if sender.is_disconnected() {
             return Err(Error::InternalError(InternalError::AbortedIndexation));
         }
+
+        // We prefer to yield and allow the writing thread
+        // to do its job, especially beneficial when there
+        // is only one CPU core available.
+        std::thread::yield_now();
     }
 }