l41: lab 1 - i/o...profile profiling timers syscall system call entry/return vfs virtual...

21
L41: Lab 1 - I/O Dr Robert N. M. Watson and Dr Graeme Jenkinson 1 November 2016 Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 1 / 15

Upload: others

Post on 30-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

L41: Lab 1 - I/O

Dr Robert N. M. Watson and Dr Graeme Jenkinson

1 November 2016

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 1 / 15

Page 2: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

L41: Lab 1 - I/O

I Introduce the BeagleBone Black and DTraceI Introduce our Jupyter-based experimental environmentI Explore user-kernel interactions via syscalls and trapsI Learn a bit about POSIX I/OI Measure the probe effect

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 2 / 15

Page 3: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

The benchmark[guest@beaglebone ~/io]$ ./io-staticio-static -c|-r|-w [-Bdqsv] [-b blocksize] [-t totalsize] path

Modes (pick one):-c ’create mode’: create benchmark data file-r ’read mode’: read() benchmark-w ’write mode’: write() benchmark

Optional flags:-B Run in bare mode: no preparatory activities-d Set O_DIRECT flag to bypass buffer cache-q Just run the benchmark, don’t print stuff out-s Call fsync() on the file descriptor when complete-v Provide a verbose benchmark description-b blocksize Specify a block size (default: 16384)-t totalsize Specify total I/O size (default: 16777216)

I Simple, bespoke I/O benchmark: read() or write()I Statically or dynamically linkedI Adjust buffer sizes, etc.I Various output modes.

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 3 / 15

Page 4: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

The benchmark (2)

I Three operational modes:Create (-c) Create a new benchmark data file

Read (-r) Perform read()s against data fileWrite (-w) Perform write()s against data file

I Adjust I/O parameters:Block size (-b) Block size used for each I/OTotal size (-t) Total size across all I/OsDirect (-d) Use direct I/O (bypass buffer cache)Sync (-s) Perform fsycnc() after I/O loopBare (-B) Don’t synchronise cache (etc) on start

(whole-program testing)I Output flags:

Quiet (-q) Suppress all output (whole-program tracing)Verbose (-v) Verbose output (interactive testing)

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 4 / 15

Page 5: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

The benchmark (2)

I Three operational modes:Create (-c) Create a new benchmark data file

Read (-r) Perform read()s against data fileWrite (-w) Perform write()s against data file

I Adjust I/O parameters:Block size (-b) Block size used for each I/OTotal size (-t) Total size across all I/OsDirect (-d) Use direct I/O (bypass buffer cache)Sync (-s) Perform fsycnc() after I/O loopBare (-B) Don’t synchronise cache (etc) on start

(whole-program testing)

I Output flags:Quiet (-q) Suppress all output (whole-program tracing)

Verbose (-v) Verbose output (interactive testing)

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 4 / 15

Page 6: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

The benchmark (2)

I Three operational modes:Create (-c) Create a new benchmark data file

Read (-r) Perform read()s against data fileWrite (-w) Perform write()s against data file

I Adjust I/O parameters:Block size (-b) Block size used for each I/OTotal size (-t) Total size across all I/OsDirect (-d) Use direct I/O (bypass buffer cache)Sync (-s) Perform fsycnc() after I/O loopBare (-B) Don’t synchronise cache (etc) on start

(whole-program testing)I Output flags:

Quiet (-q) Suppress all output (whole-program tracing)Verbose (-v) Verbose output (interactive testing)

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 4 / 15

Page 7: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

The benchmark (3)

[guest@beaglebone ~/io]$ ./io-static -v -d -w /data/iofileBenchmark configuration:blocksize: 16384totalsize: 16777216blockcount: 1024operation: writepath: /data/iofiletime: 58.502746875

280.06 KBytes/sec

I Use verbose outputI Bypass the buffer cacheI Write to the previously created file /data/iofile

I Use default buffer size (16K) and total I/O size (16M)

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 5 / 15

Page 8: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

Exploratory questions

I Baseline benchmark performance analysis:I How do read() and write() performance compare?I What is the performance impact of the buffer cache?

Consider both -d and -s.I What proportion of time is spent in userspace vs. the kernel?I How many times are system calls invoked during the I/O loop?I What is the role of traps in execution of the I/O loop?I How does work performed in just the I/O loop compare with

whole-program behaviour?

I Probe effect and measurement decisionsI How does performance change if you insert system-call or trap

probes in the I/O loop?I What sources of variance may be affecting benchmark

performance, and how can we measure them?

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 6 / 15

Page 9: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

Exploratory questions

I Baseline benchmark performance analysis:I How do read() and write() performance compare?I What is the performance impact of the buffer cache?

Consider both -d and -s.I What proportion of time is spent in userspace vs. the kernel?I How many times are system calls invoked during the I/O loop?I What is the role of traps in execution of the I/O loop?I How does work performed in just the I/O loop compare with

whole-program behaviour?

I Probe effect and measurement decisionsI How does performance change if you insert system-call or trap

probes in the I/O loop?I What sources of variance may be affecting benchmark

performance, and how can we measure them?

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 6 / 15

Page 10: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

Experimental questions for the lab report

I With respect to a configuration reading from a fixed-size filethrough the buffer cache:

1. How does changing the I/O buffer size affect I/O-loop performance?2. How does static vs. dynamic linking affect whole-program

performance?3. At what file-size threshold does any performance difference

between static and dynamic linking fall below 5%? 1%?

I Run the benchmark to gather initial measurementsI Explore through system-call/trap tracing and profilingI Use various configurations (e.g., I/O on /dev/zero) to explore

kernel code-path behaviour

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 7 / 15

Page 11: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

Introduction

Experimental questions for the lab report

I With respect to a configuration reading from a fixed-size filethrough the buffer cache:

1. How does changing the I/O buffer size affect I/O-loop performance?2. How does static vs. dynamic linking affect whole-program

performance?3. At what file-size threshold does any performance difference

between static and dynamic linking fall below 5%? 1%?

I Run the benchmark to gather initial measurementsI Explore through system-call/trap tracing and profilingI Use various configurations (e.g., I/O on /dev/zero) to explore

kernel code-path behaviour

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 7 / 15

Page 12: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

DTrace scripts

I Human-facing C-like languageI One or more {probe name, predicate, action} tuplesI Expression limited to control side effects (e.g., no loops)I Specified on command line or via a .d file

fbt::malloc:entry /execname == "csh"/ { trace(arg0); }

probe name Identifies the probe(s) to instrument; wildcards allowed;identifies the provider and a provider-specific probe name

predicate Filters cases where action will executeaction Describes tracing operations

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 8 / 15

Page 13: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

DTrace scripts

I Human-facing C-like languageI One or more {probe name, predicate, action} tuplesI Expression limited to control side effects (e.g., no loops)I Specified on command line or via a .d file

fbt::malloc:entry /execname == "csh"/ { trace(arg0); }

probe name Identifies the probe(s) to instrument; wildcards allowed;identifies the provider and a provider-specific probe name

predicate Filters cases where action will executeaction Describes tracing operations

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 8 / 15

Page 14: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

Some kernel DTrace providers in FreeBSD

Provider Descriptioncallout_execute Timer-driven calloutsdtmalloc Kernel malloc()/free()dtrace DTrace script events (BEGIN, END)fbt Function Boundary Tracingio Block I/Oip, udp, tcp, sctp TCP/IPlockstat Lockingproc, sched Kernel process/schedulingprofile Profiling timerssyscall System call entry/returnvfs Virtual filesystem

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 9 / 15

Page 15: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

Aggregations

Aggregation Descriptioncount() Number of times calledsum() Sum of argumentsavg() Average of argumentsmin() Minimum of argumentsmax() Maximum of argumentsstddev() Standard deviation ofntslquantize() Linear frequency distribution (histogram)quantize() Log frequency distribution (histogram)

I Often we want summaries of events, not detailed tracesI DTrace allows early, efficient reduction using aggregationsI Scalable multicore implementations (i.e., commutative)I @variable = function()

I printa() to print

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 10 / 15

Page 16: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

Counting kernel read() system calls[guest@beaglebone ~/io]$ ./io-static -q -r /data/iofile

root@beaglebone:/data/io # dtrace -n’syscall::read:entry/execname=="io-static"/{@reads = count(); }’

Probe Trace the read system callPredicate Limit actions to processes executing io-static

Action Count the number of probe fires

dtrace: description ’syscall::read:entry ’ matched 1 probedtrace: buffer size lowered to 2mdtrace: aggregation size lowered to 2m^C

1024

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 11 / 15

Page 17: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

Counting kernel read() system calls[guest@beaglebone ~/io]$ ./io-static -q -r /data/iofile

root@beaglebone:/data/io # dtrace -n’syscall::read:entry/execname=="io-static"/{@reads = count(); }’

Probe Trace the read system callPredicate Limit actions to processes executing io-static

Action Count the number of probe fires

dtrace: description ’syscall::read:entry ’ matched 1 probedtrace: buffer size lowered to 2mdtrace: aggregation size lowered to 2m^C

1024

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 11 / 15

Page 18: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

Jupyter Notebooks

Unified environment for:

I Executing benchmarks.I Measuring the performance of these benchmarks with DTrace.I Post-processing performance measurements.I Plotting performance measurements.I Performing statistical analysis on performance measurements.

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 12 / 15

Page 19: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

Jupyter Notebook overview

I Series of cells containing Python or cell ”magics“.I Cell magics allow inline plotting of graphs or executing shell

commands.I Raw data and plots can be save to BBB for inclusion in lab reports.I Details of environment in lab1 handout.

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 13 / 15

Page 20: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

A few cautions

There a two kinds of people, those that have experienced data lossand those that haven’t experienced data loss YET.

I Copy key scripts and data files to/from your workstation.I The SD cards seem a bit fragile during poweroff – make sure you

shut down safely using the Lab Setup instruction.I We have spare imaged SD cards if you need them.I We may replace your SD cards for future labs.I The Jupyter Notebook environment is new this year - teething

troubles are expected!

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 14 / 15

Page 21: L41: Lab 1 - I/O...profile Profiling timers syscall System call entry/return vfs Virtual filesystem Dr Robert N. M. Watson and Dr Graeme JenkinsonL41: Lab 1 - I/O1 November 2016

DTrace

A few other useful things

I Work in pairs for the lab (reports must be written separately)I You will likely want multiple SSH sessions openI The kernel source code is in github/freebsd/freebsd.git

(branch release/11.0.0)I Start with something simple – e.g., DTrace hello world

I Do not hesitate to ask for help if you need a hand!

Dr Robert N. M. Watson and Dr Graeme Jenkinson L41: Lab 1 - I/O 1 November 2016 15 / 15