Opened 3 years ago

Last modified 5 months ago

#5874 new task

Threading improvements — at Version 5

Reported by: wraitii Owned by:
Priority: Must Have Milestone: Work In Progress
Component: Core engine Keywords:
Cc: Patch: Phab:D3848

Description (last modified by Stan)

We currently use std::thread in a number of places:

  • net client (net session)
  • net server
  • user reporter
  • sound
  • texture converter
  • more?

Currently uses the threadpool

  • map generator
  • pathfinder

There are issues with our implementation: we use "naked" std::thread instead of cleverer solutions. This, notably, means we fail to detect exceptions happening in the threads (see https://code.wildfiregames.com/rP22649#45341 ) A better architecture ought to be found and implemented.

Change History (5)

comment:2 by wraitii, 3 years ago

Description: modified (diff)
Milestone: Alpha 24Alpha 25

Net client was threaded in A24, A25 will hopefully thread the pathfinder.

comment:3 by Imarok, 3 years ago

Patch: Phab:D3848

comment:4 by wraitii, 3 years ago

In 25656:

Implement a global task manager using a pool of worker threads

Tasks are simple callables (e.g. lambdas), and can be pushed with 2 priority levels. Pushing a task returns a future.
Futures can be waited on, can return results, and can be cancelled deterministically. Futures can also not be waited on.

This gives 'hardware concurrency - 1' threads to maximize CPU usage in a work-stealing workflow.

Reviewed by: vladislavbelov

Refs #5874

Differential Revision: https://code.wildfiregames.com/D3848

comment:5 by Stan, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.