Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6963989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:52:00+00:00 2026-05-27T15:52:00+00:00

I recently began experimenting with the pseudo-boost threadpool (pseudo because it hasn’t been officially

  • 0

I recently began experimenting with the pseudo-boost threadpool (pseudo because it hasn’t been officially accepted yet).

As a simple exercise, I initialized the threadpool with a maximum of two threads.

Each task does two things:

  • a CPU-intensive calculation
  • writes out the result to disk

Question

How do I modify the model into a threadpool that does:

  • a CPU-intensive calculation

and a single I/O thread which listens for completion from the threadpool – takes the resultant memory and simply:

  • writes out the result to disk

Should I simply have the task communicate to the I/O thread (spawned
as std::thread) through a std::condition_variable (essentially a mutexed queue of calculation results) or is there a way to
do it all within the threadpool library?

Or is the gcc 4.6.1 implementation of future and promise mature enough for me to pull this off?

Answer

It looks like a simple mutex queue with a condition variable works fine.

By grouping read access and writes, in addition to using the threadpool, I got the following improvements:

  • 2 core machine: 1h14m down to 33m (46% reduction in runtime)
  • 4 core vm: 40m down to 18m (55% reduction in runtime)

Thanks to Martin James for his thoughtful answer. Before this exercise, I thought that my next computational server should have dual-processors and a ton of memory. But now, with so much processing power inherent in the multiple cores and hyperthreading, I realize that money will probably better spent dealing with the I/O bottleneck.

As Martin mentioned, having multiple drives or RAID configurations would probably help. I will also look into adjusting I/O buffer settings at the kernel level.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:52:01+00:00Added an answer on May 27, 2026 at 3:52 pm

    If there is only one local disk, one writer thread on the end of a producer-consumer queue would be my favourite. Seeks, networked-disk delays and other hiccups will not leave any pooled threads that have finsihed their calculation stuck trying to write to the disk. Other disk operations, (eg. select another location/file/folder), are also easier/quicker if only one thread is accessing it – the queue will take up the slack and allow seamless calculation during the latency.

    Writing directly from the calcualtion task or submitting the result-write as a separate task would work OK but you would need more threads in the pool to achieve pause-free operation.

    Everything changes if there is more than one disk. More than one writer thread would then become a worthwhile proposition because of the increased overall performance. I would then probably go with an array/list of queues/write-threads, one for each disk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I've been doing lots of weekend coding, and have began to really need
I recently began outbalancing our host instance memory usage because we had a lot
I've been using Allegro 5 for a while now, and recently began looking into
I recently began working with Boost Asio. I noticed that the receive method of
I recently began using BIRT and have developed a report to use with my
I recently began profiling an osgi java application that I am writing using VisualVM.
I recently began working on a large project that contains a huge number of
I recently began to read some F# related literature, speaking of Real World Functional
I've recently began using dTrace and have noticed just how awesome it is. Its
I've recently began using C++ with XCode and I'm starting to miss the integrated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.