Why are computers so @#!*, and what can we do about it? Peter - - PowerPoint PPT Presentation

why are computers so and what can we do about it
SMART_READER_LITE
LIVE PREVIEW

Why are computers so @#!*, and what can we do about it? Peter - - PowerPoint PPT Presentation

Why are computers so @#!*, and what can we do about it? Peter Sewell University of Cambridge August 2014 EMF , somewhere near Bletchley p. 1 Things I Know About Computers p. 2 Things I Know About Computers 1. there are a lot of


slide-1
SLIDE 1

Why are computers so @#!*, and what can we do about it?

Peter Sewell University of Cambridge

August 2014 EMF , somewhere near Bletchley

– p. 1

slide-2
SLIDE 2

Things I Know About Computers

– p. 2

slide-3
SLIDE 3

Things I Know About Computers

  • 1. there are a lot of them

– p. 2

slide-4
SLIDE 4

Things I Know About Computers

  • 1. there are a lot of them
  • 2. they go wrong a lot

– p. 2

slide-5
SLIDE 5

[Ariane 501, $500 million]

– p. 3

slide-6
SLIDE 6

– p. 4

slide-7
SLIDE 7

– p. 5

slide-8
SLIDE 8

– p. 6

slide-9
SLIDE 9 Ba k in the 19 th Century...

– p. 7

slide-10
SLIDE 10 Beautiful Railway Bridge
  • f
the Silvery Tay! With your numerous ar hes and pillars in so grand array

– p. 8

slide-11
SLIDE 11

– p. 9

slide-12
SLIDE 12

– p. 10

slide-13
SLIDE 13

– p. 11

slide-14
SLIDE 14

Now

100 years later: decent mechanical and civil engineering

– p. 12

slide-15
SLIDE 15

Now

100 years later: decent mechanical and civil engineering What does that mean? enough thermodynamics, materials science, quality control,

  • etc. to model designs well enough to predict whether they’ll

do what we want

– p. 12

slide-16
SLIDE 16

Now

100 years later: decent mechanical and civil engineering What does that mean? enough thermodynamics, materials science, quality control,

  • etc. to model designs well enough to predict whether they’ll

do what we want And for Computing?

– p. 12

slide-17
SLIDE 17

Why is it so hard?

– p. 13

slide-18
SLIDE 18

Too Much Code

[from www.informationisbeautiful.net]

– p. 14

slide-19
SLIDE 19

– p. 15

slide-20
SLIDE 20

– p. 16

slide-21
SLIDE 21

But computer systems are built by smart people in big groups subject to commercial pressures using the best components and tools they know....

– p. 17

slide-22
SLIDE 22

– p. 18

slide-23
SLIDE 23

– p. 19

slide-24
SLIDE 24

How do we build those pieces?

  • 1. (sometimes, at best) specify in prose
  • 2. write code
  • 3. write some ad hoc tests
  • 4. test-and-fix-and-extend until marketable
  • 5. test-and-fix-and-extend until no longer marketable
  • 6. use until too bitrotted, device breaks, or obsolete

– p. 20

slide-25
SLIDE 25

How do we build those pieces?

  • 1. (sometimes, at best) specify in prose
  • 2. write code
  • 3. write some ad hoc tests
  • 4. test-and-fix-and-extend until marketable
  • 5. test-and-fix-and-extend until no longer marketable
  • 6. use until too bitrotted, device breaks, or obsolete

– p. 20

slide-26
SLIDE 26

Too Many...

Execution paths ... scales (at least!) exponentially with code size States ... scales exponentially with amount of data Possible inputs

– p. 21

slide-27
SLIDE 27

Discrete Systems

– p. 22

slide-28
SLIDE 28

What can we do?

– p. 23

slide-29
SLIDE 29

1: improve s/w engineering processes

more unit+system testing, more assertions, better coordination...

– p. 24

slide-30
SLIDE 30

2: use 1980s languages instead of 1970s

expressive type systems guarantees of type- and memory-safety enforcement of abstraction boundaries user-defined inductive types, pattern matching, functions, ... In 2014? No excuse...

– p. 25

slide-31
SLIDE 31

2b: use languages that have been designed

– p. 26

slide-32
SLIDE 32

2b: use languages that have been designed

(we can now precisely define the intended semantics of real-world PLs...)

– p. 26

slide-33
SLIDE 33

4: prove correctness

– p. 27

slide-34
SLIDE 34

4: prove correctness

CompCert verified compiler from C-like language to assembly CompCertTSO ...plus concurrency CakeML verified compiler from core ML to binary Vellvm verified LLVM optimisation passes RockSalt verified SFI seL4 verified hypervisor

– p. 27

slide-35
SLIDE 35

3: specify+test behaviour of key interfaces

– p. 28

slide-36
SLIDE 36

– p. 29

slide-37
SLIDE 37

3: specify+test behaviour of key interfaces

TCP and Sockets API x86, ARM, and IBM Power multiprocessor behaviour C/C++11 concurrency models (+ gcc/clang testing) OCaml core language C language TLS stack

– p. 30

slide-38
SLIDE 38

Multiprocessors

Processor 1 Processor N Shared Memory

– p. 31

slide-39
SLIDE 39

The GhoĆ of MultiproceĄorŊ PaĆ

BURROUGHS D825, 1962 “Outstanding features include truly modular hardware with parallel processing throughout” FUTURE PLANS The complement of compiling languages is to be expanded.

– p. 32

slide-40
SLIDE 40

Example 1 (SB)

Initial shared memory values: x=0 and y=0 Thread 0 Thread 1 write x := 1 write y := 1 read y read x Might expect x=1,y=1, x=1,y=0,

  • r

x=0,y=1.

– p. 33

slide-41
SLIDE 41

Example 1 (SB)

Initial shared memory values: x=0 and y=0 Thread 0 Thread 1 write x := 1 write y := 1 read y read x Might expect x=1,y=1, x=1,y=0,

  • r

x=0,y=1. Experimentally, on x86 (Intel Core i7): x=1, y=1 79 x=1, y=0 499683 x=0, y=1 499889 x=0, y=0 349

– p. 33

slide-42
SLIDE 42

Example 2 (MP , Message Passing)

Initial shared memory values: x=0 and y=0 Thread 0 Thread 1 write x := 1 read y // until gets 1 write y := 1 read x Might expect to always see x=1

– p. 34

slide-43
SLIDE 43

Example 2 (MP , Message Passing)

Initial shared memory values: x=0 and y=0 Thread 0 Thread 1 write x := 1 read y // until gets 1 write y := 1 read x Might expect to always see x=1 Experimentally: x86 x=1 ARM x=0 and x=1 IBM Power x=0 and x=1 Programmer must enforce ordering with memory barriers

– p. 34

slide-44
SLIDE 44

How are architectures expressed?

In prose:

For each applicable pair ai,bj the memory barrier ensures that ai will be performed with respect to any processor or mecha- nism, to the extent required by the associated Memory Coher- ence Required attributes, before bj is performed with respect to that processor or mechanism. A includes all applicable storage accesses by any such processor or mechanism that have been performed with respect to P1 before the memory barrier is created. B includes all applicable storage accesses by any such processor or mechanism that are performed after a Load instruction executed by that processor or mechanism has returned the value stored by a store that is in B.

– p. 35

slide-45
SLIDE 45

How are architectures expressed?

In prose:

For each applicable pair ai,bj the memory barrier ensures that ai will be performed with respect to any processor or mecha- nism, to the extent required by the associated Memory Coher- ence Required attributes, before bj is performed with respect to that processor or mechanism. A includes all applicable storage accesses by any such processor or mechanism that have been performed with respect to P1 before the memory barrier is created. B includes all applicable storage accesses by any such processor or mechanism that are performed after a Load instruction executed by that processor or mechanism has returned the value stored by a store that is in B. l

– p. 35

slide-46
SLIDE 46

How are architectures expressed?

“all that horrible horribly incomprehensible and confusing [...] text that no-one can parse or reason with — not even the people who wrote it” Anonymous Processor Architect, 2011

– p. 36

slide-47
SLIDE 47

Architectural Fiction

Architecture texts (and mainstream language standards too): informal prose attempts at subtle loose specifications. We pretend programmers can “write to the spec” — but we develop software by testing. Fundamental problem: prose specifications cannot be used to test programs against, or to test processor implementations, or to prove properties of either, or even to communicate precisely. In a real sense, the specs don’t exist

– p. 37

slide-48
SLIDE 48

Empirical Science to the Rescue!

– p. 38

slide-49
SLIDE 49

Empirical Science to the Rescue!

  • 1. invent mathematically precise model of multiprocessor

behaviour (but abstract, avoiding microarchitectural detail)

– p. 38

slide-50
SLIDE 50

Empirical Science to the Rescue!

  • 1. invent mathematically precise model of multiprocessor

behaviour (but abstract, avoiding microarchitectural detail)

  • 2. make tool to find all model-allowed behaviour of tests

(and interactive web interface)

– p. 38

slide-51
SLIDE 51

Empirical Science to the Rescue!

  • 1. invent mathematically precise model of multiprocessor

behaviour (but abstract, avoiding microarchitectural detail)

  • 2. make tool to find all model-allowed behaviour of tests

(and interactive web interface)

  • 3. compare against experimental data from production h/w

(fixing model and finding h/w bugs)

– p. 38

slide-52
SLIDE 52

Empirical Science to the Rescue!

  • 1. invent mathematically precise model of multiprocessor

behaviour (but abstract, avoiding microarchitectural detail)

  • 2. make tool to find all model-allowed behaviour of tests

(and interactive web interface)

  • 3. compare against experimental data from production h/w

(fixing model and finding h/w bugs)

  • 4. discuss with architects

– p. 38

slide-53
SLIDE 53

Empirical Science to the Rescue!

  • 1. invent mathematically precise model of multiprocessor

behaviour (but abstract, avoiding microarchitectural detail)

  • 2. make tool to find all model-allowed behaviour of tests

(and interactive web interface)

  • 3. compare against experimental data from production h/w

(fixing model and finding h/w bugs)

  • 4. discuss with architects
  • 5. prove correctness of C/C++11 concurrency compilation

scheme

– p. 38

slide-54
SLIDE 54

Empirical Science to the Rescue!

  • 1. invent mathematically precise model of multiprocessor

behaviour (but abstract, avoiding microarchitectural detail)

  • 2. make tool to find all model-allowed behaviour of tests

(and interactive web interface)

  • 3. compare against experimental data from production h/w

(fixing model and finding h/w bugs)

  • 4. discuss with architects
  • 5. prove correctness of C/C++11 concurrency compilation

scheme

  • 6. goto 1

– p. 38

slide-55
SLIDE 55

Rocket Science?

– p. 39

slide-56
SLIDE 56

Rocket Science?

specifying the intended behaviour of a system in some precise and clear language

– p. 39

slide-57
SLIDE 57

Rocket Science?

specifying the intended behaviour of a system in some precise and clear language in a form that is executable as a test oracle to decide whether some experimentally observed behaviour is allowed by the model

– p. 39

slide-58
SLIDE 58

Rocket Science?

specifying the intended behaviour of a system in some precise and clear language in a form that is executable as a test oracle to decide whether some experimentally observed behaviour is allowed by the model Key Question: any nondeterminism or loose specification?

– p. 39

slide-59
SLIDE 59

Not appropriate for everything — but for key infrastructure, yes!

– p. 40

slide-60
SLIDE 60

Conclusion

Reasons why building robust systems is hard Things we can do about it: use better PL tools specify for test work towards full verification

– p. 41

slide-61
SLIDE 61

Conclusion

Reasons why building robust systems is hard Things we can do about it: use better PL tools specify for test work towards full verification Cautious optimism?

– p. 41

slide-62
SLIDE 62

Conclusion

Reasons why building robust systems is hard Things we can do about it: use better PL tools specify for test work towards full verification Cautious optimism?

  • r we’re doomed!

– p. 41

slide-63
SLIDE 63 The End

– p. 42