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 Slide

  2. Hi, I’m
    Andrew Godwin

    View Slide

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

    View Slide

  4. "The Real-Time Web"

    View Slide

  5. AJAX
    1999
    Comet
    2006
    WebSockets
    2011

    View Slide

  6. "Real-Time"

    View Slide

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

    View Slide

  8. View Slide

  9. View Slide

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

    View Slide

  11. Program 2
    Program 3
    Program 1

    View Slide

  12. Scheduling
    The art of running multiple things at once

    View Slide

  13. Program 2
    Program 3
    Program 1 300 cycles
    300 cycles
    300 cycles

    View Slide

  14. 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 Slide

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

    View Slide

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

    View Slide

  17. 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 Slide

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

    View Slide

  19. View Slide

  20. View Slide

  21. 72kb
    Woven core memory

    View Slide

  22. 0.085 Mhz
    processor

    View Slide


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

    View Slide

  24. View Slide

  25. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  30. View Slide

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

    View Slide

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

    View Slide

  33. 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 Slide

  34. 103%

    View Slide

  35. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide


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

    View Slide

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

    View Slide


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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide


  48. 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide