Buffered FUSE: Optimising the Android IO Stack for User-Level Filesystem
Total Page:16
File Type:pdf, Size:1020Kb
Int. J. Embedded Systems, Vol. 6, Nos. 2/3, 2014 95 Buffered FUSE: optimising the Android IO stack for user-level filesystem Sooman Jeong and Youjip Won* Hanyang University, #507-2, Annex of Engineering Center, 17 Haengdang-dong, Sungdong-gu, Seoul, 133-791, South Korea E-mail: [email protected] E-mail: [email protected] *Corresponding author Abstract: In this work, we optimise the Android IO stack for user-level filesystem. Android imposes user-level filesystem over native filesystem partition to provide flexibility in managing the internal storage space and to maintain host compatibility. The overhead of user-level filesystem is prohibitively large and the native storage bandwidth is significantly under-utilised. We overhauled the FUSE layer in the Android platform and propose buffered FUSE (bFUSE) to address the overhead of user-level filesystem. The key technical ingredients of buffered FUSE are: 1) extended FUSE IO size; 2) internal user-level write buffer; 3) independent management thread which performs time-driven FUSE buffer synchronisation. With buffered FUSE, we examined the performances of five different filesystems and three disk scheduling algorithms in a combinatorial manner. With bFUSE on XFS filesystem using the deadline scheduling, we achieved the IO performance improvements of 470% and 419% in Android ICS and JB, respectively, over the existing smartphone device. Keywords: Android; storage; user-level filesystem; FUSE; write buffer; embedded systems. Reference to this paper should be made as follows: Jeong, S. and Won, Y. (2014) ‘Buffered FUSE: optimising the Android IO stack for user-level filesystem’, Int. J. Embedded Systems, Vol. 6, Nos. 2/3, pp.95–107. Biographical notes: Sooman Jeong received his BS degrees in Computer Science from Hanyang University, Seoul, Korea, in 2003. He worked for Samsung Electronics as a Software Engineer. He is currently working toward his MS degree in the Department of Computer Science, Hanyang University, Seoul, Korea. His research interests include optimising I/O stack of smartphones. Youjip Won received his BS and MS degrees in Computer Science from the Seoul National University, Korea, in 1990 and 1992, respectively. He received his PhD in Computer Science from the University of Minnesota, Minneapolis, in 1997. After receiving his PhD degree, he joined Intel as a Server Performance Analyst. Since 1999, he has been with the Department of Computer Science, Hanyang University, Seoul, Korea, as a Professor. His research interests include operating systems, file and storage subsystems, multimedia networking, and network traffic modelling and analysis. 1 Introduction An Android-based device is no longer a simple media player but has become a professional content creator. Smart devices have rapidly spread to the public and One piece of clear evidence for this trend is a recent expanded their territory into all home electronics including introduction of an Android-based digital camera with a high phones, TVs, cameras, and game consoles. As they have resolution sensor (up to 17 mega-pixels) (Galaxy Camera, become so closely related to our everyday lives, improving http://www.samsung.com/us/photography/galaxy-camera). the performance of these smart devices will have a In the future, smart devices including phones, TVs, and significant impact on society. A recent study on Android cameras are projected to acquire and play movies at smartphones suggests that storage is the biggest ultra-HD (3,840 × 2,160 @ 60 frames/sec) resolution. performance bottleneck (Kim et al., 2012a). Copyright © 2014 Inderscience Enterprises Ltd. 96 S. Jeong and Y. Won Android apps will require more IO bandwidth to handle We examined the behaviour of FUSE, native filesystem, such high definition multimedia contents. buffer cache, and IO scheduler for user partition accesses The Android platform partitions its storage into multiple and found that FUSE layer is the dominant source of logical partitions. There are two main storage partitions in overhead. FUSE entails significant overhead mostly due to the Android: data and sdcard. Data partition (/data) is used the following three reasons: to harbour text files, e.g., SQLite database tables, and sdcard 1 command fragmentation partition (/sdcard) harbours multimedia files, e.g., pictures, mp3 files and video clips. In recent smartphones, 2 excessive context switch both of these partitions share the same storage device. 3 loss of access correlation. Android storage has gone through several generations of evolution. In the early models, as the partition names We propose buffered FUSE (bFUSE) framework, which suggest, data partition was at internal NAND storage device effectively addresses the above mentioned three technical (eMMC) and sdcard partition was at external sdcard (HTC issues. bFUSE framework consists of: Dream, http://en.wikipedia.org/wiki/HTC_Dream). In the 1 extended FUSE IO unit later generation of Android-based smartphones (Samsung Galaxy S2, http://www.samsung.com/global/microsite/ 2 FUSE buffer managed by independent thread galaxys2/html/), data partition and sdcard partition resided 3 time driven FUSE buffer synchronisation. at the same physical device, internal NAND-based storage and each was allocated a ‘fixed’ size logical partition. Until The Android IO stack consists of FUSE, native filesystem this generation, the Android IO stack imposed EXT4 (EXT4), IO scheduler for block device (CFQ), and (Mathur et al., 2007) over data partition and VFAT underlying eMMC storage. We focus on finding the optimal (Microsoft Corporation, 2000) filesystem over sdcard combination in the IO stack design choices. We examined partition. VFAT filesystem is de facto standard in embedded the behaviour of five filesystems (EXT4, XFS, F2FS, multimedia devices, e.g., cameras, camcorders, TVs, etc. BTRFS, and NILFS2) and three IO schedulers provided by Therefore, for PC compatibility, it is mandatory that sdcard standard Linux kernel (CFQ, deadline, and NOOP) in a partition adopts VFAT filesystem despite its technical combinatorial manner. By using bFUSE and deadline-based deficiencies (Lim et al., 2013). However, this fixed IO scheduler and changing the filesystem to XFS, the IO partition-based storage configuration causes a significant performance (storage throughput) increases by 470% over underutilisation of the storage space. the baseline (existing smartphone). With this optimisation, Recent Android platform imposes user-level filesystem we are able to achieve 38 Mbyte/sec sequential write (FUSE) for sdcard partition instead of VFAT. This allows bandwidth and utilise 99% of the raw device bandwidth in sdcard to freely manoeuvre between the two respective the Android storage stack. partitions. The FUSE filesystem exists as a virtual The remainder of this paper is organised as follows. filesystem layer on top of EXT4, the native filesystem. Section 2 presents the background. The behaviour of the While this configuration provides flexibility in managing Android IO stack is analysed in Section 3. bFUSE is the internal storage space, it causes significant overhead on introduced in Section 4. Section 5 provides optimisations the FUSE, decreasing the performance of IO accesses to for the Android IO stack. Section 6 presents the results of user partition. For example, in Galaxy S3, sequential write our integration of the proposed schemes. Section 7 describes performance in FUSE imposed filesystem is one fourths of other works related to the study, and Section 8 concludes that in native EXT4 filesystem partition. this paper. The IO access to the Android storage can be categorised into two types: data partition accesses and sdcard partition accesses. While the IO accesses to both partitions suffer 2 Background from excessive overhead, the source of inefficiency differs vastly. For data partition accesses, majority of IOs are 2.1 Storage partitions for android-based created by SQLite operation and the inefficiency lies in the smartphones excessive filesystem journaling (Lee and Won, 2012; Jeong Android manages several filesystem partitions: /recovery, et al., 2013b). In this work, we focus on optimising the /boot, /cache, /system, /data and /sdcard. The Android IO stack for handling multimedia files. Sdcard /system partition contains Android-executable files and partition is the default storage partition for mp3, video files, pre-installed applications. The /cache partition is used for photographs, and user-downloaded documents, e.g., pdf updating firmware. The /boot and /recovery partitions files. We found that the IO accesses to sdcard partition are used for maintaining boot image. There are two types of suffer from significant overhead and the apps utilise only main partition: ‘/data’ and ‘/sdcard’. /data partition 25% of the raw NAND storage bandwidth. Buffered FUSE: optimising the Android IO stack for user-level filesystem 97 harbours SQLite tables, SQLite journals, and apps. /sdcard and user partitions are formatted with different filesystems, partition usually harbours pictures, video clips, and mp3 EXT4 and VFAT, respectively. Recently, the Android files, which are mostly user created contents. We call adopted FUSE to manage both data and user partitions /sdcard an ‘sdcard partition’ or a ‘user partition’. at the same physical partition (Google Galaxy Nexus, Typical accesses to the data partition (/data) and the http://www.google.com/nexus/4; Samsung Galaxy S3, user partition (/sdcard) are small (4 Kbyte) synchronous http://www.samsung.com/ae/microsite/galaxys3/en/