fair-acc / chart-fx

A scientific charting library focused on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points.
GNU Lesser General Public License v3.0
504 stars 93 forks source link

CachedDaemonThreadFactory COMMON_POOL #661

Open kromar777 opened 6 months ago

kromar777 commented 6 months ago

There starts and hangs around till app exit a large amount of daemon threads (24 on my CPU), which most of the time do nothing (waiting state). I've never seen noticeble load on these threads actually. I use that pool for my purposes to utilize these threads, isn't it a bad idea? Maybe it makes sense to give the opportunity to set the pool with desired configuration? Quick search in Idea showed not so many usages - in CachedDataPoints, CachedDaemonThreadFactory and MarchingSquares, but I didn't dig deeper.

RalphSteinhagen commented 6 months ago

Hi @kromar777 thanks for your interest in ChartFX and bringing this up.

We use those daemon threads to offload heavy lifting like point-reduction algorithms and other similar DataSet operations to keep the UI FX responsive. The threads are usually limited to the number of cores because, unless you are IO-bound, having more parallel tasks than CPU cores causes the threads to compete for and slow down the same CPU resource.

I get where you’re coming from with the pool re-use idea; it’s neat. Honestly, we haven’t prioritized customizing it since it hasn’t been a pressing issue for our use cases (yet).

We're all ears for good ideas and open to PRs (Pull Requests). What kind of enhancements do you have in mind?

Thanks for sparking the conversation! :+1: