Performance Example memory access time = 100 nanoseconds swap fault overhead = 25 msec page fault rate = 1/1000 EAT = (1-p) * p * (25 msec)

Similar documents
Operating Systems. Virtual Memory

OPERATING SYSTEM - VIRTUAL MEMORY

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct)

Virtual Memory. Virtual Memory. Paging. CSE 380 Computer Operating Systems. Paging (1)

Virtual Memory Paging

Secondary Storage. Any modern computer system will incorporate (at least) two levels of storage: magnetic disk/optical devices/tape systems

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet.

Chapter 12. Paging an Virtual Memory Systems

Operating Systems, 6 th ed. Test Bank Chapter 7

& Data Processing 2. Exercise 3: Memory Management. Dipl.-Ing. Bogdan Marin. Universität Duisburg-Essen

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

Chapter 11 I/O Management and Disk Scheduling

361 Computer Architecture Lecture 14: Cache Memory

Timing of a Disk I/O Transfer

Virtual vs Physical Addresses

Lecture 17: Virtual Memory II. Goals of virtual memory

Chapter 11 I/O Management and Disk Scheduling

Operating System Tutorial

Computer Architecture

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Chapter 7 Memory Management

Performance Comparison of RTOS

Operating Systems Concepts: Chapter 7: Scheduling Strategies

COS 318: Operating Systems. Virtual Memory and Address Translation

The Classical Architecture. Storage 1 / 36

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

Operating Systems 4 th Class

CS162 Operating Systems and Systems Programming Lecture 15. Page Allocation and Replacement

Storage in Database Systems. CMPSCI 445 Fall 2010

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

OPERATING SYSTEM - MEMORY MANAGEMENT

OS OBJECTIVE QUESTIONS

File System & Device Drive. Overview of Mass Storage Structure. Moving head Disk Mechanism. HDD Pictures 11/13/2014. CS341: Operating System

Chapter 6, The Operating System Machine Level

HY345 Operating Systems

Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Best Practices for Monitoring Databases on VMware. Dean Richards Senior DBA, Confio Software

An Implementation Of Multiprocessor Linux

DMS Performance Tuning Guide for SQL Server

Chapter 3 Operating-System Structures

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Gigabit Ethernet Design

Kernel Optimizations for KVM. Rik van Riel Senior Software Engineer, Red Hat June

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

One of the database administrators

IBM Tivoli Monitoring Version 6.3 Fix Pack 2. Infrastructure Management Dashboards for Servers Reference

Quiz for Chapter 6 Storage and Other I/O Topics 3.10

Linux Process Scheduling Policy

COS 318: Operating Systems

Tech Tip: Understanding Server Memory Counters

Capacity Estimation for Linux Workloads

Computer-System Architecture

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

Computer Organization and Architecture. Characteristics of Memory Systems. Chapter 4 Cache Memory. Location CPU Registers and control unit memory

VI Performance Monitoring

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 5 - DBMS Architecture

1 File Management. 1.1 Naming. COMP 242 Class Notes Section 6: File Management

The World According to the OS. Operating System Support for Database Management. Today s talk. What we see. Banking DB Application

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

How To Understand And Understand An Operating System In C Programming

Virtual Memory Behavior in Red Hat Linux Advanced Server 2.1

CIT 470: Advanced Network and System Administration. Topics. Performance Monitoring. Performance Monitoring

TRACE PERFORMANCE TESTING APPROACH. Overview. Approach. Flow. Attributes

Predefined Analyser Rules for MS SQL Server

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Best practices for Implementing Lotus Domino in a Storage Area Network (SAN) Environment

Overview and History of Operating Systems

Data Storage - I: Memory Hierarchies & Disks

Chapter 5 Linux Load Balancing Mechanisms

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

On Benchmarking Popular File Systems

Performance Monitoring User s Manual

A3 Computer Architecture

Memory Management CS 217. Two programs can t control all of memory simultaneously

OPERATING SYSTEMS MEMORY MANAGEMENT

Chapter 1 Computer System Overview

Virtuoso and Database Scalability

CSC 2405: Computer Systems II

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Chapter 2 System Structures

Chapter 1: Introduction. What is an Operating System?

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

PERFORMANCE TUNING ORACLE RAC ON LINUX

Supplementing Windows 95 and Windows 98 Performance Data for Remote Measurement and Capacity Planning

Performance Characteristics of VMFS and RDM VMware ESX Server 3.0.1

Operating System Software

Midterm Exam #2 Solutions November 10, 1999 CS162 Operating Systems

Outline: Operating Systems

These sub-systems are all highly dependent on each other. Any one of them with high utilization can easily cause problems in the other.

- An Essential Building Block for Stable and Reliable Compute Clusters

Introduction. Application Performance in the QLinux Multimedia Operating System. Solution: QLinux. Introduction. Outline. QLinux Design Principles

Performance and scalability of a large OLTP workload

ICS Principles of Operating Systems

CS161: Operating Systems

Transcription:

Memory Management Outline Operating Systems Processes Memory Management Basic Paging Virtual memory Virtual Memory Motivation Demand Paging Logical address space larger than physical memory Virtual Memory on special disk Abstraction for programmer Performance ok? Error handling not used Maximum arrays Less I/O needed Less memory needed Faster response More users No pages in memory initially Pure demand paging Page out A A B Main Memory A A A B B Paging Implementation Page Fault Page Page Page Page Logical Memory v i v i Page Table Validation Bit Page Page Physical Memory Page not in memory interrupt OS => page fault OS looks in table: invalid reference? => abort not in memory? => bring it in Get empty frame (from list) Swap page into frame Reset tables (valid bit = ) Restart instruction

Performance of Demand Paging Page Fault Rate < p <. (no page faults to every is fault) Effective Access Time = (-p) (memory access) + p (Page Fault Overhead) Page Fault Overhead = swap page out + swap page in + restart Performance Example memory access time = nanoseconds swap fault overhead = 5 msec page fault rate = / EAT = (-p) * + p * (5 msec) = (-p) * + p * 5,, = +,999,9 * p = +,999,9 * / = 5 microseconds! Want less than % degradation > +,999,9 * p >,999,9 * p p <. or fault in,5, accesses! Page Replacement Page fault => What if no free frames? terminate user process (ugh!) swap out process (reduces degree of multiprog) replace other page with needed page Page replacement: if free frame, use it use algorithm to select victim frame write page to disk, changing tables read in new page restart process Page Page Page Page Logical Memory () Page Replacement iv () v v i Page Table vi () i Page Table Dirty Bit - avoid page out Page victim Page Physical Memory () () Page Replacement Algorithms Every system has its own Want lowest page fault rate Evaluate by running it on a particular string of memory references (reference string) and computing number of page faults Example:,,,,,,5,,,,,5 First-In-First-Out (FIFO),,,,,,5,,,,,5 Frames / Process 5 Frames / Process 5 9 Page Faults 5 Page Faults! Belady s Anomaly

Optimal Replace the page that will not be used for the longest period of time vs. Least Recently Used Replace the page that has not been used for the longest period of time,,,,,,5,,,,,5 Frames / Process 5,,,,,,5,,,,,5 6 Page Faults How do we know this? Use as benchmark 5 5 8 Page Faults No Belady s Anomoly - Stack Algorithm - N frames subset of N+ LRU Implementation Counter implementation every page has a counter; every time page is referenced, copy clock to counter when a page needs to be changed, compare the counters to determine which to change Stack implementation keep a stack of page numbers page referenced: move to top no search needed for replacement LRU Approximations LRU good, but hardware support expensive Some hardware support by reference bit with each page, initially = when page is referenced, set = replace the one which is (no order) enhance by having 8 bits and shifting approximate LRU Second-Chance Second-Chance FIFO replacement, but Get first in FIFO Look at reference bit bit == then replace bit == then set bit =, get next in FIFO If page referenced enough, never replaced Implement with circular queue Next Vicitm (a) (b) If all, degenerates to FIFO

Enhanced Second-Chance -bits, reference bit and modify bit (,) neither recently used nor modified best page to replace (,) not recently used but modified needs write-out (,) recently used but clean probably used again soon (,) recently used and modified used soon, needs write-out Circular queue in each class -- (Macintosh) Counting Algorithms Keep a counter of number of references LFU - replace page with smallest count if does all in beginning, won t be replaced decay values by shift MFU - smallest count just brought in and will probably be used Not too common (expensive) and not too good Page Buffering Pool of frames start new process immediately, before writing old write out when system idle list of modified pages write out when system idle pool of free frames, remember content page fault => check pool Allocation of Frames How many fixed frames per process? Two allocation schemes: fixed allocation priority allocation Fixed Allocation Equal allocation ex: 9 frames, 5 procs = 8 per proc ( in pool) Proportional Allocation number of frames proportional to size ex: 6 frames, s =, s = 7 f = / 7 x 6 = 5 f = 7 / 7 x 6 = 59 Treat processes equal Priority Allocation Use a proportional scheme based on priority If process generates a page fault select replacement a process with lower priority Global versus Local replacement local consistent (not influenced by others) global more efficient (used more often)

Thrashing Thrashing If a process does not have enough pages, the page-fault rate is very high low CPU utilization OS thinks it needs increased multiprogramming adds another procces to system Thrashing is when a process is busy swapping pages in and out CPU utilization degree of muliprogramming Cause of Thrashing Working-Set Model Why does paging work? Locality model process migrates from one locality to another localities may overlap Why does thrashing occur? sum of localities > total memory size How do we fix thrashing? Working Set Model Page Fault Frequency Working set window W = a fixed number of page references total number of pages references in time T D = sum of size of W s T = 5 Working Set Example 7 W={,,} W={,,7} W={,} if T too small, will not encompass locality if T too large, will encompass several localities if T => infinity, will encompass entire program if D > m => thrashing, so suspend a process Modify LRU appx to include Working Set Page Fault Rate Page Fault Frequency Number of Frames upper bound lower bound Establish acceptable page-fault rate If rate too low, process loses frame If rate too high, process gains frame increase number of frames decrease number of frames 5

Prepaging Pure demand paging has many page faults initially use working set does cost of prepaging unused frames outweigh cost of page-faulting? Page Size Old - Page size fixed, New -choose page size How do we pick the right page size? Tradeoffs: Fragmentation Table size Minimize I/O transfer small (.ms), latency + seek time large (ms) Locality small finer resolution, but more faults ex: K process (/ used), fault / k, K faults/ byte Historical trend towards larger page sizes CPU, mem faster proportionally than disks Program Structure consider: int A[][]; for (j=; j<; j++) suppose: for (i=; i<; i++) A[i][j] = ; process has frame row per page => x page faults! Program Structure int A[][]; for (i=; i<; i++) for (j=; j<; j++) A[i][j] = ; page faults stack vs. hash table Compiler separate code from data keep routines that call each other together LISP (pointers) vs. Pascal (no-pointers) Priority Processes Consider low priority process faults, bring page in low priority process in ready queue for awhile, waiting while high priority process runs high priority process faults low priority page clean, not used in a while => perfect! Lock-bit (like for I/O) until used once Real-time Real-Time Processes bounds on delay hard-real time: systems crash, lives lost air-traffic control, factor automation soft-real time: application sucks audio, video Paging adds unexpected delays don t do it lock bits for real-time processes 6

Virtual Memory and WinNT Page Replacement Algorithm FIFO Missing page, plus adjacent pages Working set default is take victim frame periodically if no fault, reduce set size by Reserve pool hard page faults soft page faults Virtual Memory and WinNT Shared pages level of indirection for easier updates same virtual entry Page File stores only modified logical pages code and memory mapped files on disk already Virtual Memory and Linux Regions of virtual memory paging disk (normal) file (text segment, memory mapped file) New Virtual Memory exec() creates new page table fork() copies page table reference to common pages if written, then copied Page Replacement Algorithm second chance (with more bits) Application Performance Studies and Demand Paging in Windows NT Mikhail Mikhailov Ganga Kannan Mark Claypool David Finkel WPI Saqib Syed Divya Prakash Sujit Kumar BMC Software, Inc. Capacity Planning Then and Now Experiment Design Capacity Planning in the good old days used to be just mainframes simple CPU-load based queuing theory Unix Capacity Planning today distributed systems networks of workstations Windows NT MS Exchange, Lotus Notes System Pentium MHz NT Server. 6 MB RAM IDE NTFS clearmem Experiments Page Faults Caching Analysis perfmon 7

Page Fault Method Soft or Hard Page Faults? Work hard Run lots of applications, open and close All local access, not over network Caching and Prefetching Start process wait for Enter Start perfmon Hit Enter Read -K page Exit Repeat Hit Return button Page Metrics with Caching On Read KB Exit Start Read KB Hit Return button Exit 8