Filev Ar Option: Controlling Files Read And/Or Written

Total Page:16

File Type:pdf, Size:1020Kb

Filev Ar Option: Controlling Files Read And/Or Written FILEVAR OPTION: CONTROLLING FILES READ AND/OR WRITTEN Steve Goins, American Express, Phoenix, AZ ABSTRACT Related Infile Options While there are several simple ways to concatenate external files, it Two Infile options that can be very useful when reading can be very useful to control the files used. concatenated files are EOV and FileName. This paper will cover concatenating external files and the basics of using the FileVar option. EOV = variable Assigns I to variable when the first record in a series of I will provide some example programs using the FILEVAR option: concatenated files is read. SAS does not reset the variable collecting metrics, making changes to all programs in a directory, to 0. The variable is not written to the data set. etc. FileName = variable INTRODUCTION SAS assigns the name of the currently open file to the much The FileV ar option to the Infile and File statements provides variable. Like automatic variables, the FileName variable to be flexibility by allowing the files read from and/or written out is not written out. changed at run time. I will first cover other ways of reading multiple files, and then focus on the FileVar option. 1 Data a; Fn FileNm $25; This paper will only deal with the Windows operating systems 2 Length been tested on. I 3 Infile •c:\files\tst?.txt" (Windows 95, 98, ME, NT, 2000) the code has FileName=Fn; are short and readable. used my PC for testing so file names 4 Input Arnt 3. ; 5 FileNm=Fn; READING CONCATENATED FLAT FILES 6 Run; arranging for multiple files to be read as one file Two methods for Line 3 assigns the FileName variable Fn to a variable, together using the SAS grouping are: I) group the file names FileNm, which will remain on the data set. refer to the files with a wild card character. character, and 2) Below is the log from above program, and some output. is: Group the FOes NOTE: The infile "c:\files\tst?.txt" File Name~c:\files\tst3.txt, Place the file names, surrounded by a pair of tic marks or double File quotes, within parentheses. List=c:\files\tst?.txt,RECFM=V,LRECL=256 FileName FileRef ('c:\Files\tstl.txt' 'c:\Files\tst2.txt' "c:\files\tst?.txt" is: 'c:\Files\tst3.txt'); NOTE: The infile File Name~c:\files\tst2.txt, Data GroupExample; File FileRef; Infile List=c:\files\tst?.txt,RECFM=V,LRECL=256 Input Amount 3.; Run; NOTE: The infile "c:\files\tst?.txt" is: File Name=c:\files\tstl.txt, WUd Card Character File Use a wild card character in referring to the files -- in Windows, the List=c:\files\tst?.txt,RECFM=V,LRECL=256 asterisk "*" for any number of characters, or the question mark "?" records were read from the for I character. NOTE: 3 infile "c:\files\tst?.txt". FileName FileRef 'c:\Files\*.txt'; The minimum record length was 3. The maximum record length was 3. Data WildExample; NOTE: 3 records were read from the Infile FileRef; infile "c:\files\tst?.txt". Input Amount 3.; The minimum record length was 3. Run; The maximum record length was 3. NOTE: 3 records were read from the The wild card character can also be used in the Infile statement. infile "c:\files\tst?.txt". Data WildExarnple; The minimum record length was 3. Infile 'c:\Files\tst?.txt'; The maximum record length was 3. Input Amount 3.; NOTE: The data set WORK.A has 9 Run; observations and 2 variables. NOTE: DATA statement used: 32 real time 0.66 seconds End=done, to indicate the last record of the file by setting the variable done to I. Proc Print Data=Example NoObs; Run; Line 5: A DO loop is used here to read all the records of the file. This is necessary because on the second iteration FileNm Amount of the DATA step, the first In file statement reads another record which will be input to the File Var = nption in the c:\files\tstl.txt 111 c:\files\tstl.txt 222 second Infile statement. The DO While loop checks at the c:\files\tstl.txt 333 start of the loop while a DO Until loop checks at the end. c:\files\tst2.txt 222 The DO While loop should be used if you do not want the c:\files\tst2.txt 444 DATA step to end when it comes to a zero-byte file. c:\files\tst2.txt 666 c:\files\tst3.txt 333 c:\files\tst3.txt 666 Line 7: The OUTPUT statement writes out each record c:\files\tst3.txt 999 within the DO loop. FILEVAR INFILE Statement The power of the File Var option comes from the flexibility in FILEVAR= Defines a variable whose change in value creating the FileVar variable. causes the INFILE statement to close the current output file and open a new one the next time the INFILE statement executes. 1 The source for the FileVar variable can come from a field from a SAS file or raw file, can be created from fields read in, or can be You can create the FILEV AR variable by using the specified in the code. INFILE statement to read a directory listing from Unnamed pipes, a text files, or data lines. Or you could read a SAS data set to create the FILEV AR variable. FILEVAR Basics Below is a basic example of using File Var option to read 3 files. Unnamed Pipes as Input 1 Data Stuff; An unnamed pipe can be used to direct a directory listing 2 Infile Cards; to the SAS system for use as input. 3 Input Fil2Read $17.; FileName fList "Dir C:\Files\t*.txt/b"; 4 Infile Dummy FileVar=Fil2Read The above fList file reference will refer to below data: End= Done; 5 Do While (Not Done); tst3.txt 6 Input Amount 3.; tst2.txt 7 Output; tstl. txt 8 End; You do not get the full path so you wiJI usually add the file name to the directory in your code. You can add the /s 9 Cards; include subdirectories option after lb to get the full path, if C:\Files\tstl.txt appropriate to include subdirectories. C:\Files\tst2.txt C:\Files\tst3.txt FileName fList "Dir C:\Files\*.txt/b/s"; ; Run; The above fList file reference will refer to below data: C:\Files\tst3.txt NOTE: The data set WORK.STUFF has C:\Files\tst2.txt 9 observations and 1 variables. C:\Files\tstl.txt NOTE: D~T~ statement used: C:\Files\SchedulerJobs.TXT real time 0.16 seconds There may be different starting columns for the date and Line 2: The first Infile statement tells SAS to start reading data after file size, depending on the Windows version, with the the Cards statement. Windows Dir command. Line 3: This Input statement reads in a filename into a variable that Creating the FileVar Variable in Code will be used in the FileVar option for reading multiple files. This You can derive the code before the Infile (with FileVar) variable will not be kept in the data because the variable that feeds Statement. You will need to stop the DATA step after you the FileVar= is not kept. have read enough records because here there will not be an end of record or end ofSAS data set to end the DATA step. Line 4: The file reference, Dummy, can be any valid 8 character SAS file reference name. An automatic variable is set up, with 1 Data Stuff; 2 Drop Cnt; 33 3 Cnt + 1; By State; 4 FileNm = "C:\Files\tst" Run; !! put(Cnt,l.) !! ".txt"; 5 Src = FileNm; Data Null ; 6 Infile dummy FileVar = FileNm Set-Stateinfo; End= Done; By State; 7 Do While (Not Done) ; If First.State Then File2Put = 8 Input Amount 3. ; "C:\Files\" ! ! State ! ! ".txt"; 9 Output; File Dummy FileVar = File2Put; 10 End; Put State $2. 11 If Cnt = 3 Then Stop; ThatDate $6. 12 Run; Amt $4. ; Run; NOTE: The infile DUMMY is: Below is the log, which follows the last DATA step, File Name=C:\Files\tstl.txt, showing that 6 files are written out. RECFM=V,LRECL=256 NOTE: The file DUMMY is: NOTE: The infile DUMMY is: File Name=C:\Files\AK.txt, File Name=C:\Files\tst2.txt, RECFM=V,LRECL=256 RECFM=V,LRECL=256 NOTE: The file DUMMY is: NOTE: The infile DUMMY is: File Name=C:\Files\AL.txt, File Name=C:\Files\tst3.txt, RECFM=V,LRECL=256 RECFM=V,LRECL=256 NOTE: The file DUMMY is: NOTE: 3 records were read from the infile File Name=C:\Files\AR.txt, DUMMY. RECFM=V,LRECL=256 The minimum record length was 3. file The maximum record length was 3. NOTE: 1 record was written to the read from the infile DUMMY. NOTE: 3 records were The minimum record length was 12. DUMMY. The maximum record length was 12. The minimum record length was 3. NOTE: 3 records were written to the file The maximum record length was 3. DUMMY. NOTE: 3 records were read from the infile The minimum record length was 12. DUMMY. The maximum record length was 12. The minimum record length was 3. NOTE: 2 records were written to the file The maximum record length was 3. DUMMY. NOTE: The data set WORK.STUFF has 9 The minimum record length was 12. observations and 2 variables. The maximum record length was 12. NOTE: DATA statement used: NOTE: There were 6 observations read from real time 0.37 seconds the data set WORK.STATEINFO.
Recommended publications
  • Lecture 9: Data Storage and IO Models Lecture 9
    Lecture 9 Lecture 9: Data Storage and IO Models Lecture 9 Announcements • Submission Project Part 1 tonight • Instructions on Piazza! • PS2 due on Friday at 11:59 pm • Questions? Easier than PS1. • Badgers Rule! Lecture 9 Today’s Lecture 1. Data Storage 2. Disk and Files 3. Buffer Manager - Prelims 3 Lecture 9 > Section 1 1. Data Storage 4 Lecture 9 > Section 1 What you will learn about in this section 1. Life cycle of a query 2. Architecture of a DBMS 3. Memory Hierarchy 5 Lecture 9 > Section 1 Life cycle of a query Query Result Query Database Server Query Execute Parser Optimizer Select R.text from |…|……|………..|………..| Report R, Weather W |…|……|………..|………..| where W.image.rain() Scheduler Operators |…|……|………..|………..| and W.city = R.city |…|……|………..|………..| and W.date = R.date |…|……|………..|………..| and |…|……|………..|………..| R.text. |…|……|………..|………..| matches(“insurance claims”) |…|……|………..|………..| |…|……|………..|………..| |…|……|………..|………..| |…|……|………..|………..| Query Query Syntax Tree Query Plan Result Segments 6 Lecture 9 > Section 1 > Architecture of a DBMS Internal Architecture of a DBMS query Query Execution data access Storage Manager I/O access 7 Lecture 9 > Section 1 > Storage Manager Architecture of a Storage Manager Access Methods Sorted File Hash Index B+-tree Heap File Index Manager Buffer Manager Recovery Manager Concurrency Control I/O Manager IO Accesses In Systems, IO cost matters a ton! 8 Lecture 9 > Section 1 > Data Storage Data Storage • How does a DBMS store and access data? • main memory (fast, temporary) • disk (slow, permanent) • How
    [Show full text]
  • System Calls System Calls
    System calls We will investigate several issues related to system calls. Read chapter 12 of the book Linux system call categories file management process management error handling note that these categories are loosely defined and much is behind included, e.g. communication. Why? 1 System calls File management system call hierarchy you may not see some topics as part of “file management”, e.g., sockets 2 System calls Process management system call hierarchy 3 System calls Error handling hierarchy 4 Error Handling Anything can fail! System calls are no exception Try to read a file that does not exist! Error number: errno every process contains a global variable errno errno is set to 0 when process is created when error occurs errno is set to a specific code associated with the error cause trying to open file that does not exist sets errno to 2 5 Error Handling error constants are defined in errno.h here are the first few of errno.h on OS X 10.6.4 #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* Input/output error */ #define ENXIO 6 /* Device not configured */ #define E2BIG 7 /* Argument list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file descriptor */ #define ECHILD 10 /* No child processes */ #define EDEADLK 11 /* Resource deadlock avoided */ 6 Error Handling common mistake for displaying errno from Linux errno man page: 7 Error Handling Description of the perror () system call.
    [Show full text]
  • Ext4 File System and Crash Consistency
    1 Ext4 file system and crash consistency Changwoo Min 2 Summary of last lectures • Tools: building, exploring, and debugging Linux kernel • Core kernel infrastructure • Process management & scheduling • Interrupt & interrupt handler • Kernel synchronization • Memory management • Virtual file system • Page cache and page fault 3 Today: ext4 file system and crash consistency • File system in Linux kernel • Design considerations of a file system • History of file system • On-disk structure of Ext4 • File operations • Crash consistency 4 File system in Linux kernel User space application (ex: cp) User-space Syscalls: open, read, write, etc. Kernel-space VFS: Virtual File System Filesystems ext4 FAT32 JFFS2 Block layer Hardware Embedded Hard disk USB drive flash 5 What is a file system fundamentally? int main(int argc, char *argv[]) { int fd; char buffer[4096]; struct stat_buf; DIR *dir; struct dirent *entry; /* 1. Path name -> inode mapping */ fd = open("/home/lkp/hello.c" , O_RDONLY); /* 2. File offset -> disk block address mapping */ pread(fd, buffer, sizeof(buffer), 0); /* 3. File meta data operation */ fstat(fd, &stat_buf); printf("file size = %d\n", stat_buf.st_size); /* 4. Directory operation */ dir = opendir("/home"); entry = readdir(dir); printf("dir = %s\n", entry->d_name); return 0; } 6 Why do we care EXT4 file system? • Most widely-deployed file system • Default file system of major Linux distributions • File system used in Google data center • Default file system of Android kernel • Follows the traditional file system design 7 History of file system design 8 UFS (Unix File System) • The original UNIX file system • Design by Dennis Ritche and Ken Thompson (1974) • The first Linux file system (ext) and Minix FS has a similar layout 9 UFS (Unix File System) • Performance problem of UFS (and the first Linux file system) • Especially, long seek time between an inode and data block 10 FFS (Fast File System) • The file system of BSD UNIX • Designed by Marshall Kirk McKusick, et al.
    [Show full text]
  • File Handling in Python
    hapter C File Handling in 2 Python There are many ways of trying to understand programs. People often rely too much on one way, which is called "debugging" and consists of running a partly- understood program to see if it does what you expected. Another way, which ML advocates, is to install some means of understanding in the very programs themselves. — Robin Milner In this Chapter » Introduction to Files » Types of Files » Opening and Closing a 2.1 INTRODUCTION TO FILES Text File We have so far created programs in Python that » Writing to a Text File accept the input, manipulate it and display the » Reading from a Text File output. But that output is available only during » Setting Offsets in a File execution of the program and input is to be entered through the keyboard. This is because the » Creating and Traversing a variables used in a program have a lifetime that Text File lasts till the time the program is under execution. » The Pickle Module What if we want to store the data that were input as well as the generated output permanently so that we can reuse it later? Usually, organisations would want to permanently store information about employees, inventory, sales, etc. to avoid repetitive tasks of entering the same data. Hence, data are stored permanently on secondary storage devices for reusability. We store Python programs written in script mode with a .py extension. Each program is stored on the secondary device as a file. Likewise, the data entered, and the output can be stored permanently into a file.
    [Show full text]
  • System Calls and Standard I/O
    System Calls and Standard I/O Professor Jennifer Rexford http://www.cs.princeton.edu/~jrex 1 Goals of Today’s Class • System calls o How a user process contacts the Operating System o For advanced services that may require special privilege • Standard I/O library o Generic I/O support for C programs o A smart wrapper around I/O-related system calls o Stream concept, line-by-line input, formatted output, ... 2 1 System Calls 3 Communicating With the OS User Process signals systems calls Operating System • System call o Request to the operating system to perform a task o … that the process does not have permission to perform • Signal o Asynchronous notification sent to a process … to notify the process of an event that has occurred o 4 2 Processor Modes • The OS must restrict what a user process can do o What instructions can execute o What portions of the address space are accessible • Supervisor mode (or kernel mode) o Can execute any instructions in the instruction set – Including halting the processor, changing mode bit, initiating I/O o Can access any memory location in the system – Including code and data in the OS address space • User mode o Restricted capabilities – Cannot execute privileged instructions – Cannot directly reference code or data in OS address space o Any such attempt results in a fatal “protection fault” – Instead, access OS code and data indirectly via system calls 5 Main Categories of System Calls • File system o Low-level file I/O o E.g., creat, open, read, write, lseek, close • Multi-tasking mechanisms o Process
    [Show full text]
  • [13주차] Sysfs and Procfs
    1 7 Computer Core Practice1: Operating System Week13. sysfs and procfs Jhuyeong Jhin and Injung Hwang Embedded Software Lab. Embedded Software Lab. 2 sysfs 7 • A pseudo file system provided by the Linux kernel. • sysfs exports information about various kernel subsystems, HW devices, and associated device drivers to user space through virtual files. • The mount point of sysfs is usually /sys. • sysfs abstrains devices or kernel subsystems as a kobject. Embedded Software Lab. 3 How to create a file in /sys 7 1. Create and add kobject to the sysfs 2. Declare a variable and struct kobj_attribute – When you declare the kobj_attribute, you should implement the functions “show” and “store” for reading and writing from/to the variable. – One variable is one attribute 3. Create a directory in the sysfs – The directory have attributes as files • When the creation of the directory is completed, the directory and files(attributes) appear in /sys. • Reference: ${KERNEL_SRC_DIR}/include/linux/sysfs.h ${KERNEL_SRC_DIR}/fs/sysfs/* • Example : ${KERNEL_SRC_DIR}/kernel/ksysfs.c Embedded Software Lab. 4 procfs 7 • A special filesystem in Unix-like operating systems. • procfs presents information about processes and other system information in a hierarchical file-like structure. • Typically, it is mapped to a mount point named /proc at boot time. • procfs acts as an interface to internal data structures in the kernel. The process IDs of all processes in the system • Kernel provides a set of functions which are designed to make the operations for the file in /proc : “seq_file interface”. – We will create a file in procfs and print some data from data structure by using this interface.
    [Show full text]
  • USB Composite Gadget Using CONFIG-FS on Dra7xx Devices
    Application Report SPRACB5–September 2017 USB Composite Gadget Using CONFIG-FS on DRA7xx Devices RaviB ABSTRACT This application note explains how to create a USB composite gadget, network control model (NCM) and abstract control model (ACM) from the user space using Linux® CONFIG-FS on the DRA7xx platform. Contents 1 Introduction ................................................................................................................... 2 2 USB Composite Gadget Using CONFIG-FS ............................................................................. 3 3 Creating Composite Gadget From User Space.......................................................................... 4 4 References ................................................................................................................... 8 List of Figures 1 Block Diagram of USB Composite Gadget............................................................................... 3 2 Selection of CONFIGFS Through menuconfig........................................................................... 4 3 Select USB Configuration Through menuconfig......................................................................... 4 4 Composite Gadget Configuration Items as Files and Directories ..................................................... 5 5 VID, PID, and Manufacturer String Configuration ....................................................................... 6 6 Kernel Logs Show Enumeration of USB Composite Gadget by Host ................................................ 6 7 Ping
    [Show full text]
  • Text File Text File Example Text Reading Overview
    CS106A, Stanford Handout #53 Fall, 2003-04 Nick Parlante Files Text File The simple "text file" is one of the oldest and simplest types of file. For that reason, text files are one of the most universally standard ways to store information. A text file is something you could type up in a word processor, and save with the "plain text" option. A text file is made of a sequence of characters, organized as a series of horizontal lines of text. There is no notion of bold or italic or color applied to the characters; they are just plain text characters, as we would store in a String. Historically, text files have been made of the familiar roman keyboard alphabet – abcdef..xyz012..89!@#$.. – with the extremely standard ASCII encoding (American Standard Code for Information Interchange). More recently, text has grown to include the idea of unicode characters like ø and !, but the encodings for those are not yet as standard as ASCII. The .java files where we write our Java code are examples of text files. The text file is such a simple, flexible way to store information, it will be with us for a long time to come. If you want to store information in a simple, non-proprietary way, the text file is a great choice. XML files, which are a very modern way to store information, are a type of text file. Text File Example This is the first line of my 4 line text file, and this here is the 2nd. The above line is blank! The above example text file is 4 lines long.
    [Show full text]
  • Computer Files & Data Storage
    STORAGE & FILE CONCEPTS, UTILITIES (Pages 6, 150-158 - Discovering Computers & Microsoft Office 2010) I. Computer files – data, information or instructions residing on secondary storage are stored in the form of a file. A. Software files are also called program files. Program files (instructions) are created by a computer programmer and generally cannot be modified by a user. It’s important that we not move or delete program files because your computer requires them to perform operations. Program files are also referred to as “executables”. 1. You can identify a program file by its extension:“.EXE”, “.COM”, “.BAT”, “.DLL”, “.SYS”, or “.INI” (there are others) or a distinct program icon. B. Data files - when you select a “save” option while using an application program, you are in essence creating a data file. Users create data files. 1. File naming conventions refer to the guidelines followed while assigning file names and will vary with the operating system and application in use (see figure 4-1). File names in Windows 7 may be up to 255 characters, you're not allowed to use reserved characters or certain reserved words. File extensions are used to identify the application that was used to create the file and format data in a manner recognized by the source application used to create it. FALL 2012 1 II. Selecting secondary storage media A. There are three type of technologies for storage devices: magnetic, optical, & solid state, there are advantages & disadvantages between them. When selecting a secondary storage device, certain factors should be considered: 1. Capacity - the capacity of computer storage is expressed in bytes.
    [Show full text]
  • Modular Data Storage with Anvil
    Modular Data Storage with Anvil Mike Mammarella Shant Hovsepian Eddie Kohler UCLA UCLA UCLA/Meraki [email protected] [email protected] [email protected] http://www.read.cs.ucla.edu/anvil/ ABSTRACT age strategies and behaviors. We intend Anvil configura- Databases have achieved orders-of-magnitude performance tions to serve as single-machine back-end storage layers for improvements by changing the layout of stored data – for databases and other structured data management systems. instance, by arranging data in columns or compressing it be- The basic Anvil abstraction is the dTable, an abstract key- fore storage. These improvements have been implemented value store. Some dTables communicate directly with sta- in monolithic new engines, however, making it difficult to ble storage, while others layer above storage dTables, trans- experiment with feature combinations or extensions. We forming their contents. dTables can represent row stores present Anvil, a modular and extensible toolkit for build- and column stores, but their fine-grained modularity of- ing database back ends. Anvil’s storage modules, called dTa- fers database designers more possibilities. For example, a bles, have much finer granularity than prior work. For ex- typical Anvil configuration splits a single “table” into sev- ample, some dTables specialize in writing data, while oth- eral distinct dTables, including a log to absorb writes and ers provide optimized read-only formats. This specialization read-optimized structures to satisfy uncached queries. This makes both kinds of dTable simple to write and understand. split introduces opportunities for clean extensibility – for Unifying dTables implement more comprehensive function- example, we present a Bloom filter dTable that can slot ality by layering over other dTables – for instance, building a above read-optimized stores and improve the performance read/write store from read-only tables and a writable journal, of nonexistent key lookup.
    [Show full text]
  • How to Avoid Writing Kernel Drivers
    How to avoid writing kernel drivers Chris Simmonds Embedded Linux Conference Europe 2018 How to avoid writing kernel drivers1 Copyright © 2011-2018, 2net Ltd License These slides are available under a Creative Commons Attribution-ShareAlike 3.0 license. You can read the full text of the license here http://creativecommons.org/licenses/by-sa/3.0/legalcode You are free to • copy, distribute, display, and perform the work • make derivative works • make commercial use of the work Under the following conditions • Attribution: you must give the original author credit • Share Alike: if you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one (i.e. include this page exactly as it is) • For any reuse or distribution, you must make clear to others the license terms of this work How to avoid writing kernel drivers2 Copyright © 2011-2018, 2net Ltd About Chris Simmonds • Consultant and trainer • Author of Mastering Embedded Linux Programming • Working with embedded Linux since 1999 • Android since 2009 • Speaker at many conferences and workshops "Looking after the Inner Penguin" blog at http://2net.co.uk/ @2net_software https://uk.linkedin.com/in/chrisdsimmonds/ How to avoid writing kernel drivers3 Copyright © 2011-2018, 2net Ltd Agenda • Device drivers in kernel space • Device drivers in user space • Some examples: • GPIO • PWM • I2C How to avoid writing kernel drivers4 Copyright © 2011-2018, 2net Ltd Conventional device driver model Application User space C library System call handler Linux Generic services kernel Device drivers interrupts Hardware How to avoid writing kernel drivers5 Copyright © 2011-2018, 2net Ltd How applications interact device drivers • In Linux, everything is a file 1 • Applications interact with drivers via POSIX functions open(2), read(2), write(2), ioctl(2), etc • Two main types of interface: 1.
    [Show full text]
  • Evolving Ext4 for Shingled Disks Abutalib Aghayev Theodore Ts’O Garth Gibson Peter Desnoyers Carnegie Mellon University Google, Inc
    Evolving Ext4 for Shingled Disks Abutalib Aghayev Theodore Ts’o Garth Gibson Peter Desnoyers Carnegie Mellon University Google, Inc. Carnegie Mellon University Northeastern University Abstract ST5000AS0011 Drive-Managed SMR (Shingled Magnetic Recording) disks 30 ST8000AS0002 10 ST4000LM016 offer a plug-compatible higher-capacity replacement for WD40NMZW conventional disks. For non-sequential workloads, these 3 WD5000YS disks show bimodal behavior: After a short period of high 1 throughput they enter a continuous period of low throughput. 0.3 We introduce ext4-lazy1, a small change to the Linux 0.1 Throughput (MiB/s) ext4 file system that significantly improves the throughput 0.03 in both modes. We present benchmarks on four different 0.01 drive-managed SMR disks from two vendors, showing that 0 100 200 300 400 500 ext4-lazy achieves 1.7-5.4× improvement over ext4 on a Time (s) metadata-light file server benchmark. On metadata-heavy Figure 1: Throughput of CMR and DM-SMR disks from Table 1 under benchmarks it achieves 2-13× improvement over ext4 on 4 KiB random write traffic. CMR disk has a stable but low throughput under drive-managed SMR disks as well as on conventional disks. random writes. DM-SMR disks, on the other hand, have a short period of high throughput followed by a continuous period of ultra-low throughput. 1 Introduction Type Vendor Model Capacity Form Factor Over 90% of all data in the world has been generated over the DM-SMR Seagate ST8000AS0002 8 TB 3.5 inch last two years [14]. To cope with the exponential growth of DM-SMR Seagate ST5000AS0011 5 TB 3.5 inch data, as well as to stay competitive with NAND flash-based DM-SMR Seagate ST4000LM016 4 TB 2.5 inch solid state drives (SSDs), hard disk vendors are researching DM-SMR Western Digital WD40NMZW 4 TB 2.5 inch capacity-increasing technologies like Shingled Magnetic CMR Western Digital WD5000YS 500 GB 3.5 inch Recording (SMR) [20,60], Heat Assisted Magnetic Record- ing (HAMR) [29], and Bit-Patterned Magnetic Recording Table 1: CMR and DM-SMR disks from two vendors used for evaluation.
    [Show full text]