Code size analysis#

pw_async2: Cooperative async tasks for embedded

Core async2 implementation#

The following table shows the code size cost of adding pw_async2 to a system. These size reports assume a baseline system with an RTOS which already uses a handful of core Pigweed components including HAL abstractions and pw_allocator.

The first row captures the core of pw_async2: the dispatcher, tasks, and wakers, using the pw::async2::BasicDispatcher. This is the minimum size cost a system must pay to adopt pw_async2. The following row demonstrates the cost of adding another task to this system. Of course, the majority of the cost of the task exists within its implementation — this simply shows that there is minimal internal overhead.

Label

Segment

Delta

Full cost of including pw_async2

FLASH

+288

[section .rodata]

+16

pw::containers::internal::GenericIntrusiveList<>::clear()

-4

__bi_84

+228

pw::async2::size_report::Measure()

-2

pw::containers::internal::IntrusiveForwardListItem::DoGetPrevious()

+16

pw::containers::internal::LegacyIntrusiveList<>::push_back()

+4

operator delete()

NEW

+228

pw::async2::Task::RunInDispatcher()

NEW

+80

pw::async2::Dispatcher::Post()

NEW

+72

pw::async2::Task::Wake()

NEW

+72

pw::async2::size_report::PendableValue<>::Get()

NEW

+56

pw::async2::Dispatcher::PopTaskToRun()

NEW

+56

pw::async2::Task::PostTo()

NEW

+56

pw::async2::Waker::operator=()

NEW

+56

pw::async2::internal::CloneWaker()

NEW

+56

pw::async2::size_report::MockTask::DoPend()

NEW

+50

pw::async2::Dispatcher::WakeTask()

NEW

+48

pw::async2::size_report::MockTask::~MockTask()

NEW

+42

pw::async2::Dispatcher::~Dispatcher()

NEW

+40

pw::async2::Dispatcher::Deregister()

NEW

+40

pw::async2::Dispatcher::PopTaskToRunLocked()

NEW

+40

pw::async2::Waker::InternalCloneIntoLocked()

NEW

+40

pw::async2::Waker::Wake()

NEW

+38

pw::async2::Task::~Task()

NEW

+36

__atomic_exchange_1

NEW

+32

__atomic_store_1

NEW

+32

pw::async2::Dispatcher::PopAndRunAllReadyTasks()

NEW

+32

pw::async2::Waker::InsertIntoTaskWakerList()

NEW

+32

pw::async2::Waker::RemoveFromTaskWakerList()

NEW

+28

pw::async2::BasicDispatcher

NEW

+28

pw::async2::Dispatcher::UnpostTaskList()

NEW

+28

pw::async2::RunnableDispatcher::RunToCompletion()

NEW

+26

pw::async2::Dispatcher::RunTask()

NEW

+26

pw::async2::Task::RemoveAllWakersLocked()

NEW

+24

pw::async2::Waker::Waker()

NEW

+24

pw::async2::size_report::MockTask::DoPend()::{lambda()#1}::operator()()

NEW

+24

pw::async2::size_report::PendableValue<>::Get()::{lambda()#1}::operator()()

NEW

+24

pw::containers::internal::IntrusiveListItemBase<>::unlist()

NEW

+22

pw::IntrusiveForwardList<>::pop_front()

NEW

+22

pw::async2::BasicDispatcher::~BasicDispatcher()

NEW

+20

pw::async2::Dispatcher

NEW

+20

pw::async2::PendFuncTask<>

NEW

+20

pw::async2::Task

NEW

+20

pw::async2::size_report::MockTask

NEW

+18

pw::async2::PendFuncTask<>::DoPend()

NEW

+18

pw::async2::Task::RemoveWakerLocked()

NEW

+18

pw::containers::internal::LegacyIntrusiveList<>::Item::~Item()

NEW

+16

pw::async2::Waker::InsertIntoTaskWakerListLocked()

NEW

+16

pw::async2::Waker::RemoveFromTaskWakerListLocked()

NEW

+16

pw::async2::Waker::~Waker()

NEW

+16

pw::containers::internal::LegacyIntrusiveList<>::~LegacyIntrusiveList()

NEW

+14

pw::async2::PendFuncTask<>::~PendFuncTask()

NEW

+14

pw::async2::Task::Unpost()

NEW

+12

pw::async2::BasicDispatcher::DoWaitForWake()

NEW

+12

pw::async2::Task::AddWakerLocked()

NEW

+12

pw::async2::internal::StoreWaker()

NEW

+10

pw::async2::BasicDispatcher::DoWake()

NEW

+8

pw::async2::RunnableDispatcher::DoRunUntilStalled()

+2,336

RAM

+8

[section .data]

NEW

+24

pw::async2::size_report::(anonymous namespace)::dispatcher

NEW

+8

pw::async2::internal::lock()::lock

+40

Base incremental cost of adding a task to an existing async system

FLASH

+56

pw::async2::size_report::Measure()

+8

vClearInterruptMaskFromISR

+64

async2 utilities#

Pigweed provides several utilities to simplify writing asynchronous code. Among these are combinators which operate over several pendables, such as Join which waits for all pendables to complete, and Select which waits for the first pendable to complete.

The table below demonstrates the code size impact of using these utilities. For both Join and Select, the report shows:

  • The initial cost of using the utility with multiple pendables of the same type.

  • The incremental cost of adding a second call with pendables of different types, which demonstrates the overhead of template specialization.

Additionally, the table includes a comparison showing the code size difference between using the Select helper versus manually polling each pendable.

Label

Segment

Delta

Size of calling Select() with several pendables of the same type

FLASH

+164

[section .rodata]

-88

pw::async2::size_report::Measure()

-2

pw::async2::size_report::MockTask::~MockTask()

+16

pw::async2::PendFuncTask<>

+14

pw::async2::PendFuncTask<>::DoPend()

+2

pw::containers::internal::LegacyIntrusiveList<>::Item::~Item()

-6

operator delete()

+4

__bi_84

NEW

+260

pw::async2::size_report::SingleTypeSelect()

NEW

+192

pw::async2::Selector<>::PendFrom<>()

NEW

+60

pw::async2::MemberPendableWrapper<>::Pend()

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIiEEFNS2_4PollIiEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+24

pw::async2::MemberPendableWrapper<>::Pend()::{lambda()#1}::operator()<>()

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj0EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EiEENSD_ILj2EiEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SingleTypeSelectEjE3$_1NS_5tupleIJOZNSK_16SingleTypeSelectEjE3$_2OZNSK_16SingleTypeSelectEjE3$_3OZNSK_16SingleTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj1EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EiEENSD_ILj2EiEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SingleTypeSelectEjE3$_1NS_5tupleIJOZNSK_16SingleTypeSelectEjE3$_2OZNSK_16SingleTypeSelectEjE3$_3OZNSK_16SingleTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj2EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EiEENSD_ILj2EiEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SingleTypeSelectEjE3$_1NS_5tupleIJOZNSK_16SingleTypeSelectEjE3$_2OZNSK_16SingleTypeSelectEjE3$_3OZNSK_16SingleTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj3EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EiEENSD_ILj2EiEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SingleTypeSelectEjE3$_1NS_5tupleIJOZNSK_16SingleTypeSelectEjE3$_2OZNSK_16SingleTypeSelectEjE3$_3OZNSK_16SingleTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+12

_ZNSt3__220__throw_if_valuelessB8nn220000IJRNS_7variantIJN2pw6async212SelectResultILj0EiEENS4_ILj1EiEENS4_ILj2EiEENS3_21AllPendablesCompletedEEEEEEEvDpOT_

NEW

+12

_ZNSt3__226__throw_bad_variant_accessB8nn220000Ev

NEW

+10

pw::async2::Selector<>::Pend()

NEW

+6

std::__2::__libcpp_verbose_abort()

+760

Size of an additional a call to Select() with pendables of different types

FLASH

+182

pw::async2::Selector<>::PendFrom<>()

+8

pw::async2::size_report::Measure()

+140

pw::async2::size_report::PendableValue<>::Get()

+116

pw::async2::MemberPendableWrapper<>::Pend()

+2

pw::async2::size_report::MockTask::~MockTask()

+36

pw::async2::PendFuncTask<>

+32

pw::async2::PendFuncTask<>::DoPend()

+48

pw::async2::MemberPendableWrapper<>::Pend()::{lambda()#1}::operator()<>()

+48

pw::async2::size_report::PendableValue<>::Get()::{lambda()#1}::operator()()

-2

pw::containers::internal::LegacyIntrusiveList<>::Item::~Item()

-4

__bi_84

-2

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj3EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EiEENSD_ILj2EiEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SingleTypeSelectEjE3$_1NS_5tupleIJOZNSK_16SingleTypeSelectEjE3$_2OZNSK_16SingleTypeSelectEjE3$_3OZNSK_16SingleTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

+14

pw::async2::PendFuncTask<>::~PendFuncTask()

+8

vClearInterruptMaskFromISR

+10

pw::async2::Selector<>::Pend()

NEW

+256

pw::async2::size_report::MultiTypeSelect()

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIcEEFNS2_4PollIcEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIjEEFNS2_4PollIjEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj0EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report15MultiTypeSelectEjE3$_1NS_5tupleIJOZNSK_15MultiTypeSelectEjE3$_2OZNSK_15MultiTypeSelectEjE3$_3OZNSK_15MultiTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj1EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report15MultiTypeSelectEjE3$_1NS_5tupleIJOZNSK_15MultiTypeSelectEjE3$_2OZNSK_15MultiTypeSelectEjE3$_3OZNSK_15MultiTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj2EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report15MultiTypeSelectEjE3$_1NS_5tupleIJOZNSK_15MultiTypeSelectEjE3$_2OZNSK_15MultiTypeSelectEjE3$_3OZNSK_15MultiTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+14

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj3EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report15MultiTypeSelectEjE3$_1NS_5tupleIJOZNSK_15MultiTypeSelectEjE3$_2OZNSK_15MultiTypeSelectEjE3$_3OZNSK_15MultiTypeSelectEjE3$_4EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSV_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSU_DpT0_

NEW

+12

_ZNSt3__220__throw_if_valuelessB8nn220000IJRNS_7variantIJN2pw6async212SelectResultILj0EiEENS4_ILj1EjEENS4_ILj2EcEENS3_21AllPendablesCompletedEEEEEEEvDpOT_

+1,008

Cost of using Select() versus manually polling each pendable

FLASH

+164

[section .rodata]

-62

pw::async2::size_report::SelectComparison::Pend()

+16

pw::async2::PendFuncTask<>

-2

pw::async2::PendFuncTask<>::DoPend()

-4

__bi_84

-6

operator delete()

-4

vClearInterruptMaskFromISR

NEW

+180

pw::async2::Selector<>::PendFrom<>()

NEW

+176

pw::async2::MemberPendableWrapper<>::Pend()

NEW

+72

pw::async2::MemberPendableWrapper<>::Pend()::{lambda()#1}::operator()<>()

NEW

+72

pw::async2::size_report::SelectComparison::Pend()::{lambda()#1}::operator()()

NEW

+36

pw::async2::internal::VisitSelectResult<>()::{lambda()#1}::operator()<>()

NEW

+32

_ZNSt3__216__variant_detail12__visitation9__variant13__visit_valueB8nn220000IZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS5_12SelectResultILj0EiEENS9_ILj1EjEENS9_ILj2EcEENS5_21AllPendablesCompletedEEEEZNS5_11size_report16SelectComparison4PendERNS5_7ContextEEUlSD_E_NS_5tupleIJOZNSH_4PendESJ_EUliE_OZNSH_4PendESJ_EUljE_OZNSH_4PendESJ_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSU_E_JSF_EEEDcSU_DpOT0_

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIcEEFNS2_4PollIcEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIiEEFNS2_4PollIiEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIjEEFNS2_4PollIjEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+22

_ZNSt3__25visitB8nn220000IZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS2_12SelectResultILj0EiEENS6_ILj1EjEENS6_ILj2EcEENS2_21AllPendablesCompletedEEEEZNS2_11size_report16SelectComparison4PendERNS2_7ContextEEUlSA_E_NS_5tupleIJOZNSE_4PendESG_EUliE_OZNSE_4PendESG_EUljE_OZNSE_4PendESG_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSR_E_JSC_EvEEDcSR_DpOT0_

NEW

+18

pw::async2::VisitSelectResult<>()

NEW

+18

pw::async2::internal::VisitSelectResult<>()

NEW

+12

_ZNSt3__220__throw_if_valuelessB8nn220000IJRNS_7variantIJN2pw6async212SelectResultILj0EiEENS4_ILj1EjEENS4_ILj2EcEENS3_21AllPendablesCompletedEEEEEEEvDpOT_

NEW

+12

_ZNSt3__226__throw_bad_variant_accessB8nn220000Ev

NEW

+12

_ZNSt3__28__invokeB8nn220000IJZN2pw6async211size_report16SelectComparison4PendERNS2_7ContextEEUliE_iEEENS_20__invoke_result_implIvJDpT_EE4typeEDpOS9_

NEW

+10

_ZNKSt3__216__variant_detail12__visitation9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS5_12SelectResultILj0EiEENS9_ILj1EjEENS9_ILj2EcEENS5_21AllPendablesCompletedEEEEZNS5_11size_report16SelectComparison4PendERNS5_7ContextEEUlSD_E_NS_5tupleIJOZNSH_4PendESJ_EUliE_OZNSH_4PendESJ_EUljE_OZNSH_4PendESJ_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSU_E_EclB8nn220000IJRNS0_5__altILj0ESA_EEEEEDcDpOT_

NEW

+10

_ZNKSt3__216__variant_detail12__visitation9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS5_12SelectResultILj0EiEENS9_ILj1EjEENS9_ILj2EcEENS5_21AllPendablesCompletedEEEEZNS5_11size_report16SelectComparison4PendERNS5_7ContextEEUlSD_E_NS_5tupleIJOZNSH_4PendESJ_EUliE_OZNSH_4PendESJ_EUljE_OZNSH_4PendESJ_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSU_E_EclB8nn220000IJRNS0_5__altILj1ESB_EEEEEDcDpOT_

NEW

+10

_ZNKSt3__216__variant_detail12__visitation9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS5_12SelectResultILj0EiEENS9_ILj1EjEENS9_ILj2EcEENS5_21AllPendablesCompletedEEEEZNS5_11size_report16SelectComparison4PendERNS5_7ContextEEUlSD_E_NS_5tupleIJOZNSH_4PendESJ_EUliE_OZNSH_4PendESJ_EUljE_OZNSH_4PendESJ_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSU_E_EclB8nn220000IJRNS0_5__altILj2ESC_EEEEEDcDpOT_

NEW

+10

_ZNSt3__28__invokeB8nn220000IJZN2pw6async211size_report16SelectComparison4PendERNS2_7ContextEEUlcE_cEEENS_20__invoke_result_implIvJDpT_EE4typeEDpOS9_

NEW

+10

_ZNSt3__28__invokeB8nn220000IJZN2pw6async211size_report16SelectComparison4PendERNS2_7ContextEEUljE_jEEENS_20__invoke_result_implIvJDpT_EE4typeEDpOS9_

NEW

+10

pw::async2::Selector<>::Pend()

NEW

+8

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj0EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SelectComparison4PendERNS9_7ContextEEUlSH_E_NS_5tupleIJOZNSL_4PendESN_EUliE_OZNSL_4PendESN_EUljE_OZNSL_4PendESN_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSY_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSX_DpT0_

NEW

+8

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj1EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SelectComparison4PendERNS9_7ContextEEUlSH_E_NS_5tupleIJOZNSL_4PendESN_EUliE_OZNSL_4PendESN_EUljE_OZNSL_4PendESN_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSY_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSX_DpT0_

NEW

+8

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj2EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SelectComparison4PendERNS9_7ContextEEUlSH_E_NS_5tupleIJOZNSL_4PendESN_EUliE_OZNSL_4PendESN_EUljE_OZNSL_4PendESN_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSY_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSX_DpT0_

NEW

+6

std::__2::__libcpp_verbose_abort()

NEW

+2

_ZNSt3__216__variant_detail12__visitation6__base12__dispatcherIJLj3EEE10__dispatchB8nn220000IONS1_9__variant15__value_visitorIZN2pw6async28internal17VisitSelectResultIRNS_7variantIJNS9_12SelectResultILj0EiEENSD_ILj1EjEENSD_ILj2EcEENS9_21AllPendablesCompletedEEEEZNS9_11size_report16SelectComparison4PendERNS9_7ContextEEUlSH_E_NS_5tupleIJOZNSL_4PendESN_EUliE_OZNSL_4PendESN_EUljE_OZNSL_4PendESN_EUlcE_EEEJLj0ELj1ELj2EEEEvOT_OT0_OT1_NS_16integer_sequenceIjJXspT2_EEEEEUlSY_E_EEJRNS0_6__baseILNS0_6_TraitE0EJSE_SF_SG_SH_EEEEEEDcSX_DpT0_

+928

Size of calling Join() with several pendables of the same type

FLASH

+112

[section .rodata]

-88

pw::async2::size_report::Measure()

-2

pw::async2::size_report::MockTask::~MockTask()

+16

pw::async2::PendFuncTask<>::DoPend()

+2

pw::containers::internal::LegacyIntrusiveList<>::Item::~Item()

+4

vClearInterruptMaskFromISR

NEW

+212

pw::async2::size_report::SingleTypeJoin()

NEW

+124

pw::async2::Joiner<>::PendElement<>()

NEW

+60

pw::async2::MemberPendableWrapper<>::Pend()

NEW

+46

pw::async2::Joiner<>::Pend()

NEW

+42

pw::async2::Joiner<>::PendElements<>()

NEW

+40

_ZNSt3__223__optional_storage_baseINS_5tupleIJOiS2_S2_EEELb0EE13__assign_fromB8nn220000INS_27__optional_move_assign_baseIS3_Lb0EEEEEvOT_

NEW

+28

_ZNSt3__227__memberwise_forward_assignB8nn220000INS_5tupleIJOiS2_S2_EEES3_JS2_S2_S2_EJLj0ELj1ELj2EEEEvRT_OT0_NS_13__tuple_typesIJDpT1_EEENS_18__integer_sequenceIjJXspT2_EEEE

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIiEEFNS2_4PollIiEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+24

pw::async2::MemberPendableWrapper<>::Pend()::{lambda()#1}::operator()<>()

NEW

+12

_ZNSt3__25tupleIJOiS1_S1_EEaSB8nn220000EOS2_

+656

Size of an additional a call to Join() with pendables of different types

FLASH

+8

pw::async2::size_report::Measure()

+118

pw::async2::Joiner<>::PendElement<>()

+140

pw::async2::size_report::PendableValue<>::Get()

+116

pw::async2::MemberPendableWrapper<>::Pend()

+46

pw::async2::Joiner<>::Pend()

+2

pw::async2::size_report::MockTask::~MockTask()

+42

pw::async2::Joiner<>::PendElements<>()

+34

pw::async2::PendFuncTask<>::DoPend()

-2

_ZNSt3__227__memberwise_forward_assignB8nn220000INS_5tupleIJOiS2_S2_EEES3_JS2_S2_S2_EJLj0ELj1ELj2EEEEvRT_OT0_NS_13__tuple_typesIJDpT1_EEENS_18__integer_sequenceIjJXspT2_EEEE

+48

pw::async2::MemberPendableWrapper<>::Pend()::{lambda()#1}::operator()<>()

+48

pw::async2::size_report::PendableValue<>::Get()::{lambda()#1}::operator()()

+20

pw::async2::PendFuncTask<>

-2

pw::containers::internal::LegacyIntrusiveList<>::Item::~Item()

-8

vClearInterruptMaskFromISR

+14

pw::async2::PendFuncTask<>::~PendFuncTask()

+4

__bi_84

NEW

+164

pw::async2::size_report::MultiTypeJoin()

NEW

+40

_ZNSt3__223__optional_storage_baseINS_5tupleIJOiOjOcEEELb0EE13__assign_fromB8nn220000INS_27__optional_move_assign_baseIS5_Lb0EEEEEvOT_

NEW

+28

_ZNSt3__227__memberwise_forward_assignB8nn220000INS_5tupleIJOiOjOcEEES5_JS2_S3_S4_EJLj0ELj1ELj2EEEEvRT_OT0_NS_13__tuple_typesIJDpT1_EEENS_18__integer_sequenceIjJXspT2_EEEE

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIcEEFNS2_4PollIcEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+24

_ZNSt3__28__invokeB8nn220000IJMN2pw6async211size_report13PendableValueIjEEFNS2_4PollIjEERNS2_7ContextEERPS5_S9_EEENS_20__invoke_result_implIvJDpT_EE4typeEDpOSF_

NEW

+12

_ZNSt3__25tupleIJOiOjOcEEaSB8nn220000EOS4_

+920

OnceSender and OnceReceiver#

The next table shows sizes of the pair of OnceSender and OnceReceiver types, which allow for returning a delayed result from an async function, similar to a Future type in other languages. This type is templated on its stored value, causing specialization overhead for each type sent through the sender/receiver pair. The first row showcases the base cost of using a OnceSender and OnceReceiver; the second row adds another template specialization on top of this to demonstrate the incremental cost.

Label

Segment

Delta

Size of OnceSender / OnceReceiver

FLASH

+172

[section .rodata]

+52

pw::async2::size_report::Measure()

-6

operator delete()

NEW

+112

pw::async2::OnceReceiver<>::Pend()

NEW

+96

pw::async2::OnceReceiver<>::OnceReceiver()

NEW

+60

pw::async2::size_report::SenderAdd()

NEW

+52

pw::async2::OnceSender<>::emplace<>()

NEW

+52

pw::async2::size_report::ReceiverTask<>::ReceiverTask()

NEW

+46

pw::async2::size_report::ReceiverTask<>::~ReceiverTask()

NEW

+44

pw::async2::OnceReceiver<>::~OnceReceiver()

NEW

+44

pw::async2::OnceSender<>::~OnceSender()

NEW

+40

_ZN2pw15internal_result12StatusOrDataIjLb1EEC2INS_6StatusETnNSt3__29enable_ifIXsr3std16is_constructibleIS4_OT_EE5valueEiE4typeELi0EEES8_

NEW

+24

pw::async2::OnceReceiver<>::Pend()::{lambda()#1}::operator()()

NEW

+22

pw::async2::size_report::ReceiverTask<>::DoPend()

NEW

+20

_ZNSt3__28optionalIN2pw6ResultIjEEEC2B8nn220000INS1_6StatusETnNS_9enable_ifIXclsr22_CheckOptionalLikeCtorIT_OS8_EE17__enable_implicitIS8_EEEiE4typeELi0EEEONS0_IS8_EE

NEW

+20

pw::async2::size_report::ReceiverTask<>

NEW

+20

std::__2::pair<>::~pair()

NEW

+14

_ZNSt3__223__optional_storage_baseIN2pw6ResultIjEELb0EE11__constructB8nn220000IJNS1_6StatusEEEEvDpOT_

NEW

+14

_ZNSt3__223__optional_storage_baseIN2pw6ResultIjEELb0EE16__construct_fromB8nn220000INS_8optionalINS1_6StatusEEEEEvOT_

NEW

+12

_ZNRSt3__28optionalIjE5valueB8nn220000Ev

NEW

+12

_ZNSt3__227__throw_bad_optional_accessB8nn220000Ev

NEW

+6

std::__2::__libcpp_verbose_abort()

+928

RAM

NEW

+8

pw::async2::sender_receiver_lock()::lock

+8

Cost of additional OnceSender / OnceReceiver template specialization

FLASH

+56

pw::async2::size_report::Measure()

+112

pw::async2::OnceReceiver<>::Pend()

+96

pw::async2::OnceReceiver<>::OnceReceiver()

+52

pw::async2::OnceSender<>::emplace<>()

+52

pw::async2::size_report::ReceiverTask<>::ReceiverTask()

+46

pw::async2::size_report::ReceiverTask<>::~ReceiverTask()

+44

pw::async2::OnceReceiver<>::~OnceReceiver()

+44

pw::async2::OnceSender<>::~OnceSender()

+24

pw::async2::OnceReceiver<>::Pend()::{lambda()#1}::operator()()

+22

pw::async2::size_report::ReceiverTask<>::DoPend()

+20

pw::async2::size_report::ReceiverTask<>

+18

std::__2::pair<>::~pair()

+4

__bi_84

+8

vClearInterruptMaskFromISR

NEW

+62

pw::async2::size_report::SenderSub()

NEW

+40

_ZN2pw15internal_result12StatusOrDataIiLb1EEC2INS_6StatusETnNSt3__29enable_ifIXsr3std16is_constructibleIS4_OT_EE5valueEiE4typeELi0EEES8_

NEW

+20

_ZNSt3__28optionalIN2pw6ResultIiEEEC2B8nn220000INS1_6StatusETnNS_9enable_ifIXclsr22_CheckOptionalLikeCtorIT_OS8_EE17__enable_implicitIS8_EEEiE4typeELi0EEEONS0_IS8_EE

NEW

+14

_ZNSt3__223__optional_storage_baseIN2pw6ResultIiEELb0EE11__constructB8nn220000IJNS1_6StatusEEEEvDpOT_

NEW

+14

_ZNSt3__223__optional_storage_baseIN2pw6ResultIiEELb0EE16__construct_fromB8nn220000INS_8optionalINS1_6StatusEEEEEvOT_

NEW

+12

_ZNRSt3__28optionalIiE5valueB8nn220000Ev

+760