Bug 75897 - create 'get best number of threads' API in sal
Summary: create 'get best number of threads' API in sal
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha0+ Master
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2014-03-07 17:39 UTC by Michael Meeks
Modified: 2016-02-18 16:37 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2014-03-07 17:39:21 UTC
A reasonably simple easy hack to add an API to fetch an optimal number of threads (presumably the same as the core count usually ;) That is needed to setup optimal parallelism in calc XLSX loading eg.

See:

sc/source/filter/oox/workbookfragment.cxx

    sal_Int32 nThreads = std::min( rSheets.size(), (size_t) 4 /* FIXME: ncpus/2 */ );

Notice the '4' ;-)

not ideal - clearly.

The API should live inside sal/osl/ and include/osl/ and just wrap thinly the underlying OS parameters without being hyper-complicated.
Comment 1 Stephan Bergmann 2014-03-07 18:02:51 UTC
can we directly use Boost's approximation of C++11 std::thread::hardware_concurrency for that, see <http://www.boost.org/doc/libs/1_55_0/doc/html/thread/thread_management.html#thread.thread_management.thread.hardware_concurrency>?
Comment 2 Michael Meeks 2014-03-08 20:25:36 UTC
I guess that means linking to and/or distributing boost's thread library (?) or is that method effectively in-lined ?

Either way - given that as we start to use more threading anyway, having boost threads around would be rather helpful - it'd be great to have that usable. It seems we have StaticLibrary_boostthread - but ... do we link it anywhere already ? or ...

'git grep boost/thread' seems to show nothing =)
Comment 3 Björn Michaelsen 2015-09-17 12:20:42 UTC
Since we allow C++11 now, we could use std::thread::hardware_concurrency directly. However, do we even need a API wrapper for this as this is standard C++11?

@Michael: Also there is already a comphelper::ThreadPool wrapper, do we need another one?
Comment 4 Michael Meeks 2015-09-17 13:52:25 UTC
All good points; lets just close this now - we are using the std:: API currently.
Comment 5 Robinson Tryon (qubit) 2015-12-15 16:27:30 UTC
Migrating Whiteboard tags to Keywords: (EasyHack,DifficultyBeginner,SkillCpp,TopicCleanup)
[NinjaEdit]
Comment 6 Robinson Tryon (qubit) 2016-02-18 16:37:34 UTC
Remove LibreOffice Dev List from CC on EasyHacks
(curtailing excessive email to list)
[NinjaEdit]