LET ME SLEEP ON IT. Improving concurrency in unexpected ways. Nir Soffer PyCon Israel 2017

Size: px
Start display at page:

Download "LET ME SLEEP ON IT. Improving concurrency in unexpected ways. Nir Soffer PyCon Israel 2017"

Transcription

1 LET ME SLEEP ON IT Improving concurrency in unexpected ways Nir Soffer PyCon Israel 2017

2 $ whoami Taming the Vdsm beast since 2013 Tinkering with Python since 2003 Free software enthusiast Father of two

3 PYTHON THREADS SUCK

4 THE GIL The global interpretor lock will let only one thread run Python code at a time

5 WHAT'S GOING ON HERE? Py_BEGIN_ALLOW_THREADS n = read(fd, buf, count); Py_END_ALLOW_THREADS Python releases the GIL when possible

6 PYTHON THREADS ARE USEFUL You can do I/O or wait for other programs concurrently

7 SEQUENTIAL CODE IS EASY When using threads, you can write simple and clear code, as if you are the only one running

8 VDSM USES LOT OF THREADS

9 WHAT IS VDSM? Vdsm manages virtual machines on a hypervisor

10 VIRTUAL MACHINES NEED STORAGE Vdsm provides storage for virtual machines Typically shared storage

11 SHARED STORAGE IS EXTREMELY FAST Seen 750MiB/s writes using direct I/O to SSD disk array

12 SHARED STORAGE IS HORRIBLY SLOW $ ps -p o stat -o cmd STAT CMD D+ dd if=/dev/zero of=mnt/test bs=8m count=1280 oflag=direct

13 VDSM MONITORS STORAGE Every storage domain has a dedicated thread We can have 50 storage domains

14 MONITOR THREADS ARE ISOLATED If one thread gets stuck on unresponsive storage, other threads are not affected

15 VDSM USES LVM Vdsm manages block storage using LVM Creates logical volumes for VM disks and snapshots

16 ACCESSING LVM METADATA IS SLOW Vdsm caches LVM metadata

17 There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton

18 MONITOR THREADS REFRESH LVM CACHE Monitor threads invalidate the cache and run LVM commands to reload the cache

19 OPERATION MUTEX

20 LVM CACHE class LVMCache(object):... def _invalidate_lvs(self, vg_name, lv_names): with self._opmutex.locked(lvm_op_invalidate): for lv_name in lv_names: self._lvs[(vg_name, lv_name)] = Stub(lv_name) def _reload_lvs(self, vg_name, lv_names): with self._opmutex.locked(lvm_op_reload): lvm_output = self._run_lvs(vg_name, lv_names) for lv in self._parse_lvs(lvm_output): self._lvs[(vg_name, lv_name)] = lv (Simpli ed)

21 LVM CACHE USES FANCY LOCKING Multiple threads can invalidate the cache at the same time Multiple threads can reload the cache at the same time Invalidate and reload cannot run at the same time

22 HOW OPERATION MUTEX WORKS 1. Thread-1 acquires the mutex for an invalidate operation 2. Thread-2 tries to acquire the mutex for a reload operation, waiting Thread-3 enters the mutex for an invalidate operation 4. Thread-1 exits the mutex 5. Thread-3 exits and release the mutex 6. Thread-2 wakes up and acquires the mutex for a reload operation

23 OPERATION MUTEX [1/3] class OperationMutex(object): def init (self): self._cond = threading.condition(threading.lock()) self._operation = None self._holders = def locked(self, operation): self._acquire(operation) try: yield self finally: self._release()

24 OPERATION MUTEX [2/3] def _acquire(self, operation): with self._cond: while self._operation not in (operation, None): self._cond.wait() if self._operation is None: self._operation = operation self._holders += 1 (Logging removed)

25 OPERATION MUTEX [3/3] def _release(self): with self._cond: self._holders -= 1 if self._holders == 0: self._operation = None self._cond.notify_all() (Logging removed)

26 OPERATION MUTEX IN PRACTICE (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_reload_vgs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_reload_vgs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_reload_vgs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (_invalidate_lvs) 'lvm reload' is holding the mutex, waiting... (Simpli ed, colored)

27 WE HAVE A PROBLEM Too many threads waiting... Most of the time only one thread is inside the operation mutex

28 OPERATION MUTEX IS HARMFUL Lots of storage domains... Storage is overloaded... LVM commands become slow... Monitor threads waiting... Monitoring timeouts... Hypervisor goes down

29 IMPROVING CONCURRENCY

30 HOW ARE OPERATION MUTEX TESTS PASSING? There are no Operation Mutex tests

31 Code without tests is broken. -- Nir Soffer

32 ADDING TESTS Let's start with the easy case, allowing multiple threads to perform the same operation

33 TESTING SAME OPERATION def test_same_operation(): m = opmutex.operationmutex() def worker(n): with m.locked("operation"): time.sleep(1.0) elapsed = run_threads(worker, 50) assert elapsed < 2.0

34 WE NEED SOME HELP def run_threads(func, count): threads = [] start = time.time() try: for i in range(count): t = threading.thread(target=func, args=(i,), name="worker-%02d" % i) t.daemon = True t.start() threads.append(t) finally: for t in threads: t.join() return time.time() - start

35 TEST PASSES! opmutex_test.py::test_same_operation PASSED

36 REFRESH LVM CACHE FLOW 1. Invalidate cache 2. Reload cache

37 TIME MATTERS 1. Invalidate updates a dict - microseconds 2. Reload goes to storage - seconds

38 TESTING REFRESH FLOW def test_refresh_flow(run): count = 50 m = opmutex.operationmutex() cache = ["old"] * count def worker(n): with m.locked("invalidate"): cache[n] = "invalid" with m.locked("reload"): time.sleep(1.0) cache[n] = "new" elapsed = run_threads(worker, count) assert elapsed < 2.0 assert cache == ["new"] * count

39 TEST FAILS RANDOMLY Testing threading issues is tricky How can we make it fail consistently?

40 MAKING IT range(10)) def test_refresh_flow(run): count = 50 m = opmutex.operationmutex() cache = ["old"] * count def worker(n): with m.locked("invalidate"): cache[n] = "invalid" with m.locked("reload"): time.sleep(1.0) cache[n] = "new" elapsed = run_threads(worker, count) assert elapsed < 2.0

41 FAILING TESTS ARE GOOD opmutex_test.py::test_same_operation PASSED opmutex_test.py::test_refresh_flow[0] FAILED opmutex_test.py::test_refresh_flow[1] PASSED opmutex_test.py::test_refresh_flow[2] PASSED opmutex_test.py::test_refresh_flow[3] PASSED opmutex_test.py::test_refresh_flow[4] PASSED opmutex_test.py::test_refresh_flow[5] FAILED opmutex_test.py::test_refresh_flow[6] PASSED opmutex_test.py::test_refresh_flow[7] FAILED opmutex_test.py::test_refresh_flow[8] PASSED opmutex_test.py::test_refresh_flow[9] FAILED

42 TEST FAILURE LOG worker-00: Operation 'invalidate' acquired the mutex worker-00: Operation 'invalidate' released the mutex worker-00: Operation 'reload' acquired the mutex worker-01: Operation 'reload' is holding the mutex, waiting... worker-02: Operation 'reload' is holding the mutex, waiting... worker-03: Operation 'reload' is holding the mutex, waiting... worker-04: Operation 'reload' is holding the mutex, waiting... worker-05: Operation 'reload' is holding the mutex, waiting... worker-06: Operation 'reload' is holding the mutex, waiting... worker-07: Operation 'reload' is holding the mutex, waiting... worker-08: Operation 'reload' is holding the mutex, waiting... worker-09: Operation 'reload' is holding the mutex, waiting... worker-10: Operation 'reload' is holding the mutex, waiting...

43 WHY DOES IT FAIL? 1. worker-00 acquires the GIL 2. worker-00 acquires the operation mutex for an invalidate operation 3. Other workers could enter the operation mutex, but worker- 00 is holding the GIL worker-00 releases the operation mutex 5. worker-00 acquires the operation mutex again for a reload operation 6. worker-00 releases the GIL during sleep 7. Other workers cannot enter the operation mutex, waiting...

44 HOW SHOULD IT WORK 1. All workers enter the operation mutex for an invalidate operation 2. All workers exit the operation mutex 3. All workers enter the operation mutex for a reload operation 4. All workers exit the operation mutex

45 CAN WE FIX IT? Need to sleep on it...

46 THREADS ARE NOT POLITE When you enter a building, you hold the door so the next person can enter

47 HOW CAN WE MAKE THREADS POLITE? When entering the operation mutex, take a little nap, letting other threads in

48 TAKE A LITTLE def locked(self, operation): self._acquire(operation) try: # Give other threads chance to get in. time.sleep(0.01) yield self finally: self._release()

49 GREEN AGAIN! opmutex_test.py::test_same_operation PASSED opmutex_test.py::test_refresh_flow[0] PASSED opmutex_test.py::test_refresh_flow[1] PASSED opmutex_test.py::test_refresh_flow[2] PASSED opmutex_test.py::test_refresh_flow[3] PASSED opmutex_test.py::test_refresh_flow[4] PASSED opmutex_test.py::test_refresh_flow[5] PASSED opmutex_test.py::test_refresh_flow[6] PASSED opmutex_test.py::test_refresh_flow[7] PASSED opmutex_test.py::test_refresh_flow[8] PASSED opmutex_test.py::test_refresh_flow[9] PASSED

50 FIXED TEST LOG worker-00: Operation 'invalidate' acquired the mutex worker-01: Operation 'invalidate' entered the mutex worker-02: Operation 'invalidate' entered the mutex worker-03: Operation 'invalidate' entered the mutex worker-04: Operation 'invalidate' entered the mutex worker-05: Operation 'invalidate' entered the mutex worker-06: Operation 'invalidate' entered the mutex worker-00: Operation 'invalidate' exited the mutex worker-07: Operation 'invalidate' entered the mutex worker-01: Operation 'invalidate' exited the mutex worker-00: Operation 'invalidate' is holding the mutex, waiting... worker-02: Operation 'invalidate' exited the mutex...

51 FIX AVAILABLE IN OVIRT-3.6

52 ARE WE DONE?

53 WHY DO WE NEED THE OPERATION MUTEX? Need to sleep on it little bit more...

54 WE DON'T No need to separate invalidate and reload operations Multiple threads modifying the cache is not thread safe The real problem is monitor thread isolation Monitor threads should not refresh LVM cache

55 OPERATION MUTEX WAS REMOVED IN OVIRT-4.0 More on this in my PyCon Israel 2018 talk?

56 The Best Code is No Code At All. --

57 MORE INFO Fork this talk on github ovirt - open your virtual datacenter We are hiring

58 THANK YOU! Questions?

Threading the Code. Self-Review Questions. Self-review 11.1 What is a thread and what is a process? What is the difference between the two?

Threading the Code. Self-Review Questions. Self-review 11.1 What is a thread and what is a process? What is the difference between the two? Threading the Code 11 Self-Review Questions Self-review 11.1 What is a thread and what is a process? What is the difference between the two? Self-review 11.2 What does the scheduler in an operating system

More information

Fasteners Documentation

Fasteners Documentation Fasteners Documentation Release 0.14.1 Joshua Harlow Jul 12, 2017 Contents 1 Lock 3 1.1 Classes.................................................. 3 1.2 Decorators................................................

More information

Administrivia. HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday.

Administrivia. HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday. Administrivia HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday. Keep posting discussion on Piazza Python Multiprocessing Topics today: Multiprocessing

More information

Sherlock Documentation

Sherlock Documentation Sherlock Documentation Release 0.3.0 Vaidik Kapoor May 05, 2015 Contents 1 Overview 3 1.1 Features.................................................. 3 1.2 Supported Backends and Client Libraries................................

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs CSE 451: Operating Systems Winter 2005 Lecture 7 Synchronization Steve Gribble Synchronization Threads cooperate in multithreaded programs to share resources, access shared data structures e.g., threads

More information

Embracing the Global Interpreter Lock (GIL)

Embracing the Global Interpreter Lock (GIL) Embracing the Global Interpreter Lock (GIL) David Beazley http://www.dabeaz.com October 6, 2011 PyCodeConf 2011, Miami 1 Let's Love the GIL! After blowing up the GIL at PyCon'2010, I thought it needed

More information

CPython cannot into threads

CPython cannot into threads GIL CPython cannot into threads 1992 PyPy Jython CPython IronPython Brython PyPy Jython CPython IronPython Brython PyPy Jython CPython IronPython Brython CPython cannot into threads CPython cannot into

More information

Lecture 8. Introduction to Python! Lecture 8

Lecture 8. Introduction to Python! Lecture 8 Lecture 8 Introduction to Python Lecture 8 Summary Python exceptions Processes and Threads Programming with Threads Python Exceptions In Python, there are two distinguishable kinds of errors: syntax errors

More information

Parallelism in Python

Parallelism in Python Multithreading or Multiprocessing? Mathematics Department Mercyhurst University May 5, 2017 Table of Contents 1 Parallel Computing 2 3 Understanding Parallelism in Programming Before we go into Python

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization Hank Levy Levy@cs.washington.edu 412 Sieg Hall Synchronization Threads cooperate in multithreaded programs to share resources, access shared

More information

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 Learning from Bad Examples CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 1 Goals Demonstrate techniques to design for shared mutability Build on an example where multiple threads

More information

Before we can talk about concurrency, we need to first understand what happens under the hood when the interpreter executes a Python statement.

Before we can talk about concurrency, we need to first understand what happens under the hood when the interpreter executes a Python statement. CS61A Notes Week 14 Concurrency Notes adapted from Justin Chen, Chung Wu, and George Wang On your computer, you often have multiple programs running at the same time. You might have your internet browser

More information

Introducing Shared-Memory Concurrency

Introducing Shared-Memory Concurrency Race Conditions and Atomic Blocks November 19, 2007 Why use concurrency? Communicating between threads Concurrency in Java/C Concurrency Computation where multiple things happen at the same time is inherently

More information

Implementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430

Implementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430 Implementing Mutual Exclusion Sarah Diesburg Operating Systems CS 3430 From the Previous Lecture The too much milk example shows that writing concurrent programs directly with load and store instructions

More information

Some examples of where it is useful to implement threads, even on single-core computers, are:

Some examples of where it is useful to implement threads, even on single-core computers, are: Chapter 7 Threading 7.1 Threading Threads are the smallest program units that an operating system can execute. Programming with threads allows that several lightweight processes can run simultaneously

More information

Python Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY

Python Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY Python Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY PyCon Korea 2017 Kim Sol kstreee@gmail.com Python Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY Kim Sol

More information

PROJECT 6: PINTOS FILE SYSTEM. CS124 Operating Systems Winter , Lecture 25

PROJECT 6: PINTOS FILE SYSTEM. CS124 Operating Systems Winter , Lecture 25 PROJECT 6: PINTOS FILE SYSTEM CS124 Operating Systems Winter 2015-2016, Lecture 25 2 Project 6: Pintos File System Last project is to improve the Pintos file system Note: Please ask before using late tokens

More information

6.033 Spring 2004, Quiz 1 Page 1 of Computer Systems Engineering: Spring Quiz I

6.033 Spring 2004, Quiz 1 Page 1 of Computer Systems Engineering: Spring Quiz I 6.033 Spring 2004, Quiz 1 Page 1 of 10 Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.033 Computer Systems Engineering: Spring 2004 Quiz I 1.0 Cumulative

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Profiling and Parallel Computing Harry Smith University of Pennsylvania November 29, 2017 Harry Smith (University of Pennsylvania) CIS 192 November 29, 2017 1 / 19 Outline 1 Performance

More information

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons) ) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons) Goal A Distributed Transaction We want a transaction that involves multiple nodes Review of transactions and their properties

More information

Lab 4 : Caching Locks. Introduction. Getting Started

Lab 4 : Caching Locks. Introduction. Getting Started Lab 4 : Caching Locks Introduction In this lab you will build a lock server and client that cache locks at the client, reducing the load on the server and improving client performance. For example, suppose

More information

CPS 310 second midterm exam, 11/14/2014

CPS 310 second midterm exam, 11/14/2014 CPS 310 second midterm exam, 11/14/2014 Your name please: Part 1. Sticking points Consider the Java code snippet below. Is it a legal use of Java synchronization? What happens if two threads A and B call

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 2019 Lecture 4: Processes Administrivia If you have not already, please make sure to enroll in piazza ~20 students have not yet Lab 1: please check the hints

More information

10/17/2011. Cooperating Processes. Synchronization 1. Example: Producer Consumer (3) Example

10/17/2011. Cooperating Processes. Synchronization 1. Example: Producer Consumer (3) Example Cooperating Processes Synchronization 1 Chapter 6.1 4 processes share something (devices such as terminal, keyboard, mouse, etc., or data structures) and can affect each other non deterministic Not exactly

More information

SUPER CLOUD STORAGE MEASUREMENT STUDY AND OPTIMIZATION

SUPER CLOUD STORAGE MEASUREMENT STUDY AND OPTIMIZATION CS5413: HIGH PERFORMANCE SYSTEMS AND NETWORKING SUPER CLOUD STORAGE MEASUREMENT STUDY AND OPTIMIZATION December 23, 2014 Sneha Prasad (sh824@cornell.edu) Lu Yang (ly77@cornell.edu) Contents 1 Introduction....................................

More information

Multithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science

Multithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science Multithreaded Programming Part II CSE 219 Stony Brook University, Thread Scheduling In a Java application, main is a thread on its own Once multiple threads are made Runnable the thread scheduler of the

More information

COMP 3361: Operating Systems 1 Final Exam Winter 2009

COMP 3361: Operating Systems 1 Final Exam Winter 2009 COMP 3361: Operating Systems 1 Final Exam Winter 2009 Name: Instructions This is an open book exam. The exam is worth 100 points, and each question indicates how many points it is worth. Read the exam

More information

Huge Codebases Application Monitoring with Hystrix

Huge Codebases Application Monitoring with Hystrix Huge Codebases Application Monitoring with Hystrix 30 Jan. 2016 Roman Mohr Red Hat FOSDEM 2016 1 About Me Roman Mohr Software Engineer at Red Hat Member of the SLA team in ovirt Mail: rmohr@redhat.com

More information

CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON. Created by Moritz Wundke

CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON. Created by Moritz Wundke CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON Created by Moritz Wundke INTRODUCTION Concurrent aims to be a different type of task distribution system compared to what MPI like system do. It adds a simple

More information

Asynchronous Programming Under the Hood. Week 6

Asynchronous Programming Under the Hood. Week 6 Asynchronous Programming Under the Hood Week 6 How to Implement Event Dispatchers Recall: Record registered callbacks in a data structure (easy) Wait for an event to happen (easy) Call the callbacks when

More information

Virtual Machine Design

Virtual Machine Design Virtual Machine Design Lecture 4: Multithreading and Synchronization Antero Taivalsaari September 2003 Session #2026: J2MEPlatform, Connected Limited Device Configuration (CLDC) Lecture Goals Give an overview

More information

How to hold onto things in a multiprocessor world

How to hold onto things in a multiprocessor world How to hold onto things in a multiprocessor world Taylor Riastradh Campbell campbell@mumble.net riastradh@netbsd.org AsiaBSDcon 2017 Tokyo, Japan March 12, 2017 Slides n code Full of code! Please browse

More information

EECS 482 Introduction to Operating Systems

EECS 482 Introduction to Operating Systems EECS 482 Introduction to Operating Systems Winter 2018 Harsha V. Madhyastha Monitors vs. Semaphores Monitors: Custom user-defined conditions Developer must control access to variables Semaphores: Access

More information

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons) ) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons) Goal A Distributed Transaction We want a transaction that involves multiple nodes Review of transactions and their properties

More information

CPS 310 first midterm exam, 10/6/2014

CPS 310 first midterm exam, 10/6/2014 CPS 310 first midterm exam, 10/6/2014 Your name please: Part 1. More fun with fork and exec* What is the output generated by this program? Please assume that each executed print statement completes, e.g.,

More information

Universidad Carlos III de Madrid Computer Science and Engineering Department Operating Systems Course

Universidad Carlos III de Madrid Computer Science and Engineering Department Operating Systems Course Exercise 1 (20 points). Autotest. Answer the quiz questions in the following table. Write the correct answer with its corresponding letter. For each 3 wrong answer, one correct answer will be subtracted

More information

CS 10: Problem solving via Object Oriented Programming Winter 2017

CS 10: Problem solving via Object Oriented Programming Winter 2017 CS 10: Problem solving via Object Oriented Programming Winter 2017 Tim Pierson 260 (255) Sudikoff SynchronizaGon Agenda 1. Threads and interleaving execugon 2. Producer/consumer 3. Deadlock, starvagon

More information

! Design constraints. " Component failures are the norm. " Files are huge by traditional standards. ! POSIX-like

! Design constraints.  Component failures are the norm.  Files are huge by traditional standards. ! POSIX-like Cloud background Google File System! Warehouse scale systems " 10K-100K nodes " 50MW (1 MW = 1,000 houses) " Power efficient! Located near cheap power! Passive cooling! Power Usage Effectiveness = Total

More information

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons) ) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons) Transactions - Definition A transaction is a sequence of data operations with the following properties: * A Atomic All

More information

Ovirt Storage Overview

Ovirt Storage Overview Ovirt Storage Overview Jun 8 th, 2012 Barak Azulay 1 Agenda Defining the problem Storage Domain Storage Pool Roadmap How to contribute Q&A Example Domain Classes Domain Types File Domains Block Domains

More information

Scheduling. CS 161: Lecture 4 2/9/17

Scheduling. CS 161: Lecture 4 2/9/17 Scheduling CS 161: Lecture 4 2/9/17 Where does the first process come from? The Linux Boot Process Machine turned on; BIOS runs BIOS: Basic Input/Output System Stored in flash memory on motherboard Determines

More information

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4 Temporal relations CSE 451: Operating Systems Autumn 2010 Module 7 Synchronization Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions executed

More information

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some

More information

PROCESS SYNCHRONIZATION

PROCESS SYNCHRONIZATION PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization

More information

Systèmes d Exploitation Avancés

Systèmes d Exploitation Avancés Systèmes d Exploitation Avancés Instructor: Pablo Oliveira ISTY Instructor: Pablo Oliveira (ISTY) Systèmes d Exploitation Avancés 1 / 32 Review : Thread package API tid thread create (void (*fn) (void

More information

Processes and Threads. Industrial Programming. Processes and Threads (cont'd) Processes and Threads (cont'd)

Processes and Threads. Industrial Programming. Processes and Threads (cont'd) Processes and Threads (cont'd) Processes and Threads Industrial Programming Lecture 5: C# Threading Introduction, Accessing Shared Resources Based on: An Introduction to programming with C# Threads By Andrew Birrell, Microsoft, 2005

More information

Microkernels. Overview. Required reading: Improving IPC by kernel design

Microkernels. Overview. Required reading: Improving IPC by kernel design Microkernels Required reading: Improving IPC by kernel design Overview This lecture looks at the microkernel organization. In a microkernel, services that a monolithic kernel implements in the kernel are

More information

Info 408 Distributed Applications Programming Exercise sheet nb. 4

Info 408 Distributed Applications Programming Exercise sheet nb. 4 Lebanese University Info 408 Faculty of Science 2017-2018 Section I 1 Custom Connections Info 408 Distributed Applications Programming Exercise sheet nb. 4 When accessing a server represented by an RMI

More information

Processes and Threads

Processes and Threads COS 318: Operating Systems Processes and Threads Kai Li and Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall13/cos318 Today s Topics u Concurrency

More information

Object Oriented Programming. Week 10 Part 1 Threads

Object Oriented Programming. Week 10 Part 1 Threads Object Oriented Programming Week 10 Part 1 Threads Lecture Concurrency, Multitasking, Process and Threads Thread Priority and State Java Multithreading Extending the Thread Class Defining a Class that

More information

Operating Systems (234123) Spring (Homework 3 Wet) Homework 3 Wet

Operating Systems (234123) Spring (Homework 3 Wet) Homework 3 Wet Due date: Monday, 4/06/2012 12:30 noon Teaching assistants in charge: Operating Systems (234123) Spring-2012 Homework 3 Wet Anastasia Braginsky All emails regarding this assignment should be sent only

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Graphical User Interfaces Robert Rand University of Pennsylvania December 03, 2015 Robert Rand (University of Pennsylvania) CIS 192 December 03, 2015 1 / 21 Outline 1 Performance

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

CIS Operating Systems Memory Management Cache and Demand Paging. Professor Qiang Zeng Spring 2018

CIS Operating Systems Memory Management Cache and Demand Paging. Professor Qiang Zeng Spring 2018 CIS 3207 - Operating Systems Memory Management Cache and Demand Paging Professor Qiang Zeng Spring 2018 Process switch Upon process switch what is updated in order to assist address translation? Contiguous

More information

CSC 261/461 Database Systems Lecture 24

CSC 261/461 Database Systems Lecture 24 CSC 261/461 Database Systems Lecture 24 Fall 2017 TRANSACTIONS Announcement Poster: You should have sent us the poster by yesterday. If you have not done so, please send us asap. Make sure to send it for

More information

cotyledon Documentation

cotyledon Documentation cotyledon Documentation Release Mehdi Abaakouk Feb 07, 2018 Contents 1 Contents: 1 1.1 Installation................................................ 1 1.2 API....................................................

More information

Experience with Processes and Monitors in Mesa. Arvind Krishnamurthy

Experience with Processes and Monitors in Mesa. Arvind Krishnamurthy Experience with Processes and Monitors in Mesa Arvind Krishnamurthy Background Focus of this paper: light-weight processes (threads) and how they synchronize with each other History: Second system; followed

More information

Lecture 8: September 30

Lecture 8: September 30 CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate

More information

Systems Programming & Scripting

Systems Programming & Scripting Systems Programming & Scripting Lecture 10: C# Threading Introduction, Accessing Shared Resources Based on: An Introduction to programming with C# Threads By Andrew Birrell, Microsoft, 2005 Examples from

More information

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 13 Robert Grimm, New York University 1 Review Last week Exceptions 2 Outline Concurrency Discussion of Final Sources for today s lecture: PLP, 12

More information

Concurrent Counting using Combining Tree

Concurrent Counting using Combining Tree Final Project Report by Shang Wang, Taolun Chai and Xiaoming Jia Concurrent Counting using Combining Tree 1. Introduction Counting is one of the very basic and natural activities that computers do. However,

More information

CIS Operating Systems Memory Management Cache. Professor Qiang Zeng Fall 2017

CIS Operating Systems Memory Management Cache. Professor Qiang Zeng Fall 2017 CIS 5512 - Operating Systems Memory Management Cache Professor Qiang Zeng Fall 2017 Previous class What is logical address? Who use it? Describes a location in the logical memory address space Compiler

More information

Concurrency, Parallelism, Events, Asynchronicity, Oh My

Concurrency, Parallelism, Events, Asynchronicity, Oh My Concurrency, Parallelism, Events, Asynchronicity, Oh My threads, processes, queues & workers, multiprocessing, gevent, twisted, yo momma Tommi Virtanen / @tv / DreamHost SoCal Piggies 2011-11-10 One thing

More information

10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4

10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4 What s in a process? CSE 451: Operating Systems Autumn 2010 Module 5 Threads Ed Lazowska lazowska@cs.washington.edu Allen Center 570 A process consists of (at least): An, containing the code (instructions)

More information

CSE : Python Programming. Packages (Tutorial, Section 6.4) Announcements. Today. Packages: Concretely. Packages: Overview

CSE : Python Programming. Packages (Tutorial, Section 6.4) Announcements. Today. Packages: Concretely. Packages: Overview Announcements CSE 399-004: Python Programming Lecture 07: Packages, Command-line arguments, and Unit testing February 26, 2007 http://www.seas.upenn.edu/~cse39904/ No homework this week There may be one

More information

CS 162 Midterm Exam. October 18, This is a closed book examination. You have 60 minutes to answer as many questions

CS 162 Midterm Exam. October 18, This is a closed book examination. You have 60 minutes to answer as many questions CS 162 Midterm Exam October 18, 1993 Your Name: Lecture (A.M. or P.M.): General Information: This is a closed book examination. You have 60 minutes to answer as many questions as possible. The number in

More information

CMSC 132: Object-Oriented Programming II. Threads in Java

CMSC 132: Object-Oriented Programming II. Threads in Java CMSC 132: Object-Oriented Programming II Threads in Java 1 Problem Multiple tasks for computer Draw & display images on screen Check keyboard & mouse input Send & receive data on network Read & write files

More information

What are Transactions? Transaction Management: Introduction (Chap. 16) Major Example: the web app. Concurrent Execution. Web app in execution (CS636)

What are Transactions? Transaction Management: Introduction (Chap. 16) Major Example: the web app. Concurrent Execution. Web app in execution (CS636) What are Transactions? Transaction Management: Introduction (Chap. 16) CS634 Class 14, Mar. 23, 2016 So far, we looked at individual queries; in practice, a task consists of a sequence of actions E.g.,

More information

EECS 482 Introduction to Operating Systems

EECS 482 Introduction to Operating Systems EECS 482 Introduction to Operating Systems Winter 2018 Harsha V. Madhyastha Multiple updates and reliability Data must survive crashes and power outages Assume: update of one block atomic and durable Challenge:

More information

CS11 Java. Fall Lecture 7

CS11 Java. Fall Lecture 7 CS11 Java Fall 2006-2007 Lecture 7 Today s Topics All about Java Threads Some Lab 7 tips Java Threading Recap A program can use multiple threads to do several things at once A thread can have local (non-shared)

More information

Section 5: Thread Synchronization

Section 5: Thread Synchronization CS162 February 16, 2018 Contents 1 Warmup 2 1.1 Thread safety........................................... 2 2 Vocabulary 2 3 Problems 3 3.1 The Central Galactic Floopy Corporation...........................

More information

Solution to the. Gaming Parlor. Programming Project

Solution to the. Gaming Parlor. Programming Project Solution to the Gaming Parlor Programming Project The Gaming Parlor - Solution Scenario: Front desk with dice (resource units) Groups request (e.g., 5) dice (They request resources) Groups must wait, if

More information

Consistency: Relaxed. SWE 622, Spring 2017 Distributed Software Engineering

Consistency: Relaxed. SWE 622, Spring 2017 Distributed Software Engineering Consistency: Relaxed SWE 622, Spring 2017 Distributed Software Engineering Review: HW2 What did we do? Cache->Redis Locks->Lock Server Post-mortem feedback: http://b.socrative.com/ click on student login,

More information

i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture

i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture 2 Concurrency Model checking Java Pathfinder (JPF) Detecting race condition Bounded buffer problem

More information

Lustre Client GSS with Linux Keyrings

Lustre Client GSS with Linux Keyrings Lustre Client GSS with Linux Keyrings Eric Mei 2008.07.22 1 Introduction This document describes how Lustre use keyring to populate and manage the client gss context, to replace current

More information

Transaction Management: Introduction (Chap. 16)

Transaction Management: Introduction (Chap. 16) Transaction Management: Introduction (Chap. 16) CS634 Class 14 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke What are Transactions? So far, we looked at individual queries;

More information

Citrix Connectivity Help. Table of Contents

Citrix Connectivity Help. Table of Contents Citrix Connectivity Help Table of Contents I. Purpose of this Document II. Print Preview Freezing III. Closing Word/ PD² Correctly IV. Session Reliability V. Reconnecting to Disconnected Applications VI.

More information

Name: NETID: issuing a write to an I/O device, e.g. the disk, keyboard or the network card

Name: NETID: issuing a write to an I/O device, e.g. the disk, keyboard or the network card CS 4410 Operating Systems Prelim I, Fall 2011 Prof. Sirer Name: NETID: This is a closed book examination. It is 8 pages long. You have 120 minutes. No electronic devices of any kind are allowed. If you

More information

CS193k, Stanford Handout #8. Threads 3

CS193k, Stanford Handout #8. Threads 3 CS193k, Stanford Handout #8 Spring, 2000-01 Nick Parlante Threads 3 t.join() Wait for finish We block until the receiver thread exits its run(). Use this to wait for another thread to finish. The current

More information

Synchronising Threads

Synchronising Threads Synchronising Threads David Chisnall March 1, 2011 First Rule for Maintainable Concurrent Code No data may be both mutable and aliased Harder Problems Data is shared and mutable Access to it must be protected

More information

CS510 Operating System Foundations. Jonathan Walpole

CS510 Operating System Foundations. Jonathan Walpole CS510 Operating System Foundations Jonathan Walpole A Solution to the Gaming Parlor Programming Project The Gaming Parlor - Solution Scenario: Front desk with dice (resource units) Groups request (e.g.,

More information

Diagnostics in Testing and Performance Engineering

Diagnostics in Testing and Performance Engineering Diagnostics in Testing and Performance Engineering This document talks about importance of diagnostics in application testing and performance engineering space. Here are some of the diagnostics best practices

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

ECE 598 Advanced Operating Systems Lecture 23

ECE 598 Advanced Operating Systems Lecture 23 ECE 598 Advanced Operating Systems Lecture 23 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 21 April 2016 Don t forget HW#9 Midterm next Thursday Announcements 1 Process States

More information

Tricky issues in file systems

Tricky issues in file systems Tricky issues in file systems Taylor Riastradh Campbell campbell@mumble.net riastradh@netbsd.org EuroBSDcon 2015 Stockholm, Sweden October 4, 2015 What is a file system? Standard Unix concept: hierarchy

More information

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

OpenACC Course. Office Hour #2 Q&A

OpenACC Course. Office Hour #2 Q&A OpenACC Course Office Hour #2 Q&A Q1: How many threads does each GPU core have? A: GPU cores execute arithmetic instructions. Each core can execute one single precision floating point instruction per cycle

More information

FLAT DATACENTER STORAGE CHANDNI MODI (FN8692)

FLAT DATACENTER STORAGE CHANDNI MODI (FN8692) FLAT DATACENTER STORAGE CHANDNI MODI (FN8692) OUTLINE Flat datacenter storage Deterministic data placement in fds Metadata properties of fds Per-blob metadata in fds Dynamic Work Allocation in fds Replication

More information

Performance Throughput Utilization of system resources

Performance Throughput Utilization of system resources Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency

More information

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to

More information

Concurrent Programming Issues & Readers/Writers

Concurrent Programming Issues & Readers/Writers Concurrent Programming Issues & Readers/Writers 1 Summary of Our Discussions! Developing and debugging concurrent programs is hard Ø Non-deterministic interleaving of instructions! Safety: isolation and

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution

More information

Overview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1

Overview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1 CMSC 433 Programming Language Technologies and Paradigms Spring 2003 Threads and Synchronization April 1, 2003 Overview What are threads? Thread scheduling, data races, and synchronization Thread mechanisms

More information

7. MULTITHREDED PROGRAMMING

7. MULTITHREDED PROGRAMMING 7. MULTITHREDED PROGRAMMING What is thread? A thread is a single sequential flow of control within a program. Thread is a path of the execution in a program. Muti-Threading: Executing more than one thread

More information

PYTHON MULTITHREADED PROGRAMMING

PYTHON MULTITHREADED PROGRAMMING PYTHON MULTITHREADED PROGRAMMING http://www.tutorialspoint.com/python/python_multithreading.htm Copyright tutorialspoint.com Running several threads is similar to running several different programs concurrently,

More information

go get my/vulnerabilities Green threads are not eco friendly threads

go get my/vulnerabilities Green threads are not eco friendly threads go get my/vulnerabilities Green threads are not eco friendly threads 1 Who ( Web Mobile ) penetration tester Code reviewer Programmer Roberto Clapis @empijei 2 Go Google s language Born in 2007 (quite

More information

Consistency: Strict & Sequential. SWE 622, Spring 2017 Distributed Software Engineering

Consistency: Strict & Sequential. SWE 622, Spring 2017 Distributed Software Engineering Consistency: Strict & Sequential SWE 622, Spring 2017 Distributed Software Engineering Review: Real Architectures N-Tier Web Architectures Internet Clients External Cache Internal Cache Web Servers Misc

More information

Thanks for Live Snapshots, Where's Live Merge?

Thanks for Live Snapshots, Where's Live Merge? Thanks for Live Snapshots, Where's Live Merge? KVM Forum 16 October 2014 Adam Litke Red Hat Adam Litke, Thanks for Live Snapshots, Where's Live Merge 1 Agenda Introduction of Live Snapshots and Live Merge

More information

Paperspace. Architecture Overview. 20 Jay St. Suite 312 Brooklyn, NY Technical Whitepaper

Paperspace. Architecture Overview. 20 Jay St. Suite 312 Brooklyn, NY Technical Whitepaper Architecture Overview Copyright 2016 Paperspace, Co. All Rights Reserved June - 1-2017 Technical Whitepaper Paperspace Whitepaper: Architecture Overview Content 1. Overview 3 2. Virtualization 3 Xen Hypervisor

More information

Managed Conversion of Guests to ovirt. Arik Hadas Senior Software Engineer Red Hat 21/8/15

Managed Conversion of Guests to ovirt. Arik Hadas Senior Software Engineer Red Hat 21/8/15 Managed Conversion of Guests to ovirt Arik Hadas Senior Software Engineer Red Hat 21/8/15 Agenda Motivation Architecture Demonstration Implementation Future work Many ways to run Virtual Machines There

More information