From c1fcb2ebc6d27097c9faa39d917ceb34efa9d2f4 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 17 Oct 2024 09:43:11 +0200 Subject: [PATCH] add some warning --- .../update/new/indexer/document_changes.rs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/milli/src/update/new/indexer/document_changes.rs b/milli/src/update/new/indexer/document_changes.rs index 5d9e7b3ba..423ddbdcc 100644 --- a/milli/src/update/new/indexer/document_changes.rs +++ b/milli/src/update/new/indexer/document_changes.rs @@ -27,13 +27,17 @@ pub trait RefCellExt { impl RefCellExt for RefCell { fn try_borrow_or_yield(&self) -> std::result::Result, std::cell::BorrowError> { + /// TODO: move this trait and impl elsewhere loop { match self.try_borrow() { Ok(borrow) => break Ok(borrow), - Err(error) => match rayon::yield_local() { - Some(rayon::Yield::Executed) => continue, - _ => return Err(error), - }, + Err(error) => { + tracing::warn!("dynamic borrow failed, yielding to local tasks"); + match rayon::yield_local() { + Some(rayon::Yield::Executed) => continue, + _ => return Err(error), + } + } } } } @@ -44,10 +48,14 @@ impl RefCellExt for RefCell { loop { match self.try_borrow_mut() { Ok(borrow) => break Ok(borrow), - Err(error) => match rayon::yield_local() { - Some(rayon::Yield::Executed) => continue, - _ => return Err(error), - }, + Err(error) => { + tracing::warn!("dynamic borrow failed, yielding to local tasks"); + + match rayon::yield_local() { + Some(rayon::Yield::Executed) => continue, + _ => return Err(error), + } + } } } } @@ -168,6 +176,7 @@ impl ThreadLocal { where F: FnOnce() -> T, { + /// TODO: move ThreadLocal, MostlySend, FullySend to a dedicated file self.inner.get_or(|| unsafe { MostlySendWrapper::new(create()) }).as_ref() }