fix problems with spawning too many async tasks underload (#196)

This commit is contained in:
Stephan Dilly 2020-07-18 13:57:08 +02:00
parent 7e8df3ad28
commit 58a1719c98
5 changed files with 23 additions and 12 deletions

View File

@ -57,7 +57,7 @@ impl AsyncCommitFiles {
{ {
let current = self.current.lock()?; let current = self.current.lock()?;
if let Some(ref c) = *current { if let Some(c) = &*current {
if c.0 == id { if c.0 == id {
return Ok(()); return Ok(());
} }
@ -68,9 +68,9 @@ impl AsyncCommitFiles {
let sender = self.sender.clone(); let sender = self.sender.clone();
let arc_pending = Arc::clone(&self.pending); let arc_pending = Arc::clone(&self.pending);
rayon_core::spawn(move || { self.pending.fetch_add(1, Ordering::Relaxed);
arc_pending.fetch_add(1, Ordering::Relaxed);
rayon_core::spawn(move || {
Self::fetch_helper(id, arc_current) Self::fetch_helper(id, arc_current)
.expect("failed to fetch"); .expect("failed to fetch");
@ -92,9 +92,15 @@ impl AsyncCommitFiles {
) -> Result<()> { ) -> Result<()> {
let res = sync::get_commit_files(CWD, id)?; let res = sync::get_commit_files(CWD, id)?;
log::trace!(
"get_commit_files: {} ({})",
id.to_string(),
res.len()
);
{ {
let mut last = arc_current.lock()?; let mut current = arc_current.lock()?;
*last = Some(Request(id, res)); *current = Some(Request(id, res));
} }
Ok(()) Ok(())

View File

@ -109,9 +109,10 @@ impl AsyncDiff {
let arc_last = Arc::clone(&self.last); let arc_last = Arc::clone(&self.last);
let sender = self.sender.clone(); let sender = self.sender.clone();
let arc_pending = Arc::clone(&self.pending); let arc_pending = Arc::clone(&self.pending);
rayon_core::spawn(move || {
arc_pending.fetch_add(1, Ordering::Relaxed);
self.pending.fetch_add(1, Ordering::Relaxed);
rayon_core::spawn(move || {
let notify = AsyncDiff::get_diff_helper( let notify = AsyncDiff::get_diff_helper(
params, params,
arc_last, arc_last,

View File

@ -117,16 +117,18 @@ impl AsyncLog {
let arc_pending = Arc::clone(&self.pending); let arc_pending = Arc::clone(&self.pending);
let arc_background = Arc::clone(&self.background); let arc_background = Arc::clone(&self.background);
self.pending.store(true, Ordering::Relaxed);
rayon_core::spawn(move || { rayon_core::spawn(move || {
scope_time!("async::revlog"); scope_time!("async::revlog");
arc_pending.store(true, Ordering::Relaxed);
AsyncLog::fetch_helper( AsyncLog::fetch_helper(
arc_current, arc_current,
arc_background, arc_background,
&sender, &sender,
) )
.expect("failed to fetch"); .expect("failed to fetch");
arc_pending.store(false, Ordering::Relaxed); arc_pending.store(false, Ordering::Relaxed);
Self::notify(&sender); Self::notify(&sender);

View File

@ -116,9 +116,10 @@ impl AsyncStatus {
let arc_pending = Arc::clone(&self.pending); let arc_pending = Arc::clone(&self.pending);
let status_type = params.status_type; let status_type = params.status_type;
let include_untracked = params.include_untracked; let include_untracked = params.include_untracked;
rayon_core::spawn(move || {
arc_pending.fetch_add(1, Ordering::Relaxed);
self.pending.fetch_add(1, Ordering::Relaxed);
rayon_core::spawn(move || {
Self::fetch_helper( Self::fetch_helper(
status_type, status_type,
include_untracked, include_untracked,

View File

@ -74,9 +74,10 @@ impl AsyncTags {
let arc_last = Arc::clone(&self.last); let arc_last = Arc::clone(&self.last);
let sender = self.sender.clone(); let sender = self.sender.clone();
let arc_pending = Arc::clone(&self.pending); let arc_pending = Arc::clone(&self.pending);
rayon_core::spawn(move || {
arc_pending.fetch_add(1, Ordering::Relaxed);
self.pending.fetch_add(1, Ordering::Relaxed);
rayon_core::spawn(move || {
let notify = AsyncTags::getter(arc_last) let notify = AsyncTags::getter(arc_last)
.expect("error getting tags"); .expect("error getting tags");