Caching and Buffering in HDF5

Similar documents
What NetCDF users should know about HDF5?

HDF5 I/O Performance. HDF and HDF-EOS Workshop VI December 5, 2002

DRAFT. HDF5 Data Flow Pipeline for H5Dread. 1 Introduction. 2 Examples

I/O in scientific applications

File System Internals. Jo, Heeseung

CS399 New Beginnings. Jonathan Walpole

CS 550 Operating Systems Spring File System

Hierarchical Data Format 5:

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Memory Management. Dr. Yingwu Zhu

Chapter 8: Main Memory

File Systems. Kartik Gopalan. Chapter 4 From Tanenbaum s Modern Operating System

CS307 Operating Systems Main Memory

h5perf_serial, a Serial File System Benchmarking Tool

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Chapter 8: Memory-Management Strategies

Chapter 3 - Memory Management

Chapter 12: File System Implementation

The HDF Group. Parallel HDF5. Extreme Scale Computing Argonne.

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Introduction to serial HDF5

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Computer Systems Laboratory Sungkyunkwan University

CS370 Operating Systems

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective

CPSC 421 Database Management Systems. Lecture 11: Storage and File Organization

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Background. Contiguous Memory Allocation

COSC 6374 Parallel Computation. Scientific Data Libraries. Edgar Gabriel Fall Motivation

File System Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

Parallel I/O and Portable Data Formats HDF5

Basic Memory Management

Goals of Memory Management

Chapter 8: Main Memory

HDF- A Suitable Scientific Data Format for Satellite Data Products

File Directories Associated with any file management system and collection of files is a file directories The directory contains information about

Main Memory (Part II)

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

HDF5 Single Writer/Multiple Reader Feature Design and Semantics

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Chapter 17. Disk Storage, Basic File Structures, and Hashing. Records. Blocking

File System Implementation

Chapter 8 Main Memory

Main Memory (Part I)

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies

UNIT III MEMORY MANAGEMENT

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

CSE 153 Design of Operating Systems

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

[537] Fast File System. Tyler Harter

Post-processing issue, introduction to HDF5

CS 153 Design of Operating Systems Winter 2016

File Systems. CS170 Fall 2018

File Layout and Directories

CS3600 SYSTEMS AND NETWORKS

CS307: Operating Systems

Preview. Memory Management

A Private Heap for HDF5 Quincey Koziol Jan. 15, 2007

CS370 Operating Systems

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

Introduction to HDF5

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

RFC: HDF5 File Space Management: Paged Aggregation

Operating Systems Unit 6. Memory Management

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Benchmarking the CGNS I/O performance

Memory Management. Goals of Memory Management. Mechanism. Policies

HDF5 User s Guide. HDF5 Release November

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 6: File Systems

Chapter 3.5 Memory and I/O Systems

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

New Features in HDF5. Why new features? September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial

In multiprogramming systems, processes share a common store. Processes need space for:

Paging & Segmentation

CS November 2017

End-to-End Data Integrity in the Intel/EMC/HDF Group Exascale IO DOE Fast Forward Project

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

The Google File System

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Frequently asked questions from the previous class survey

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

Virtual Memory I. Jo, Heeseung

Parallel I/O and Portable Data Formats

File System: Interface and Implmentation

Transcription:

Caching and Buffering in HDF5 September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 1 Software stack Life cycle: What happens to data when it is transferred from application buffer to HDF5 file and from HDF5 file to application buffer? Data buffer Object API Library internals Virtual file I/O H5Dwrite? Unbuffered I/O or other storage Data in a file September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 2 1

Goals Understanding of what is happening to data inside the HDF5 library will help to write efficient applications Goals of this talk: Describe some basic operations and data structures, and explain how they affect performance and storage sizes Give some recipes for how to improve performance September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 3 Topics Dataset metadata and array data storage layouts Types of dataset storage layouts Factors affecting I/O performance I/O with compact datasets I/O with contiguous datasets I/O with chunked datasets Variable length data and I/O September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 4 2

HDF5 dataset metadata and array data storage layouts September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 5 Data array HDF5 Dataset Ordered collection of identically typed data items distinguished by their indices Metadata Dataspace: Rank, dimensions of dataset array Datatype: Information on how to interpret data Storage Properties: How array is organized on disk Attributes: User-defined metadata (optional) September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 6 3

HDF5 Dataset Metadata Dataspace Dataset data 3 Dim_1 = 4 Dim_2 = 5 Dim_3 = 7 IEEE 32-bit float Chunked Compressed Time = 32.4 Pressure = 987 Temp = 56 September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 7 Metadata cache and dataset data Dataset data typically kept in application memory Dataset header in separate space metadata cache Metadata cache Datatype Dataspace Attributes Dataset header Dataset data Dataset data Application memory September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 8 4

HDF5 metadata Metadata and metadata cache Information about HDF5 objects used by the library Examples: object headers, B-tree nodes for group, B-Tree nodes for chunks, heaps, super-block, etc. Usually small compared to raw data sizes (KB vs. MB-GB) September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 9 Metadata and metadata cache Metadata cache Space allocated to handle pieces of the HDF5 metadata Allocated by the HDF5 library in application s memory space Cache behavior affects overall performance Metadata cache implementation prior to HDF5 1.6.5 could cause performance degradation for some applications September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 10 5

Types of data storage layouts September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 11 HDF5 datasets storage layouts Contiguous Chunked Compact September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 12 6

Contiguous storage layout Metadata header separate from dataset data Data stored in one contiguous block in HDF5 file Metadata cache Datatype Dataspace Attributes Dataset data Application memory Dataset data September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 13 Chunked storage Chunking storage layout where a dataset is partitioned in fixed-size multi-dimensional tiles or chunks Used for extendible datasets and datasets with filters applied (checksum, compression) HDF5 library treats each chunk as atomic object Greatly affects performance and file sizes September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 14 7

Chunked storage layout Dataset data divided into equal sized blocks (chunks) Each chunk stored separately as a contiguous block in HDF5 file Datatype Dataspace Attributes Metadata cache Chunk index Dataset data A B C D Application memory header Chunk index A C D B September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 15 Compact storage layout Dataset data and metadata stored together in the object header Metadata cache Dataset data Datatype Dataspace Attributes Application memory September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 16 8

Factors affecting I/O performance September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 17 What goes on inside the library? Operations on data inside the library Copying to/from internal buffers Datatype conversion Scattering - gathering Data transformation (filters, compression) Data structures used B-trees (groups, dataset chunks) Hash tables Local and Global heaps (variable length data: link names, strings, etc.) Other concepts HDF5 metadata, metadata cache Chunking, chunk cache September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 18 9

Operations on data inside the library Copying to/from internal buffers Datatype conversion, such as float integer Little-endian big-endian 64-bit integer to 16-bit integer Scattering - gathering Data is scattered/gathered from/to application buffers into internal buffers for datatype conversion and partial I/O Data transformation (filters, compression) Checksum on raw data and metadata (in 1.8.0) Algebraic transform GZIP and SZIP compressions User-defined filters September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 19 I/O performance I/O performance depends on Storage layouts Dataset storage properties Chunking strategy Metadata cache performance Datatype conversion performance Other filters, such as compression Access patterns September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 20 10

I/O with different storage layouts September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 21 Writing a compact dataset Metadata cache Datatype Dataspace Attributes Dataset data Dataset data Application memory One write to store header and dataset data September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 22 11

Writing contiguous dataset no conversion Metadata cache Dataset data Datatype Dataspace Attributes Application memory No sub-setting in memory or a file is performed September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 23 Writing a contiguous dataset with datatype conversion Dataset header Datatype Dataspace Attribute 1 Attribute 2 Metadata cache Dataset data Conversion buffer 1MB Application memory No sub-setting in memory or a file is performed September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 24 12

Partial I/O with contiguous datasets September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 25 Writing whole dataset contiguous rows N M One I/O operation Application data in memory M rows Data is contiguous in a file September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 26 13

Sub-setting of contiguous dataset Series of adjacent rows Application data in memory N M One I/O operation M rows Subset contiguous in a file Entire dataset contiguous in a file September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 27 Sub-setting of contiguous dataset Adjacent, partial rows Application data in memory N M Several small I/O operation N elements Data is scattered in a file in M contiguous blocks September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 28 14

Sub-setting of contiguous dataset Extreme case: writing a column Application data in memory N M Several small I/O operation 1 element Subset data is scattered in a file in M different locations September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 29 Sub-setting of contiguous dataset Data sieve buffer Application data in memory N memcopy Data in a sieve buffer (64K) in memory M 1 element Data is scattered in a file September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 30 15

Performance tuning for contiguous dataset Datatype conversion Avoid for better performance Use H5Pset_buffer function to customize conversion buffer size Partial I/O Write/read in big contiguous blocks Use H5Pset_sieve_buf_size to improve performance for complex subsetting September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 31 I/O with Chunking September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 32 16

Chunked storage layout Raw data divided into equal sized blocks (chunks) Each chunk stored separately as a contiguous block in a file Datatype Dataspace Attributes Metadata cache Chunk index Dataset data A B C D Application memory header Chunk index A C D B September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 33 Information about chunking HDF5 library treats each chunk as atomic object Compression and other filters are applied to each chunk Datatype conversion is performed on each chunk Chunk size greatly affects performance Chunk overhead adds to file size Chunk processing involves many steps Chunk cache Caches chunks for better performance Size of chunk cache is set for file (default size 1MB) Each chunked dataset has its own chunk cache Chunk may be too big to fit into cache Memory may grow if application keeps opening datasets September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 34 17

Chunk cache Dataset_1 header Dataset_N header Metadata cache Chunking B-tree nodes Chunk cache Default size is 1MB Application memory September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 35 Writing chunked dataset Chunked dataset Chunk cache A C B C Filter pipeline B A. C Filters including compression are applied when chunk is evicted from cache September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 36 18

Partial I/O with Chunking September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 37 Partial I/O for chunked dataset 1 2 3 4 Example: write the green subset from the dataset, converting the data Dataset is stored as six chunks in the file. The subset spans four chunks, numbered 1-4 in the figure. Hence four chunks must be written to the file. But first, the four chunks must be read from the file, to preserve those parts of each chunk that are not to be overwritten. September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 38 19

Partial I/O for chunked dataset 1 2 3 4 For each of four chunks on writing: Read chunk from file into chunk cache, unless it s already there Determine which part of the chunk will be replaced by the selection Move those elements from application buffer to conversion buffer Perform conversion Replace that part of the chunk in the cache with the corresponding elements from the conversion buffer Apply filters (compression) when chunk is flushed from chunk cache For each element 3 (or more) memcopy operations are performed September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 39 Partial I/O for chunked dataset Application buffer Chunk cache 3 3 Chunk conversion buffer Application memory Elements participating in I/O are gathered into corresponding chunk after going through conversion buffer September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 40 20

Partial I/O for chunked dataset Chunk cache Application buffer 3 Conversion buffer Apply filters and write to file Application memory Chunk September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 41 Variable length data and I/O September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 42 21

String Examples of variable length data A[0] the first string we want to write A[N-1] the N-th string we want to write Each element is a record of variable-length A[0] (1,1,0,0,0,5,6,7,8,9) [length = 10] A[1] (0,0,110,2005) [length = 4]. A[N] (1,2,3,4,5,6,7,8,9,10,11,12,.,M) [length = M] September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 43 Variable length data in HDF5 Variable length description in HDF5 application typedef struct { size_t length; void *p; }hvl_t; Base type can be any HDF5 type H5Tvlen_create(base_type) ~ 20 bytes overhead for each element Data cannot be compressed September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 44 22

Variable length data storage in HDF5 Actual variable length data Dataset header Dataset with variable length elements Pointer into global heap September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 45 Variable length datasets and I/O When writing variable length data, elements in application buffer always go through conversion and are copied to the global heaps in a metadata cache before ending in a file Metadata cache Global heap Application buffer conversion buffer September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 46 23

There may be more than one global heap Raw VL data Raw VL data Conversion buffer Metadata cache Raw VL data On a write request, VL data goes through conversion and is written to a global heap; elements of the same dataset may be written to different heaps. September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 47 Variable length datasets and I/O September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 48 24

VL chunked dataset in a file Chunk B-tree Heaps with VL data Dataset chunks Dataset header September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 49 Writing chunked VL datasets Metadata cache B-tree nodes Application memory Dataset header Global heap Raw data Chunk cache Chunk Conversion cache buffer Filter pipeline VL chunked dataset with selected region September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 50 25

Hints for variable length data I/O Avoid closing/opening a file while writing VL datasets Global heap information is lost Global heaps may have unused space Avoid alternately writing different VL datasets Data from different datasets will go into to the same heap If maximum length of the record is known, consider using fixed-length records and compression September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 51 Questions? September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 52 26