Seastar
High performance C++ framework for concurrent servers
Public Member Functions | Friends | List of all members
seastar::scheduling_group Class Reference

Detailed Description

Identifies function calls that are accounted as a group.

A scheduling_group is a tag that can be used to mark a function call. Executions of such tagged calls are accounted as a group.

#include <seastar/core/scheduling.hh>

Public Member Functions

constexpr scheduling_group () noexcept
 Creates a scheduling_group object denoting the default group.
 
bool active () const
 
const sstringname () const
 
bool operator== (scheduling_group x) const
 
bool operator!= (scheduling_group x) const
 
bool is_main () const
 
template<typename T >
T & get_specific (scheduling_group_key key)
 
void set_shares (float shares)
 

Friends

future< scheduling_groupcreate_scheduling_group (sstring name, float shares)
 
future destroy_scheduling_group (scheduling_group sg)
 
future rename_scheduling_group (scheduling_group sg, sstring new_name)
 
unsigned internal::scheduling_group_index (scheduling_group sg)
 
scheduling_group internal::scheduling_group_from_index (unsigned index)
 
template<typename SpecificValType , typename Mapper , typename Reducer , typename Initial >
future< typename function_traits< Reducer >::return_type > map_reduce_scheduling_group_specific (Mapper mapper, Reducer reducer, Initial initial_val, scheduling_group_key key)
 
template<typename SpecificValType , typename Reducer , typename Initial >
future< typename function_traits< Reducer >::return_type > reduce_scheduling_group_specific (Reducer reducer, Initial initial_val, scheduling_group_key key)
 

Member Function Documentation

◆ get_specific()

template<typename T >
T& seastar::scheduling_group::get_specific ( scheduling_group_key  key)
inline

Returnes a reference to this scheduling group specific value

Template Parameters
T- the type of the scheduling specific type (cannot be deduced)
Parameters
key- the key of the value to retrieve.
Returns
A reference to this scheduling specific value.

◆ set_shares()

void seastar::scheduling_group::set_shares ( float  shares)

Adjusts the number of shares allotted to the group.

Dynamically adjust the number of shares allotted to the group, increasing or decreasing the amount of CPU bandwidth it gets. The adjustment is local to the shard.

This can be used to reduce a background job's interference with a foreground load: the shares can be started at a low value, increased when the background job's backlog increases, and reduced again when the backlog decreases.

Parameters
sharesnumber of shares allotted to the group. Use numbers in the 1-1000 range.

Friends And Related Function Documentation

◆ create_scheduling_group

future<scheduling_group> create_scheduling_group ( sstring  name,
float  shares 
)
friend

Creates a scheduling group with a specified number of shares.

The operation is global and affects all shards. The returned scheduling group can then be used in any shard.

Parameters
nameA name that identifiers the group; will be used as a label in the group's metrics
sharesnumber of shares of the CPU time allotted to the group; Use numbers in the 1-1000 range (but can go above).
Returns
a scheduling group that can be used on any shard

◆ destroy_scheduling_group

future destroy_scheduling_group ( scheduling_group  sg)
friend

Destroys a scheduling group.

Destroys a scheduling_group previously created with create_scheduling_group(). The destroyed group must not be currently in use and must not be used later.

The operation is global and affects all shards.

Parameters
sgThe scheduling group to be destroyed
Returns
a future that is ready when the scheduling group has been torn down

◆ map_reduce_scheduling_group_specific

template<typename SpecificValType , typename Mapper , typename Reducer , typename Initial >
future<typename function_traits<Reducer>::return_type> map_reduce_scheduling_group_specific ( Mapper  mapper,
Reducer  reducer,
Initial  initial_val,
scheduling_group_key  key 
)
friend

A map reduce over all values of a specific scheduling group data.

Parameters
mapper- A functor SomeType(SpecificValType&) or SomeType(SpecificValType) that maps the specific data to a value of any type.
reducer- A functor of of type ConvetibleToInitial(Initial, MapperReurnType) that reduces a value of type Initial and of the mapper return type to a value of type convertible to Initial.
initial_val- the initial value to pass in the first call to the reducer.
key- the key to the specific data that the mapper should act upon.
Returns
A future that resolves when the result of the map reduce is ready.
Note
The type of SpecificValType must be given because there is no way to deduce it in a consistent manner.
Theoretically the parameter type of Mapper can be deduced to be the type (function_traits<Mapper>::arg<0>) but then there is a danger when the Mapper accepts a parameter type T where SpecificValType is convertible to SpecificValType.

◆ reduce_scheduling_group_specific

template<typename SpecificValType , typename Reducer , typename Initial >
future<typename function_traits<Reducer>::return_type> reduce_scheduling_group_specific ( Reducer  reducer,
Initial  initial_val,
scheduling_group_key  key 
)
friend

A reduce over all values of a specific scheduling group data.

Parameters
reducer- A functor of of type ConvetibleToInitial(Initial, SpecificValType) that reduces a value of type Initial and of the sg specific data type to a value of type convertible to Initial.
initial_val- the initial value to pass in the first call to the reducer.
key- the key to the specific data that the mapper should act upon.
Returns
A future that resolves when the result of the reduce is ready.
Note
The type of SpecificValType must be given because there is no way to deduce it in a consistent manner.
Theoretically the parameter type of Reducer can be deduced to be the type (function_traits<Reducer>::arg<0>) but then there is a danger when the Reducer accepts a parameter type T where SpecificValType is convertible to SpecificValType.

◆ rename_scheduling_group

future rename_scheduling_group ( scheduling_group  sg,
sstring  new_name 
)
friend

Rename scheduling group.

Renames a scheduling_group previously created with create_scheduling_group().

The operation is global and affects all shards. The operation affects the exported statistics labels.

Parameters
sgThe scheduling group to be renamed
new_nameThe new name for the scheduling group.
Returns
a future that is ready when the scheduling group has been renamed

The documentation for this class was generated from the following file: