SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler offline
An Embedded Soft Real
Time System in Go
Mirko Damiani
Software Engineer @ Develer
LinuxLab 3-4 Dec 2018
Overview
● Soft real time systems
● Our hardware/software solution
● Go advantages for embedded
● Go optimizations
Soft Real Time System
● Industrial machines
● Quality features
○ Color
○ Weight
○ Defects
○ Shape
○ ...
● Classification
○ Grouping items together,
according to quality features
Quality Classifier
Photo by Kate Buckley on flickr
Industrial Applications
Photo by SortingExpert on WikipediaPhoto from prozesstechnik
Specs & Outline
● 100 lanes
● 20 items/sec per lane
● 2000 items/sec
● 10 exits per lane
● Industrial scale
Photo by Chris Chadd from Pexels
Feeder
Sensor
Exit
Lane
Rotary
Encoder
Ejector
Classify
Need of Precision
● Items are eventually ejected
○ Precise timing of ejection
○ Precision of 250 us
○ Multiple exits
● Usually real time OS are used
○ Higher determinism
Hardware Architecture
Our Machine Layout
IO IO
exit 1 exit 2
ejectorssensors
BL
data in data out
checkpoint
● Boards
○ BL: Business Logic
○ IO: Input/Output
● Business Logic
○ Acquires data from sensors
○ Manages every lane
● Network traffic is heavy
○ Up to 250 sensors
○ Up to 2000 items per second
● Checkpoint
○ Trigger for classification
The Challenge
Canonical Way
● RTOS kernel
● Custom hardware & boards
● CANBUS communication
● Single board
● Firmware C bare metal
The Challenge: Linux and Go
Canonical Way
● RTOS kernel
● Custom hardware & boards
● CANBUS communication
● Single board
● Firmware C bare metal
Our Solution
● GNU/Linux standard kernel
● Hardware standard components
● Ethernet based communication
● Distributed system
● Go language
Why Linux?
GNU/Linux
● Real time processes
● Microprocessor boards
● No Safety Certifications
● Plenty of Drivers
● Separation of competences
● Debug on desktop with tools
● Many Languages & Libraries
RTOS
● Tasks with priorities
● Microcontrollers (no MMU)
● Safety and Certifications
● Limited number of Drivers
● Single big application
● Debug on hardware boards
● Few Languages and Libraries
Network connections
● “BL” Single Business Logic board
○ Freescale i.MX 6, Quad Core ARM Cortex A9 @ 1.2 GHz
○ Performs the items classification for every lane
● “IO” Multiple Input/Output boards
○ Develboard Atmel, Single Core ARM @ 600 MHz
○ Digital inputs and outputs
● Multiple sensor sensors
● Ethernet bus with standard switches/routers
BL
IO IO IO
Ethernet
Switch
Star topology
Different topology with Linux Sw bridge
BL
IO IO IO
BL
IO IO IO
Star topology
Serial topology
● Simplified cabling
● Sw bridge: 15% CPU
Latency for Soft Real Time
● Kernel driver with a precision of 250 us
○ DMA + double buffering
○ Buffer has a duration of 100 ms
○ Actual precision of 66 us
● Queue of scheduled activations
○ User space software writes activations to the kernel driver
● Soft real time latency
○ 100 ms + queue management ~= 150 ms
○ System can’t react faster than 150 ms (e.g. change of speed)
Rotary encoder
● Lanes are physically bound
○ Multiple encoders in case of
big machines
● Encoder steps
○ Square waves
○ 2000 steps/round
● Kernel driver
○ Parameters exported in sysfs
A
B
Z
Linear Interpolation
● We cannot synchronize thousands
times per second with Ethernet
● Synchronization every 100 ms
● Linear interpolation
○ Encoder accelerations are “slow” because
it’s bound to a mechanical transport
● Workaround of a real time protocol
t
#step
● Real curve
● Interpolated curve
BL/IO Clock Synchronization
● Activation messages are marked with a specific timestamp
○ We need to synchronize clocks
● Usually, NTP is used
○ Precision of ~milliseconds => Not enough for us
○ We need a precision of (at least) 250 us
● Precision Time Protocol IEEE 1585 (PTP)
● Two PTP timestamping models: Hardware or Software
○ Software timestamping: Kernel interrupt => Precision of ~microseconds
○ Hardware timestamping: Ethernet interface => Precision of ~nanoseconds
○ Develboard supports IEEE 1858, but software timestamping is enough
Go for Embedded
Basic Advantages
● Simple language, clients got used to it very quickly
● Simple documentation and maintenance
● Static binaries
● Large ecosystem of libraries
● Concurrent programming
● Easy cross compilation
○ Embedded (ARM)
○ Windows
○ Linux
Embedded: Go vs C++
● Stack trace and data race analysis
○ Valgrind slows down performance
● Debug tools
○ Remote debugging and system analysis (gdb vs pprof)
● Linter and code analysis
○ Easier to integrate static analysis tools (e.g. golint, go vet)
● Tags (go build -tags 
)
○ Useful for embedded apps and stubs
○ Cleaner approach compared to #ifdef
Fine tuning: Disassembly
● go tool objdump -s main.join -S <binary_name>
func join(strings []string) string {
0x8bae0 e59a1008 MOVW 0x8(R10), R1
0x8bae4 e15d0001 CMP R1, R13
0x8bae8 9a00001a B.LS 0x8bb58
e 0x8baec e52de024 MOVW.W R14, -0x24(R13)
0x8baf0 e3a00000 MOVW $0, R0
0x8baf4 e3a01000 MOVW $0, R1
0x8baf8 e3a02000 MOVW $0, R2
for _, str := range strings {
0x8bafc ea00000f B 0x8bb40
0x8bb00 e58d0020 MOVW R0, 0x20(R13)
0x8bb04 e59d3028 MOVW 0x28(R13), R3
0x8bb08 e7934180 MOVW (R3)(R0<<3), R4
0x8bb0c e0835180 ADD R0<<$3, R3, R5
0x8bb10 e5955004 MOVW 0x4(R5), R5
package main
import (
"fmt"
"os"
)
func join(strings []string) string {
var ret string
for _, str := range strings {
ret += str
}
return ret
}
func main() {
fmt.Println(join(os.Args[1:]))
}
How do we perform tests on Embedded?
1. Unit tests
2. Full integration tests
○ Integration framework
○ Mocking board/instruments as Goroutines
○ Easier than C++
○ Fast prototyping for tests
3. Continuous integration
○ The real embedded system was simulated on CircleCI
● Monitoring of performance
○ Metrics
○ Profiling
● Google pprof upstream version:
○ go get -u github.com/google/pprof
● Small CPU profile file => 10 minutes execution => just 185 KiB
○ Stand alone, no binary
○ Can read from both local file or over HTTP
○ pprof -http :8081 http://localhost:8080/debug/pprof/profile?seconds=30
Avoid Performance Regression
Hardware in the Loop
● Automatic performance monitoring
● We have a real hardware test bench
● We want to deploy our system
directly to the test bench
● Results from the test bench
are retrieved by CircleCI
Repo
CI
Metrics
Hardware
Remote Introspection via Browser
● Uncommon in embedded apps
● Expvar
○ Standard interface for public variables
○ Exports figures about the program
○ JSON format
// At global scope
var requestCount = expvar.NewInt("RequestCount")
...
func myHandler(w http.ResponseWriter, r *http.Request) {
requestCount.Add(1)
...
}
Go Optimizations
Metrics
● Performance analysis
○ We don’t want performance regressions
○ Refactoring
○ Test suites don’t help
● “Tachymeter” library to monitor metrics
○ Low impact, samples are added to a circular buffer
○ Average, Standard Deviation, Percentiles, Min, Max, 

● Multiple outputs
○ Formatted string, JSON string, Histogram text and html
○ HTTP endpoint for remote analysis
Checkpoint Margin
● Average
○ Avg 2.301660948s
○ StdDev 176.75148ms
● Percentiles
○ P75 2.222552667s
○ P95 1.921699001s
○ P99 1.721095s
○ P999 1.575430001s
● Limits
○ Max 2.916016667s
○ Min 1.464427001s
checkpointsensors
margin
activation
2 minutes run
How is Checkpoint Margin affected?
● I/O bound
● Reading packets from connections
● We need to read fairly from 250 tcp sockets
eth/tcpBL
S
S
S
Standard Network Loop
● One Goroutine per connection
○ 1. Read data from network
○ 2. Decode packets
○ 3. Send to main loop via channel
● chan packet
○ Sending one packet at time
to the main loop
● Can we do better?
main
loop
TCP
gorunTCP
gorunTCP
gorunTCP
Read
chan
packet
Concurrent
Goroutines
Batched Channel
● chan packet vs chan []packet
○ Sending one packet at time
is too slow
● Use a single channel write
operation to send all packets
received from a single TCP read
○ Minimizing channel writes is good
main
loop
TCP
gorunTCP
gorunTCP
gorunTCP
Read
chan
[ ]packet
Concurrent
Goroutines
Number of Channel Writes
● Channel
○ Buffered
○ Slice of packets
● Writes per second
○ 2000 → 25000 w/s
● Total GC STW time
○ 2.28 → 11.50 s
Channel Writes per Second [w/s]
● Checkpoint Margin [s]
● GC Time [s]
2 minutes run
Failed Test: Using a Mutex
● Goroutines will block on a mutex
○ High contention
○ Go scheduler is cooperative
● Deadline missed
○ Checkpoint event is delayed
● Conn.Read(): Channel Mutex
○ Min 13 us 13 us
○ Max 773 us 1.15 s
○ P99 64 us 510 ms
● Activation margin: Channel Mutex
○ P99 466 ms -1.13 s
main
loop
TCP
gorunTCP
gorunTCP
gorunTCP
Read
mutex
checkpoint
margin
activation
delay
Alternative: Using EPOLL
● EPOLL syscall allows to use
a single Goroutine
● MultiReader Go interface
○ Reading from multiple connections
○ Monitoring of multiple file descriptors
● Drawbacks
○ It can’t be used on Windows
○ Cannot use net.Socket
○ Maintenance
main
loop
TCP
Multi
Read
type MultiPacketReader interface {
// TCP connection with framing
Register(conn PacketConn)
// Reads from one of the
// registered connections
ReadPackets(packets [][]byte)
(n int, conn PacketConn, err error)
}
chan
[ ]packet
CPU Usage: EPOLL VS Go
● 4 CPUs in total
○ Graph shows just one CPU
(for simplicity)
● Go impl
○ CPU usage is higher...
○ 
 but more “uniform”
● EPOLL impl
○ CPU cores are switched
more frequently
● EPOLL
● Go
Time (2 minutes)
Conclusions
Thanks
mirko@develer.com
● Standard Linux OS and hardware
○ Faster development
○ Distributed system
● Testing and monitoring
○ Fast prototyping for tests
○ Profiling and metrics
○ Performance tests on real hardware
● Optimizations
○ Goroutines management
○ Packets reception
● Drawbacks
○ GC impact must be reduced
○ Mutex contention can be a problem
○ Network APIs are not flexible enough
● Go can be used for embedded apps!

Mais conteĂșdo relacionado

Mais procurados

Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Linaro
 
Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120
Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120
Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120Linaro
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!Linaro
 
LAS16-100K1: Welcome Keynote
LAS16-100K1: Welcome KeynoteLAS16-100K1: Welcome Keynote
LAS16-100K1: Welcome KeynoteLinaro
 
Kernel Recipes 2016 - New hwmon device registration API - Jean Delvare
Kernel Recipes 2016 -  New hwmon device registration API - Jean DelvareKernel Recipes 2016 -  New hwmon device registration API - Jean Delvare
Kernel Recipes 2016 - New hwmon device registration API - Jean DelvareAnne Nicolas
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageKernel TLV
 
BKK16-304 The State of GDB on AArch64
BKK16-304 The State of GDB on AArch64BKK16-304 The State of GDB on AArch64
BKK16-304 The State of GDB on AArch64Linaro
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesLinaro
 
LAS16-500: The Rise and Fall of Assembler and the VGIC from Hell
LAS16-500: The Rise and Fall of Assembler and the VGIC from HellLAS16-500: The Rise and Fall of Assembler and the VGIC from Hell
LAS16-500: The Rise and Fall of Assembler and the VGIC from HellLinaro
 
Davide Berardi - Linux hardening and security measures against Memory corruption
Davide Berardi - Linux hardening and security measures against Memory corruptionDavide Berardi - Linux hardening and security measures against Memory corruption
Davide Berardi - Linux hardening and security measures against Memory corruptionlinuxlab_conf
 
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...linuxlab_conf
 
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLinaro
 
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...linuxlab_conf
 
LAS16-201: ART JIT in Android N
LAS16-201: ART JIT in Android NLAS16-201: ART JIT in Android N
LAS16-201: ART JIT in Android NLinaro
 
Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102Linaro
 
ebpf and IO Visor: The What, how, and what next!
ebpf and IO Visor: The What, how, and what next!ebpf and IO Visor: The What, how, and what next!
ebpf and IO Visor: The What, how, and what next!Affan Syed
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLinaro
 
Kernel Recipes 2016 - Landlock LSM: Unprivileged sandboxing
Kernel Recipes 2016 - Landlock LSM: Unprivileged sandboxingKernel Recipes 2016 - Landlock LSM: Unprivileged sandboxing
Kernel Recipes 2016 - Landlock LSM: Unprivileged sandboxingAnne Nicolas
 
Libpcap
LibpcapLibpcap
Libpcapliu qiang
 
LAS16-405:OpenDataPlane: Software Defined Dataplane leader
LAS16-405:OpenDataPlane: Software Defined Dataplane leaderLAS16-405:OpenDataPlane: Software Defined Dataplane leader
LAS16-405:OpenDataPlane: Software Defined Dataplane leaderLinaro
 

Mais procurados (20)

Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
 
Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120
Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120
Linux-wpan: IEEE 802.15.4 and 6LoWPAN in the Linux Kernel - BUD17-120
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
LAS16-100K1: Welcome Keynote
LAS16-100K1: Welcome KeynoteLAS16-100K1: Welcome Keynote
LAS16-100K1: Welcome Keynote
 
Kernel Recipes 2016 - New hwmon device registration API - Jean Delvare
Kernel Recipes 2016 -  New hwmon device registration API - Jean DelvareKernel Recipes 2016 -  New hwmon device registration API - Jean Delvare
Kernel Recipes 2016 - New hwmon device registration API - Jean Delvare
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 
BKK16-304 The State of GDB on AArch64
BKK16-304 The State of GDB on AArch64BKK16-304 The State of GDB on AArch64
BKK16-304 The State of GDB on AArch64
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
 
LAS16-500: The Rise and Fall of Assembler and the VGIC from Hell
LAS16-500: The Rise and Fall of Assembler and the VGIC from HellLAS16-500: The Rise and Fall of Assembler and the VGIC from Hell
LAS16-500: The Rise and Fall of Assembler and the VGIC from Hell
 
Davide Berardi - Linux hardening and security measures against Memory corruption
Davide Berardi - Linux hardening and security measures against Memory corruptionDavide Berardi - Linux hardening and security measures against Memory corruption
Davide Berardi - Linux hardening and security measures against Memory corruption
 
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
 
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
 
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
 
LAS16-201: ART JIT in Android N
LAS16-201: ART JIT in Android NLAS16-201: ART JIT in Android N
LAS16-201: ART JIT in Android N
 
Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102
 
ebpf and IO Visor: The What, how, and what next!
ebpf and IO Visor: The What, how, and what next!ebpf and IO Visor: The What, how, and what next!
ebpf and IO Visor: The What, how, and what next!
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel Awareness
 
Kernel Recipes 2016 - Landlock LSM: Unprivileged sandboxing
Kernel Recipes 2016 - Landlock LSM: Unprivileged sandboxingKernel Recipes 2016 - Landlock LSM: Unprivileged sandboxing
Kernel Recipes 2016 - Landlock LSM: Unprivileged sandboxing
 
Libpcap
LibpcapLibpcap
Libpcap
 
LAS16-405:OpenDataPlane: Software Defined Dataplane leader
LAS16-405:OpenDataPlane: Software Defined Dataplane leaderLAS16-405:OpenDataPlane: Software Defined Dataplane leader
LAS16-405:OpenDataPlane: Software Defined Dataplane leader
 

Semelhante a An Embedded Soft Real Time System in Go Optimized for Performance

Kraken mesoscon 2018
Kraken mesoscon 2018Kraken mesoscon 2018
Kraken mesoscon 2018joeyzhang1989928
 
Keynote: Scaling Sensu Go
Keynote: Scaling Sensu GoKeynote: Scaling Sensu Go
Keynote: Scaling Sensu GoSensu Inc.
 
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/SecNetflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/SecPeter Bakas
 
MOVED: The challenge of SVE in QEMU - SFO17-103
MOVED: The challenge of SVE in QEMU - SFO17-103MOVED: The challenge of SVE in QEMU - SFO17-103
MOVED: The challenge of SVE in QEMU - SFO17-103Linaro
 
Logs @ OVHcloud
Logs @ OVHcloudLogs @ OVHcloud
Logs @ OVHcloudOVHcloud
 
Migrating to Apache Spark at Netflix
Migrating to Apache Spark at NetflixMigrating to Apache Spark at Netflix
Migrating to Apache Spark at NetflixDatabricks
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodbPGConf APAC
 
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kevin Lynch
 
MTCNA Intro to routerOS
MTCNA Intro to routerOSMTCNA Intro to routerOS
MTCNA Intro to routerOSGLC Networks
 
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...Yiran Wang
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network InterfacesKernel TLV
 
Kubernetes from scratch at veepee sysadmins days 2019
Kubernetes from scratch at veepee   sysadmins days 2019Kubernetes from scratch at veepee   sysadmins days 2019
Kubernetes from scratch at veepee sysadmins days 2019🔧 Loïc BLOT
 
ELC 2016 - I2C hacking demystified
ELC 2016 - I2C hacking demystifiedELC 2016 - I2C hacking demystified
ELC 2016 - I2C hacking demystifiedIgor Stoppa
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbWei Shan Ang
 
Performance challenges in software networking
Performance challenges in software networkingPerformance challenges in software networking
Performance challenges in software networkingStephen Hemminger
 
HBaseCon 2015: OpenTSDB and AsyncHBase Update
HBaseCon 2015: OpenTSDB and AsyncHBase UpdateHBaseCon 2015: OpenTSDB and AsyncHBase Update
HBaseCon 2015: OpenTSDB and AsyncHBase UpdateHBaseCon
 
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideBKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideLinaro
 
Improving Kafka at-least-once performance at Uber
Improving Kafka at-least-once performance at UberImproving Kafka at-least-once performance at Uber
Improving Kafka at-least-once performance at UberYing Zheng
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2aspyker
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hoodRichardWarburton
 

Semelhante a An Embedded Soft Real Time System in Go Optimized for Performance (20)

Kraken mesoscon 2018
Kraken mesoscon 2018Kraken mesoscon 2018
Kraken mesoscon 2018
 
Keynote: Scaling Sensu Go
Keynote: Scaling Sensu GoKeynote: Scaling Sensu Go
Keynote: Scaling Sensu Go
 
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/SecNetflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
 
MOVED: The challenge of SVE in QEMU - SFO17-103
MOVED: The challenge of SVE in QEMU - SFO17-103MOVED: The challenge of SVE in QEMU - SFO17-103
MOVED: The challenge of SVE in QEMU - SFO17-103
 
Logs @ OVHcloud
Logs @ OVHcloudLogs @ OVHcloud
Logs @ OVHcloud
 
Migrating to Apache Spark at Netflix
Migrating to Apache Spark at NetflixMigrating to Apache Spark at Netflix
Migrating to Apache Spark at Netflix
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
 
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
 
MTCNA Intro to routerOS
MTCNA Intro to routerOSMTCNA Intro to routerOS
MTCNA Intro to routerOS
 
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
 
Kubernetes from scratch at veepee sysadmins days 2019
Kubernetes from scratch at veepee   sysadmins days 2019Kubernetes from scratch at veepee   sysadmins days 2019
Kubernetes from scratch at veepee sysadmins days 2019
 
ELC 2016 - I2C hacking demystified
ELC 2016 - I2C hacking demystifiedELC 2016 - I2C hacking demystified
ELC 2016 - I2C hacking demystified
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodb
 
Performance challenges in software networking
Performance challenges in software networkingPerformance challenges in software networking
Performance challenges in software networking
 
HBaseCon 2015: OpenTSDB and AsyncHBase Update
HBaseCon 2015: OpenTSDB and AsyncHBase UpdateHBaseCon 2015: OpenTSDB and AsyncHBase Update
HBaseCon 2015: OpenTSDB and AsyncHBase Update
 
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideBKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
 
Improving Kafka at-least-once performance at Uber
Improving Kafka at-least-once performance at UberImproving Kafka at-least-once performance at Uber
Improving Kafka at-least-once performance at Uber
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hood
 

Mais de linuxlab_conf

Jonathan Corbet - Keynote: The Kernel Report
Jonathan Corbet - Keynote: The Kernel ReportJonathan Corbet - Keynote: The Kernel Report
Jonathan Corbet - Keynote: The Kernel Reportlinuxlab_conf
 
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...linuxlab_conf
 
Bruno Verachten - The Android device farm that fits in a (cloudy) pocket
Bruno Verachten - The Android device farm that fits in a (cloudy) pocketBruno Verachten - The Android device farm that fits in a (cloudy) pocket
Bruno Verachten - The Android device farm that fits in a (cloudy) pocketlinuxlab_conf
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchlinuxlab_conf
 
Jacopo Mondi - Complex cameras are complex
Jacopo Mondi - Complex cameras are complexJacopo Mondi - Complex cameras are complex
Jacopo Mondi - Complex cameras are complexlinuxlab_conf
 
Dario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugsDario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugslinuxlab_conf
 
Tommaso Cucinotta - Low-latency and power-efficient audio applications on Linux
Tommaso Cucinotta - Low-latency and power-efficient audio applications on LinuxTommaso Cucinotta - Low-latency and power-efficient audio applications on Linux
Tommaso Cucinotta - Low-latency and power-efficient audio applications on Linuxlinuxlab_conf
 
Angelo Compagnucci - Upgrading buildroot based devices with swupdate
Angelo Compagnucci - Upgrading buildroot based devices with swupdateAngelo Compagnucci - Upgrading buildroot based devices with swupdate
Angelo Compagnucci - Upgrading buildroot based devices with swupdatelinuxlab_conf
 
Stefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto ProjectStefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto Projectlinuxlab_conf
 
Luca Abeni - Real-Time Virtual Machines with Linux and kvm
Luca Abeni - Real-Time Virtual Machines with Linux and kvmLuca Abeni - Real-Time Virtual Machines with Linux and kvm
Luca Abeni - Real-Time Virtual Machines with Linux and kvmlinuxlab_conf
 
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily JobLuca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Joblinuxlab_conf
 

Mais de linuxlab_conf (11)

Jonathan Corbet - Keynote: The Kernel Report
Jonathan Corbet - Keynote: The Kernel ReportJonathan Corbet - Keynote: The Kernel Report
Jonathan Corbet - Keynote: The Kernel Report
 
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
 
Bruno Verachten - The Android device farm that fits in a (cloudy) pocket
Bruno Verachten - The Android device farm that fits in a (cloudy) pocketBruno Verachten - The Android device farm that fits in a (cloudy) pocket
Bruno Verachten - The Android device farm that fits in a (cloudy) pocket
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Jacopo Mondi - Complex cameras are complex
Jacopo Mondi - Complex cameras are complexJacopo Mondi - Complex cameras are complex
Jacopo Mondi - Complex cameras are complex
 
Dario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugsDario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugs
 
Tommaso Cucinotta - Low-latency and power-efficient audio applications on Linux
Tommaso Cucinotta - Low-latency and power-efficient audio applications on LinuxTommaso Cucinotta - Low-latency and power-efficient audio applications on Linux
Tommaso Cucinotta - Low-latency and power-efficient audio applications on Linux
 
Angelo Compagnucci - Upgrading buildroot based devices with swupdate
Angelo Compagnucci - Upgrading buildroot based devices with swupdateAngelo Compagnucci - Upgrading buildroot based devices with swupdate
Angelo Compagnucci - Upgrading buildroot based devices with swupdate
 
Stefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto ProjectStefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto Project
 
Luca Abeni - Real-Time Virtual Machines with Linux and kvm
Luca Abeni - Real-Time Virtual Machines with Linux and kvmLuca Abeni - Real-Time Virtual Machines with Linux and kvm
Luca Abeni - Real-Time Virtual Machines with Linux and kvm
 
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily JobLuca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
 

Último

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...soniya singh
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto GonzĂĄlez Trastoy
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Último (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Call Girls In Mukherjee Nagar đŸ“± 9999965857 đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar đŸ“±  9999965857  đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar đŸ“±  9999965857  đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar đŸ“± 9999965857 đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi âžĄïž 8264348440 💋📞 Independent Escort S...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

An Embedded Soft Real Time System in Go Optimized for Performance

  • 1. An Embedded Soft Real Time System in Go Mirko Damiani Software Engineer @ Develer LinuxLab 3-4 Dec 2018
  • 2. Overview ● Soft real time systems ● Our hardware/software solution ● Go advantages for embedded ● Go optimizations
  • 3. Soft Real Time System
  • 4. ● Industrial machines ● Quality features ○ Color ○ Weight ○ Defects ○ Shape ○ ... ● Classification ○ Grouping items together, according to quality features Quality Classifier Photo by Kate Buckley on flickr
  • 5. Industrial Applications Photo by SortingExpert on WikipediaPhoto from prozesstechnik
  • 6. Specs & Outline ● 100 lanes ● 20 items/sec per lane ● 2000 items/sec ● 10 exits per lane ● Industrial scale Photo by Chris Chadd from Pexels Feeder Sensor Exit Lane Rotary Encoder Ejector Classify
  • 7. Need of Precision ● Items are eventually ejected ○ Precise timing of ejection ○ Precision of 250 us ○ Multiple exits ● Usually real time OS are used ○ Higher determinism
  • 9. Our Machine Layout IO IO exit 1 exit 2 ejectorssensors BL data in data out checkpoint ● Boards ○ BL: Business Logic ○ IO: Input/Output ● Business Logic ○ Acquires data from sensors ○ Manages every lane ● Network traffic is heavy ○ Up to 250 sensors ○ Up to 2000 items per second ● Checkpoint ○ Trigger for classification
  • 10. The Challenge Canonical Way ● RTOS kernel ● Custom hardware & boards ● CANBUS communication ● Single board ● Firmware C bare metal
  • 11. The Challenge: Linux and Go Canonical Way ● RTOS kernel ● Custom hardware & boards ● CANBUS communication ● Single board ● Firmware C bare metal Our Solution ● GNU/Linux standard kernel ● Hardware standard components ● Ethernet based communication ● Distributed system ● Go language
  • 12. Why Linux? GNU/Linux ● Real time processes ● Microprocessor boards ● No Safety Certifications ● Plenty of Drivers ● Separation of competences ● Debug on desktop with tools ● Many Languages & Libraries RTOS ● Tasks with priorities ● Microcontrollers (no MMU) ● Safety and Certifications ● Limited number of Drivers ● Single big application ● Debug on hardware boards ● Few Languages and Libraries
  • 13. Network connections ● “BL” Single Business Logic board ○ Freescale i.MX 6, Quad Core ARM Cortex A9 @ 1.2 GHz ○ Performs the items classification for every lane ● “IO” Multiple Input/Output boards ○ Develboard Atmel, Single Core ARM @ 600 MHz ○ Digital inputs and outputs ● Multiple sensor sensors ● Ethernet bus with standard switches/routers BL IO IO IO Ethernet Switch Star topology
  • 14. Different topology with Linux Sw bridge BL IO IO IO BL IO IO IO Star topology Serial topology ● Simplified cabling ● Sw bridge: 15% CPU
  • 15. Latency for Soft Real Time ● Kernel driver with a precision of 250 us ○ DMA + double buffering ○ Buffer has a duration of 100 ms ○ Actual precision of 66 us ● Queue of scheduled activations ○ User space software writes activations to the kernel driver ● Soft real time latency ○ 100 ms + queue management ~= 150 ms ○ System can’t react faster than 150 ms (e.g. change of speed)
  • 16. Rotary encoder ● Lanes are physically bound ○ Multiple encoders in case of big machines ● Encoder steps ○ Square waves ○ 2000 steps/round ● Kernel driver ○ Parameters exported in sysfs A B Z
  • 17. Linear Interpolation ● We cannot synchronize thousands times per second with Ethernet ● Synchronization every 100 ms ● Linear interpolation ○ Encoder accelerations are “slow” because it’s bound to a mechanical transport ● Workaround of a real time protocol t #step ● Real curve ● Interpolated curve
  • 18. BL/IO Clock Synchronization ● Activation messages are marked with a specific timestamp ○ We need to synchronize clocks ● Usually, NTP is used ○ Precision of ~milliseconds => Not enough for us ○ We need a precision of (at least) 250 us ● Precision Time Protocol IEEE 1585 (PTP) ● Two PTP timestamping models: Hardware or Software ○ Software timestamping: Kernel interrupt => Precision of ~microseconds ○ Hardware timestamping: Ethernet interface => Precision of ~nanoseconds ○ Develboard supports IEEE 1858, but software timestamping is enough
  • 20. Basic Advantages ● Simple language, clients got used to it very quickly ● Simple documentation and maintenance ● Static binaries ● Large ecosystem of libraries ● Concurrent programming ● Easy cross compilation ○ Embedded (ARM) ○ Windows ○ Linux
  • 21. Embedded: Go vs C++ ● Stack trace and data race analysis ○ Valgrind slows down performance ● Debug tools ○ Remote debugging and system analysis (gdb vs pprof) ● Linter and code analysis ○ Easier to integrate static analysis tools (e.g. golint, go vet) ● Tags (go build -tags 
) ○ Useful for embedded apps and stubs ○ Cleaner approach compared to #ifdef
  • 22. Fine tuning: Disassembly ● go tool objdump -s main.join -S <binary_name> func join(strings []string) string { 0x8bae0 e59a1008 MOVW 0x8(R10), R1 0x8bae4 e15d0001 CMP R1, R13 0x8bae8 9a00001a B.LS 0x8bb58 e 0x8baec e52de024 MOVW.W R14, -0x24(R13) 0x8baf0 e3a00000 MOVW $0, R0 0x8baf4 e3a01000 MOVW $0, R1 0x8baf8 e3a02000 MOVW $0, R2 for _, str := range strings { 0x8bafc ea00000f B 0x8bb40 0x8bb00 e58d0020 MOVW R0, 0x20(R13) 0x8bb04 e59d3028 MOVW 0x28(R13), R3 0x8bb08 e7934180 MOVW (R3)(R0<<3), R4 0x8bb0c e0835180 ADD R0<<$3, R3, R5 0x8bb10 e5955004 MOVW 0x4(R5), R5 package main import ( "fmt" "os" ) func join(strings []string) string { var ret string for _, str := range strings { ret += str } return ret } func main() { fmt.Println(join(os.Args[1:])) }
  • 23. How do we perform tests on Embedded? 1. Unit tests 2. Full integration tests ○ Integration framework ○ Mocking board/instruments as Goroutines ○ Easier than C++ ○ Fast prototyping for tests 3. Continuous integration ○ The real embedded system was simulated on CircleCI
  • 24. ● Monitoring of performance ○ Metrics ○ Profiling ● Google pprof upstream version: ○ go get -u github.com/google/pprof ● Small CPU profile file => 10 minutes execution => just 185 KiB ○ Stand alone, no binary ○ Can read from both local file or over HTTP ○ pprof -http :8081 http://localhost:8080/debug/pprof/profile?seconds=30 Avoid Performance Regression
  • 25. Hardware in the Loop ● Automatic performance monitoring ● We have a real hardware test bench ● We want to deploy our system directly to the test bench ● Results from the test bench are retrieved by CircleCI Repo CI Metrics Hardware
  • 26. Remote Introspection via Browser ● Uncommon in embedded apps ● Expvar ○ Standard interface for public variables ○ Exports figures about the program ○ JSON format // At global scope var requestCount = expvar.NewInt("RequestCount") ... func myHandler(w http.ResponseWriter, r *http.Request) { requestCount.Add(1) ... }
  • 28. Metrics ● Performance analysis ○ We don’t want performance regressions ○ Refactoring ○ Test suites don’t help ● “Tachymeter” library to monitor metrics ○ Low impact, samples are added to a circular buffer ○ Average, Standard Deviation, Percentiles, Min, Max, 
 ● Multiple outputs ○ Formatted string, JSON string, Histogram text and html ○ HTTP endpoint for remote analysis
  • 29. Checkpoint Margin ● Average ○ Avg 2.301660948s ○ StdDev 176.75148ms ● Percentiles ○ P75 2.222552667s ○ P95 1.921699001s ○ P99 1.721095s ○ P999 1.575430001s ● Limits ○ Max 2.916016667s ○ Min 1.464427001s checkpointsensors margin activation 2 minutes run
  • 30. How is Checkpoint Margin affected? ● I/O bound ● Reading packets from connections ● We need to read fairly from 250 tcp sockets eth/tcpBL S S S
  • 31. Standard Network Loop ● One Goroutine per connection ○ 1. Read data from network ○ 2. Decode packets ○ 3. Send to main loop via channel ● chan packet ○ Sending one packet at time to the main loop ● Can we do better? main loop TCP gorunTCP gorunTCP gorunTCP Read chan packet Concurrent Goroutines
  • 32. Batched Channel ● chan packet vs chan []packet ○ Sending one packet at time is too slow ● Use a single channel write operation to send all packets received from a single TCP read ○ Minimizing channel writes is good main loop TCP gorunTCP gorunTCP gorunTCP Read chan [ ]packet Concurrent Goroutines
  • 33. Number of Channel Writes ● Channel ○ Buffered ○ Slice of packets ● Writes per second ○ 2000 → 25000 w/s ● Total GC STW time ○ 2.28 → 11.50 s Channel Writes per Second [w/s] ● Checkpoint Margin [s] ● GC Time [s] 2 minutes run
  • 34. Failed Test: Using a Mutex ● Goroutines will block on a mutex ○ High contention ○ Go scheduler is cooperative ● Deadline missed ○ Checkpoint event is delayed ● Conn.Read(): Channel Mutex ○ Min 13 us 13 us ○ Max 773 us 1.15 s ○ P99 64 us 510 ms ● Activation margin: Channel Mutex ○ P99 466 ms -1.13 s main loop TCP gorunTCP gorunTCP gorunTCP Read mutex checkpoint margin activation delay
  • 35. Alternative: Using EPOLL ● EPOLL syscall allows to use a single Goroutine ● MultiReader Go interface ○ Reading from multiple connections ○ Monitoring of multiple file descriptors ● Drawbacks ○ It can’t be used on Windows ○ Cannot use net.Socket ○ Maintenance main loop TCP Multi Read type MultiPacketReader interface { // TCP connection with framing Register(conn PacketConn) // Reads from one of the // registered connections ReadPackets(packets [][]byte) (n int, conn PacketConn, err error) } chan [ ]packet
  • 36. CPU Usage: EPOLL VS Go ● 4 CPUs in total ○ Graph shows just one CPU (for simplicity) ● Go impl ○ CPU usage is higher... ○ 
 but more “uniform” ● EPOLL impl ○ CPU cores are switched more frequently ● EPOLL ● Go Time (2 minutes)
  • 37. Conclusions Thanks mirko@develer.com ● Standard Linux OS and hardware ○ Faster development ○ Distributed system ● Testing and monitoring ○ Fast prototyping for tests ○ Profiling and metrics ○ Performance tests on real hardware ● Optimizations ○ Goroutines management ○ Packets reception ● Drawbacks ○ GC impact must be reduced ○ Mutex contention can be a problem ○ Network APIs are not flexible enough ● Go can be used for embedded apps!