33
CONFIDENTIAL INFORMATION Intrinsyc Software Android on eMMC Optimizing for Performance Tom Foy [email protected]

Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

CONFIDENTIAL INFORMATION

Intrinsyc Software

Android on eMMC

Optimizing for Performance

Tom Foy

[email protected]

Page 2: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

2 CONFIDENTIAL INFORMATION

What is eMMC?

Solid state storage device on MMC bus

Chip on PCB

NAND flash based

Page 3: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

3 CONFIDENTIAL INFORMATION

Why eMMC matters

Popular on embedded devices

Cheap

Flexible

Page 4: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

4 CONFIDENTIAL INFORMATION

eMMC characteristics

Fast read access

Fast read seek times

Acceptable sequential write performance

Poor random write performance

Page 5: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

CONFIDENTIAL INFORMATION

MMC

Micro-Controller

Slower NAND Flash

(Erase Blocks)

Slower NAND Flash

(Erase Blocks)

Slower NAND Flash

(Erase Blocks)

Slower NAND Flash

(Erase Blocks)

SRAM

Fast Cache Flash

MMC

Bus

Inside

Firmware

Page 6: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

6 CONFIDENTIAL INFORMATION

Inside the eMMC

NAND flash arranged in pages

Controller with temporary storage

Wear levelling

Free space management

Page 7: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

7 CONFIDENTIAL INFORMATION

Discard

eMMC TRIM command

Tells controller what is free

TRIM blocks on format

Page 8: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

8 CONFIDENTIAL INFORMATION

eMMC scenarios

Tablets with lots of DRAM

Smartphones

LCD-based eReaders

Electronic Paper (eInk) eReaders

LCD-based navigation devices

Industrial devices, Loggers

Page 9: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

9 CONFIDENTIAL INFORMATION

DRAM is good

Alleviates write performance issues

Improves read times even further

Reduces NAND wear

Page 10: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

10 CONFIDENTIAL INFORMATION

Areas

User space

Filesystem type

Filesystem layout

IO Scheduler

Block IO & Cache

MMC bus driver

EMMC

MMC/Block Device

Block Device

IO Scheduler

Filesystem Filesystem

SQLite DalvikVM Webkit

Page 11: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

11 CONFIDENTIAL INFORMATION

Android challenges

Vendors claim mostly sequential reads/writes

Content Providers

SQLite activity

Many sync writes from userspace

Page 12: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

12 CONFIDENTIAL INFORMATION

Boot

Fixed battery

Clean shut-down

Warm reboots

IO scheduler

Android system

Page 13: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

13 CONFIDENTIAL INFORMATION

Plenty of RAM allows large block cache

Low memory killer

Tune flushing thresholds

Cache is king!

Page 14: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

14 CONFIDENTIAL INFORMATION

Filesystems

Focus on write performance

Tests run using fsbench (3.0 kernel, OMAP3 aka Nook Color)

EXT4, BTRFS,NILFS2

Page 15: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

15 CONFIDENTIAL INFORMATION

Benchmarks

Page 16: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

16 CONFIDENTIAL INFORMATION

Page 17: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

17 CONFIDENTIAL INFORMATION

Page 18: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

18 CONFIDENTIAL INFORMATION

Page 19: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

19 CONFIDENTIAL INFORMATION

Page 20: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

20 CONFIDENTIAL INFORMATION

EXT4 - a write

Journal write (usually ~16K)

inode update (usually 4K)

Data goes into page cache

Page 21: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

21 CONFIDENTIAL INFORMATION

EXT4 w/o journal

Not too dangerous on embedded systems with battery

Good performance due to improved sequentiality

Page 22: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

22 CONFIDENTIAL INFORMATION

BTRFS

If not using a lot of fsync/fdatasync

Great large write performance

Terrible on small/mediun sync writes

Good performance on multiple writes

Page 23: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

23 CONFIDENTIAL INFORMATION

NILFS2

Consistent performance

Potentially much faster if eMMC part has fast sequential performance

Should theoretically be the fastest :-)

Page 24: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

24 CONFIDENTIAL INFORMATION

EXT4 with journal

If journaling is needed, consider RAM journal device

Again RAM journal not as dangerous as you think

Better than BTRFS on small/medium sync writes

Page 25: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

25 CONFIDENTIAL INFORMATION

I/O schedulers

CFQ, noop, deadline

Results are similar within ~10% range

QOS considerations are more important than throughput

Page 26: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

26 CONFIDENTIAL INFORMATION

User space

Avoid synchronization on files

Avoid sync/fsync/fdatasync/etc

Avoid small writes to files, better to buffer

Don’t be afraid to read, be afraid to write!

Page 27: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

27 CONFIDENTIAL INFORMATION

Conclusion

EXT4 (discard, ram/no journal) is probably your best bet

Try out a couple of configurations for the eMMC you are targeting

Avoid writes! :-)

Page 28: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

28 CONFIDENTIAL INFORMATION

Questions?

Page 29: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

29 CONFIDENTIAL INFORMATION CONFIDENTIAL INFORMATION

Appendix

Page 30: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

30 CONFIDENTIAL INFORMATION

EXT4 with RAM journal

Page 31: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

31 CONFIDENTIAL INFORMATION

Page 32: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

32 CONFIDENTIAL INFORMATION

Page 33: Intrinsyc Software Android on eMMC Optimizing for Performance · Android system . CONFIDENTIAL INFORMATION 13 Plenty of RAM allows large block cache Low memory killer Tune flushing

33 CONFIDENTIAL INFORMATION