What Time Is It? A Guide to Time for Software Developers George - - PowerPoint PPT Presentation

what time is it
SMART_READER_LITE
LIVE PREVIEW

What Time Is It? A Guide to Time for Software Developers George - - PowerPoint PPT Presentation

What Time Is It? A Guide to Time for Software Developers George Neville-Neil ACM Highlights Learning Center tools for professional development: http: / / learning.acm.org 1,400+ trusted technical books and videos by O Reilly, Morgan


slide-1
SLIDE 1

What Time Is It?

A Guide to Time for Software Developers

George Neville-Neil

slide-2
SLIDE 2
  • Learning Center tools for professional development: http: / / learning.acm.org
  • 1,400+ trusted technical books and videos by O’Reilly, Morgan Kaufm ann, etc.
  • Online training toward top vendor certifications (CEH, Cisco, CISSP, CompTIA, PMI, etc.)
  • Learning Webinars from thought leaders and top practitioner
  • ACM Tech Packs (annotated bibliographies compiled by subject experts
  • Podcast interviews with innovators and award winners
  • Popular publications:
  • Flagship Communications of the ACM ( CACM) magazine: http: / / cacm.acm.org/
  • ACM Queue magazine for practitioners: http: / / queue.acm.org/
  • ACM Digital Library, the world’s most comprehensive database of computing

literature: http: / / dl.acm.org.

  • International conferences that draw leading experts on a broad spectrum of

computing topics: http: / / www.acm.org/ conferences.

  • Prestigious awards, including the ACM A.M. Turing and Infosys:

http: / / awards.acm.org/

  • And much more…

http: / / www.acm .org.

ACM Highlights

slide-3
SLIDE 3

What Time Is It?

A Guide to Time for Software Developers

George Neville-Neil

slide-4
SLIDE 4

Time is an Illusion

  • Created by people for people
  • Provides ordering to the day
  • Necessary for basic, human, communication
slide-5
SLIDE 5

A Brief History of…

  • Seasons
  • Months
  • Days
  • Hours
  • Minutes
  • Seconds
slide-6
SLIDE 6

Finer grains

  • 1 second
  • 1,000 milliseconds
  • 1,000,000 microseconds
  • 1,000,000,000 nanoseconds
slide-7
SLIDE 7

How do I use time?

  • In my programs?
  • In deployed systems?
  • Time is pervasive
  • Most systems are distributed systems
slide-8
SLIDE 8

Programming with Time

  • Takes time to get time
  • gettimeofday(2)
  • Traditional
  • clock_gettime(2)
  • Finer grained controls
slide-9
SLIDE 9

What's wrong with computer time?

  • Cheap Crystals
  • Systems run hot and cold
  • Age of crystals
  • Workload effects
  • Harder than you (or your management) might

think

slide-10
SLIDE 10
slide-11
SLIDE 11

Technology always makes things better

slide-12
SLIDE 12

Can you see it?

slide-13
SLIDE 13

How bad is it?

  • Offset starts at 0,0
  • 23:00-01:00 (2 hours)
  • 15ms behind
  • Typical behavior
slide-14
SLIDE 14

Who cares about a little wander?

  • Debugging distributed systems
  • Reconciling on-line transactions
  • Robots and Automation
  • Power Grids
  • Cellular Networks
slide-15
SLIDE 15

When is a second not a second?

  • Syntonization is not synchronization
  • Frequency inputs to massage the clock
  • Pulse Per Second (1PPS)
  • Other frequencies available, at a cost
slide-16
SLIDE 16

What is your tolerance?

  • Financial Transactions
  • FINRA: 1 second (for now)
  • Robot Arm
  • Powerline
  • 1/50th or 1/60th of a second
  • Cellular Networks
slide-17
SLIDE 17

Solutions?

  • Better crystals
  • Not on commodity hardware
  • Add on cards
  • Expensive for large deployments
  • Ask a better clock
  • Current state of the art
slide-18
SLIDE 18

Ask a better clock

  • A clock with a better crystal exists
  • Clients synchronize to the better clock
  • Complications
slide-19
SLIDE 19

Basic Theory of Operation

  • Stratum
  • Time Transfer
  • Ask, “What time is it?”
  • Measure and correct for network propagation

time

  • Steer the local clock
slide-20
SLIDE 20

Network Time Protocol (NTP)

  • V3 RFC 1305 (1992)
  • V4 RFC 5905 (2010)
  • Internet Based Timekeeping
  • Client/server model
  • Default polling is once per 64 seconds
  • Can take hours to synchronize
slide-21
SLIDE 21

Some Definitions

  • Synchronization
  • My neighbor and I know it is 3pm
  • Syntonization
  • The duration of a second is one second
  • Network Jitter
  • Variance in network latency
  • Grand Master
  • The better clock
slide-22
SLIDE 22

Time in the Cloud

slide-23
SLIDE 23

What?!

  • Default NTP config
  • Polling 50 times per

day

  • +/- 5ms
slide-24
SLIDE 24

Precision Time Protocol (PTP)

  • IEEE-1588 v1 (2002) v2 (2008) v3 (???)
  • LAN Environment
  • Multicast
  • Better than 1usec accuracy with software only
  • Hardware Support Available
slide-25
SLIDE 25

PTP

slide-26
SLIDE 26

How did you do that?

  • Graph includes 24 hours
  • Hundreds of

measurements per hour

  • Median 300ns
  • +/- 30usec around 0
  • Client is pure software
  • Master is a Meinberg

M600

slide-27
SLIDE 27

PTP in Packets

GM Slave Slave Slave Slave

DELAY RESPONSE DELAY REQUEST SYNC FOLLOWUP

slide-28
SLIDE 28

Sources of jitter

  • Routers
  • Switches
  • Links
  • Electronic Noise
  • Software
slide-29
SLIDE 29

Where does the time go?

  • NIC Interrupts
  • Packet Buffering
  • OS Scheduling
  • Software Stack
slide-30
SLIDE 30

Where does the time go?

slide-31
SLIDE 31

For my next trick…

  • Every packet has a sequence number
  • All packets are multicast
  • All hosts see the packets “at the same time”

Alas…16 bit sequence number

slide-32
SLIDE 32

Inter Host Quality

  • For each SYNC record the system time
  • Post process files
  • Show the offset between hosts
  • Included in PTPd (Quality File)
slide-33
SLIDE 33

PTPd

  • BSD Licensed
  • Supports IEEE-1588v2
  • Interoperates with NTPd
  • http://ptpd.sf.net
slide-34
SLIDE 34

The Leap Second

  • Adjustment based on astronomical

measurement

  • Periodically adds a second to the clock
  • 23:59:60
  • Can occur at the end of any month
  • But usually June or December
slide-35
SLIDE 35

ACM: The Learning Continues…

  • Questions about this webcast? learning@acm.org
  • ACM Learning Webinars (on-demand archive):

http://learning.acm.org/webinar

  • ACM Learning Center: http://learning.acm.org
  • ACM Queue: http://queue.acm.org/