You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/19 00:30:40 UTC

[GitHub] [arrow-ballista] tfeda opened a new issue, #388: Use `tokio::sync::Semaphore` to wait for available task slots

tfeda opened a new issue, #388:
URL: https://github.com/apache/arrow-ballista/issues/388

   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   
   @Dandandan, I think we could improve on #378 by using `tokio::sync::Semaphore` to wait for task slots to open up, rather than sleep spinning. It could look something like this:
   
   ```
   let available_task_slots = Arc::new(Semaphore::new(num_task_slots))
   
   loop {
      // thread sleeps until permits are dropped
      let task_permit = available_task_slots.acquire_owned().await  
       
      // poll scheduler for work
   
     if work_is_available {
        tokio::spawn(async move {
          // task work  
      
          // move permit into task scope
          drop(task_permit)
        })
     }
     // If no work is available, task_permit gets dropped here
   }
   
   ```
   Looking at the current implementation, its pretty much the same thing as what a tokio semaphore does, except with the sleeping spin loop.
   
   
   **Describe alternatives you've considered**
   
   Just a thought, implementing this isn't a deal breaker
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-ballista] Dandandan closed issue #388: Use `tokio::sync::Semaphore` to wait for available task slots

Posted by GitBox <gi...@apache.org>.
Dandandan closed issue #388: Use `tokio::sync::Semaphore` to wait for available task slots
URL: https://github.com/apache/arrow-ballista/issues/388


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-ballista] Dandandan commented on issue #388: Use `tokio::sync::Semaphore` to wait for available task slots

Posted by GitBox <gi...@apache.org>.
Dandandan commented on issue #388:
URL: https://github.com/apache/arrow-ballista/issues/388#issuecomment-1283540987

   @tfeda thanks... that seems what we are looking for.
   Could save some extra milliseconds between tasks 👍


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org