Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pioneering Real-Time

Pioneering Real-Time

My keynote from PyCon Balkan 2019

Andrew Godwin

October 03, 2019
Tweet

More Decks by Andrew Godwin

Other Decks in Programming

Transcript

  1. PIONEERING
    REAL-TIME
    ANDREW GODWIN // @andrewgodwin

    View full-size slide

  2. Hi, I’m
    Andrew Godwin

    View full-size slide

  3. async def view(request):
    data = await api_call(pk=5)
    return render(request, "a.html", …)

    View full-size slide

  4. "The Real-Time Web"

    View full-size slide

  5. AJAX
    1999
    Comet
    2006
    WebSockets
    2011

    View full-size slide

  6. “A system in which input data is
    processed within milliseconds
    so that it is available
    virtually immediately

    View full-size slide

  7. CPU cores run one thing at a time
    (yes, computers are basically a giant lie)

    View full-size slide

  8. Program 2
    Program 3
    Program 1

    View full-size slide

  9. Scheduling
    The art of running multiple things at once

    View full-size slide

  10. Program 2
    Program 3
    Program 1 300 cycles
    300 cycles
    300 cycles

    View full-size slide

  11. Program 2
    Program 3
    Program 1 300 cycles
    Restore
    Save
    Restore
    Save
    Restore
    Save
    30 cycles
    30 cycles
    300 cycles
    30 cycles
    30 cycles
    300 cycles
    30 cycles
    30 cycles

    View full-size slide

  12. Context switching is expensive
    The more you have, the worse it gets

    View full-size slide

  13. Python's threading has this problem!
    The more you have, the worse it gets

    View full-size slide

  14. Active
    Threads
    Idle
    Threads Runtime
    1 0 1.3 seconds
    1 1 2.3 seconds
    1 5 5.4 seconds
    1 30 39 seconds
    1 100 15 minutes

    View full-size slide

  15. "Boxcar" scheduling has… issues
    Don't ever write avionics software like this! Thanks.

    View full-size slide

  16. 72kb
    Woven core memory

    View full-size slide

  17. 0.085 Mhz
    processor

    View full-size slide


  18. Don Eyles
    ...when the guidance system
    was first being conceived, the
    onboard software was
    almost an afterthought

    View full-size slide

  19. Priority-based Executive
    Please do write avionics software like this.

    View full-size slide

  20. Job Priorities
    Higher numbers beat lower
    Limited job "RAM"
    Only 7 running at once
    Interrupts from hardware
    Descent radar, keyboard, etc.

    View full-size slide

  21. Predictable Software
    They knew exactly what ran and what it took

    View full-size slide

  22. ...Unpredictable Hardware
    It's never easy, especially in space.

    View full-size slide

  23. Two differently phased 800Mhz clocks
    This is really bad, trust me.

    View full-size slide

  24. False detections stole computer time
    The radar system had to update the guidance computer

    View full-size slide

  25. Descent Phase: 85% load
    Capsule orientation and thrust calculations
    Hardware Bug: 13%
    Caused by the descent radar
    Display Routine: 5%
    Astronauts trying to see how far to go

    View full-size slide

  26. SERVICER never gets to run
    But the system keeps trying to schedule it

    View full-size slide

  27. Alarm 1202
    The computer self-restarts, but keeps crashing

    View full-size slide

  28. Buzz Aldrin works it out
    Turns off the display routine to bring the load under 100%

    View full-size slide

  29. Apollo 11 was almost a failure
    ...but good software design prevented it

    View full-size slide

  30. Apollo 9
    First flight test of Lunar Module
    Apollo 10
    Second test and partial descent of Lunar Module
    Apollo 11
    First Moon landing

    View full-size slide


  31. Eugene A. Cernan, recounting Apollo 10
    Don't give those guys an
    opportunity to land,
    'cause they might!

    View full-size slide

  32. Building for Failure
    Software is only as good as its worst outing

    View full-size slide


  33. Don Eyles
    During simulations we
    sometimes pushed the
    [restart] button randomly

    View full-size slide

  34. We often only design for the good cases
    After all, that's what we're expecting to happen

    View full-size slide

  35. Hardware is always unpredictable
    Disks, networks, even keyboards and mice

    View full-size slide

  36. Can your software survive a crash?
    Or does it need a clean shutdown to work?

    View full-size slide

  37. How will you handle the unexpected?
    Weird input. Slow network connections. Emoji.

    View full-size slide


  38. Don Eyles
    When Hal Laning designed the
    Executive and Waitlist system, he
    made it up from whole cloth with
    no examples to guide him.
    The design [...] still represents the
    state of the art.

    View full-size slide

  39. All software has consequences
    We may not all be designing spacecraft, but we affect lives.

    View full-size slide

  40. doneyles.com/LM/Tales.html
    Tales from the Lunar Module Guidance Computer, 2004

    View full-size slide

  41. Thanks.
    Andrew Godwin
    @andrewgodwin // aeracode.org

    View full-size slide