How$to$Measure$RTOS$ Performance Colin/Walls - - PowerPoint PPT Presentation

how to measure rtos performance
SMART_READER_LITE
LIVE PREVIEW

How$to$Measure$RTOS$ Performance Colin/Walls - - PowerPoint PPT Presentation

How$to$Measure$RTOS$ Performance Colin/Walls colin_walls@mentor.com with/acknowledgement/to/Faheem Sheikh/&/Dan/Driscoll mentor.com/embedded Android'is'a'trademark'of'Google'Inc.'Use'of'this'trademark'is'subject'to'Google'Permissions.


slide-1
SLIDE 1

mentor.com/embedded

Android'is'a'trademark'of'Google'Inc.'Use'of'this'trademark'is'subject'to'Google'Permissions. Linux'is'the'registered'trademark'of'Linus'Torvalds'in'the'U.S.'and'other'countries.

Colin/Walls

colin_walls@mentor.com

with/acknowledgement/to/Faheem Sheikh/&/Dan/Driscoll

How$to$Measure$RTOS$ Performance

slide-2
SLIDE 2

2 mentor.com/embedded 2

Agenda

Introduction RTOS/Metrics Memory/Footprint Interrupt/Latency Scheduling/Latency Timing/Kernel/Services Conclusions

slide-3
SLIDE 3

3 mentor.com/embedded 3

Agenda

Introduction RTOS/Metrics Memory/Footprint Interrupt/Latency Scheduling/Latency Timing/Kernel/Services Conclusions

slide-4
SLIDE 4

4 mentor.com/embedded 4

Introduction$– Why?

Embedded&systems

– Enough&CPU&power&– just – Adequate&memory&– none&to&spare – Power&consumption&an&issue – Cost&normally&critical

Desktop&computers

– Infinite&CPU&power – Infinite&memory – Costs&nothing

slide-5
SLIDE 5

5 mentor.com/embedded 5

Introduction$– Choosing$an$RTOS

! RTOS/solutions

Proprietary/[inOhouseP/home/brew]

Commercial

– At/least/200/product/available

Open/source

! Asking/the/right/questions/is/important ! Understanding/the/answers/is/critical

Pitfalls/with/misinterpretation

slide-6
SLIDE 6

6 mentor.com/embedded 6

Agenda

Introduction RTOS$Metrics Memory/Footprint Interrupt/Latency Scheduling/Latency Timing/Kernel/Services Conclusions

slide-7
SLIDE 7

7 mentor.com/embedded 7

RTOS$Metrics

! Three/common/categories:

Memory/footprint

– Program/and/data

Latency

– Interrupt/and/scheduling

Services/performance

! No/real/standardization

Embedded/Microprocessor/Benchmark/Consortium/(EEMBC)/not/ widely/adopted

– Oriented/towards/CPU/benchmarking

slide-8
SLIDE 8

8 mentor.com/embedded 8

Agenda

Introduction RTOS/Metrics Memory$Footprint Interrupt/Latency Scheduling/Latency Timing/Kernel/Services Conclusions

slide-9
SLIDE 9

9 mentor.com/embedded 9

Memory$Footprint

! RAM/and/ROM/requirements/of/RTOS

On/a/specific/platform

! ROM&size:

– Kernel&code – ReadGonly&data – Runtime&library&code – Maybe&in&flashH&possibly& copied&to&RAM

! RAM&size:

– Kernel&data&structures – Global&variables – May&need&accommodate& “ROM”

slide-10
SLIDE 10

10 mentor.com/embedded 10

Memory$Footprint$– Dependencies$

! Key/factors/affect/the/footprint/calculation ! CPU/architecture

Huge/effect/on/number/of/instructions

! Software/configuration

Which/kernel/components/are/included

Scalability/...

! Compiler/optimization

Reduces/code/size,/but/may/adversely/affect/performance

slide-11
SLIDE 11

11 mentor.com/embedded 11 11

Memory$Footprint$– Scalability$

Service&#1 Service&#2 Service&#3 Service&#4 Service&#271

RTOS

… rtos_call_1(); … rtos_call_3(); … rtos_call_157(); …

Application Code

Service&#1 Service&#3 Service&#157

RTOS core

Application Memory

slide-12
SLIDE 12

12 mentor.com/embedded 12

Memory$Footprint$– Measurement$

! Making/measurement/need/not/be/difficult ! Two/key/methods:

Memory/MAP/file

– Generated/by/standard/linkers – Quality/and/detail/varies/between/tools

Specific/tool

– Shows/footprint/information/for/selected/executable/image – Example:/objdump

slide-13
SLIDE 13

13 mentor.com/embedded 13

Memory$Footprint$– Importance$

! Limited/memory/availability

Small/onOchip/memory

No/external/memory/option

Application/code/is/priority

! Larger/systems

Kernel/performance/a/priority

Place/in/onOchip/memory

Lock/into/cache

! Using/a/bootloader

NonOvolatile/memory/and/RAM/space/used

slide-14
SLIDE 14

14 mentor.com/embedded 14

Memory$Footprint$– Pitfalls$

! Vendor/data/can/be/readily/misinterpreted ! Look/at/minimum/configuration/definition

It/may/be/a/tiny,/impractical/subset

! Runtime/library/functions/are/often/not/included ! RAM/ROM/sizes/should/have/a/min/max/range

RAM/is/likely/to/be/application/dependent

ROM/driven/by/kernel/configuration

– Need/minimum/“useable”/size – Also/maximum/measure/with/all/services

Scalability/variable/– may/be/different/kernel/versions

slide-15
SLIDE 15

15 mentor.com/embedded 15

Memory$Footprint$– Example$

! Nucleus/RTOS/kernel/is/fully/scalable ! Example:/ARM/Cortex/A8/in/ARM/mode ! Built/with/Mentor/Sourcery/CodeBench/toolchain ! Full/optimization/for/size ! ROM/=/12O30/Kbytes ! RAM/=/500/bytes

slide-16
SLIDE 16

16 mentor.com/embedded 16

Memory$Footprint$– Example$

! Min/has/essential/kernel/services/[dynamic/memory,/

threads,/semaphores,/events,/queues]

Runtime/library/excluded

! Max/includes/all/kernel/services ! Compiling/for/ThumbO2/mode/reduces/ROM/by/35%

So/Nucleus/kernel/can/use/7.8/Kbytes/on/a/CortexOM/based/ controller

slide-17
SLIDE 17

17 mentor.com/embedded 17

Agenda

Introduction RTOS/Metrics Memory/Footprint Interrupt$Latency Scheduling/Latency Timing/Kernel/Services Conclusions

slide-18
SLIDE 18

18 mentor.com/embedded 18

Interrupt$Latency

Definitions/of/interrupt/latency

slide-19
SLIDE 19

19 mentor.com/embedded 19

Interrupt$Latency$– Definition$

! Different/definitions ! System:/Time/between/interrupt/assertion/and/the/instant/

an/observable/response/happens

! OS:/Duration/of/when/the/CPU/was/interrupted/until/the/

start/of/the/corresponding/interrupt/service/routine/(ISR)

This/is/really/OS/overhead

Many/vendors/refer/to/this/as/the/latency

Hence/often/report/zero/latency

slide-20
SLIDE 20

20 mentor.com/embedded 20

Interrupt$Latency$– Measurement$

Interrupt/response/is/the/sum/of/two/distinct/times: ƮIL =$ƮH$+ ƮOS where:

ƮH is/the/hardware/dependent/time

– depends/on/the/interrupt/controller/on/the/board/as/well/as/the/type/

  • f/the/interrupt

ƮOS is/the/OS/induced/overhead

– Best/and/worst/case/scenarios – Worst/when/kernel/disables/interrupts

slide-21
SLIDE 21

21 mentor.com/embedded 21

Interrupt$Latency$– Measurement$

! Best/approach/is/to/record/time/between/interrupts/source/

and/response

Use/an/oscilloscope

For/example:

– One/GPIO/pin/can/generate/an/interrupt – Another/pin/toggled/at/the/start/of/the/ISR

slide-22
SLIDE 22

22 mentor.com/embedded 22

Interrupt$Latency$– Importance

! Specific/types/of/designs/rely/on/this/metric:

Time/critical

Fault/tolerant

! If/high/I/O/bandwidth/is/needed,/measure/the/latency/of/a/

particular/interrupt

! Most/systems/can/tolerate/interrupt/latency/of/tens/of/

microseconds

slide-23
SLIDE 23

23 mentor.com/embedded 23

Interrupt$Latency$– Pitfalls$

! Main/danger/is/interpretation/of/published/figures

Hardware6configuration

– Which&platform? – CPU&speed? – Cache&configuration? – Timer&frequency? – Interrupt&controller&type?

OS6configuration

– Where&is&code&running& from?&[Flash,&SDRAM&...] – Which&interrupt&used? – Code&optimized&for&speed? – Is&metric&best&or&average& case?

slide-24
SLIDE 24

24 mentor.com/embedded 24

Interrupt$Latency$– Example$

! Nucleus/RTOS

ARM/Cortex/A8

600MHz

Running/from/SRAM

! Average/interrupt/latency/of/less/than/0.5/microseconds

slide-25
SLIDE 25

25 mentor.com/embedded 25

Agenda

Introduction RTOS/Metrics Memory/Footprint Interrupt/Latency Scheduling$Latency Timing/Kernel/Services Conclusions

slide-26
SLIDE 26

26 mentor.com/embedded 26

Scheduling$Latency$– Definition$

! Performance/of/RTOS/thread/scheduler ! Very/wide/variation/in/measurement/technique/and/

interpretation

! Two/distinct/related/quantities:

Context/switch/time

Scheduling/overhead

slide-27
SLIDE 27

27 mentor.com/embedded 27

Scheduling$Latency$– Definition$

Context/switch/time

slide-28
SLIDE 28

28 mentor.com/embedded 28

Scheduling$Latency$– Definition$

Scheduling/overhead

slide-29
SLIDE 29

29 mentor.com/embedded 29

Scheduling$Latency$– Measurement$

Scheduling/latency/is/the/maximum/of/two/times: ƮSL =$MAX(ƮSO, ƮCS) where:

ƮSO is/the/scheduling/overhead

– End/of/ISR/to/start/of/task/schedule

ƮCS is/the/time/taken/to/save/and/restore/thread/context

slide-30
SLIDE 30

30 mentor.com/embedded 30

Scheduling$Latency$– Importance

! Most/systems/that/have/stringent/interrupt/latency/

demands/also/need/low/scheduling/latency

! Broadly,/systems/that/are:

Time/critical

Fault/tolerant

slide-31
SLIDE 31

31 mentor.com/embedded 31

Scheduling$Latency$– Pitfalls$

! Ignoring/initial/system/state

If/system/is/idle,/there/is/no/time/taken/saving/context

Hardware6configuration

– Which&platform? – CPU&speed? – Cache&configuration? – Timer&frequency? – Interrupt&controller&type?

OS6configuration

– Where&is&code&running& from?&[Flash,&SDRAM&...] – Which&interrupt&used? – Code&optimized&for&speed? – Is&metric&best&or&average& case?

slide-32
SLIDE 32

32 mentor.com/embedded 32

Scheduling$Latency$– Example$

! Nucleus/RTOS

ARM/Cortex/A8

600MHz

Running/from/SRAM

! Scheduling/latency/is/1.3/microseconds

slide-33
SLIDE 33

33 mentor.com/embedded 33

Agenda

Introduction RTOS/Metrics Memory/Footprint Interrupt/Latency Scheduling/Latency Timing$Kernel$Services Conclusions

slide-34
SLIDE 34

34 mentor.com/embedded 34

Timing$Kernel$Services

! RTOS/may/have/a/great/many/API/calls ! Timing/of/keys/ones/may/be/of/interest

Focus/on/frequently/used/API/calls

! Four/key/categories:

Threading/services

Synchronization/services

InterOprocess/communication/services

Memory/services

slide-35
SLIDE 35

35 mentor.com/embedded 35

Timing$Kernel$Services

Threading/Services

Control/of/fundamental/kernel/functionality:

– Create/thread – Start/thread – Resume/thread – Stop/thread

Many/multiOtaking/applications/make/heavy/use/of/these/calls

slide-36
SLIDE 36

36 mentor.com/embedded 36

Timing$Kernel$Services

Synchronization/Services

Services/to/synchronize/between/contexts,/like/an/ISR/and/a/ thread

Also/protection/of/critical/code/sections/from/concurrent/access

– e.g./Semaphore/may/be/used/by/Ethernet/ISR/to/write/data/into/

shared/memory/that/is/also/used/by/a/task

Timing/is/important/is/the/application/has/numerous/shared/ resources/or/peripherals

slide-37
SLIDE 37

37 mentor.com/embedded 37

Timing$Kernel$Services

InterOprocess/Communication/Services

Services/to/share/data/between/multiple/threads

Examples:

– FIFOs – Queues – Mailboxes – Event/flags

Many/multiOtaking/applications/make/heavy/use/of/this/type/of/ service

slide-38
SLIDE 38

38 mentor.com/embedded 38

Timing$Kernel$Services

Memory/Services

In/a/multiOthreaded/context,/kernel/is/used/to/manage/dynamic/ memory

Allocation/and/deOallocation/times/are/important

– Applications/with/large/data/throughput/are/particularly/sensitive

slide-39
SLIDE 39

39 mentor.com/embedded 39

Timing$Kernel$Services$– Pitfalls$

! Hardware/configuration

Which/platform?

CPU/speed?

Cache/configuration?

! OS/configuration

Where/is/code/running/from?/[Flash,/SDRAM/...]

Code/optimized/for/speed?

Is/metric/best/or/average/case?

Is/kernel/configured/for/reduced/error/checking?

slide-40
SLIDE 40

40 mentor.com/embedded 40

Timing$Kernel$Services$– Example

Nucleus$RTOS$Kernel$Service Time$in$µS Task/resumption 0.3 Task/suspension 0.3 Obtaining/a/semaphore 0.5 Set/an/event 0.4 Send/message/to/queue 0.9 Allocate/memory 0.2 DeOallocate/memory 0.7 Allocate/partition 0.4

slide-41
SLIDE 41

41 mentor.com/embedded 41

Agenda

Introduction RTOS/Metrics Memory/Footprint Interrupt/Latency Scheduling/Latency Timing/Kernel/Services Conclusions

slide-42
SLIDE 42

42 mentor.com/embedded 42

Conclusions

! RTOS/performance/data/provided/by/vendors/can/be/

useful

! It/can/also/be/misleading/if/it/is/misinterpreted ! Need/a/thorough/understanding/of:

Measurement/techniques

Terminology

TradeOoffs

to/conduct/fair/comparison

! Recommendation/is/to/rely/on/holistic/or/applicationO

  • riented/measurements
slide-43
SLIDE 43

mentor.com/embedded

Android'is'a'trademark'of'Google'Inc.'Use'of'this'trademark'is'subject'to'Google'Permissions. Linux'is'the'registered'trademark'of'Linus'Torvalds'in'the'U.S.'and'other'countries.

Colin/Walls

colin_walls@mentor.com http://blogs.mentor.com/colinwalls

Thank$you