37
Performance evaluation of Linux Discard Support (Overview, benchmark results, current status) Red Hat Luk´ s Czerner February 12, 2011

(Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Performance evaluation of Linux DiscardSupport(Overview, benchmark results, current status)

Red Hat

Lukas Czerner

February 12, 2011

Page 2: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Copyright © 2011 Lukas Czerner, Red Hat.Permission is granted to copy, distribute and/or modify thisdocument under the terms of the GNU Free DocumentationLicense, Version 1.3 or any later version published by the FreeSoftware Foundation; with no Invariant Sections, no Front-CoverTexts, and no Back-Cover Texts. A copy of the license is includedin the COPYING file.

Page 3: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Part I

Discard Background

Page 4: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Agenda

1 SSD Description

2 Thinly Provisioned Storage

3 Introducing Linux Discard Support

Page 5: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

SSD Description

Solid-State Drive

Flash memory block device

Wear-leveling needed

Firmware = black box

Page 6: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

SSD Description

ATA TRIM Command

Helps handle garbage collection overhead

Subsequent READ of TRIM’ed blocks

1 Read data should NOT change between READ’s2 Read data should NOT be retrieved from data previously

written to any other LBA.

As long as the device has enough free pages to write to we donot necessarily need it.

In a nutshell: TRIM command tells the device what LBA’a isnot used by the OS anymore.

Page 7: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Thinly Provisioned Storage

Thin Provisioning

Unlike in traditional storage, there is no fixed one-to-onelogical bock to physical storage mapping

More efficient use of storage space

Block reclamation interface needed

Page 8: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Thinly Provisioned Storage

SCSI UNMAP / WRITE SAME

Storage space reclamation interface

Subsequent READ of unmapped blocks

1 Read data should NOT change between READ’s2 Read data should NOT be retrieved from data previously

written to any other LBA.

Unlike with SSD’s we can not afford to wait until we run outof space for reclamation.

Page 9: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Introducing Linux Discard Support

Linux Discard Implementation

Abstraction for the two underlying specifications:

1 ATA TRIM Command2 SCSI UNMAP / WRITE SAME

API for user-space

BLKDISCARD ioctlAdded with v2.6.27-rc9-30-gd30a260

API for File Sytems

1 sb issue discard()2 blkdev issue discard()

Page 10: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Part II

Discard Performance

Page 11: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Agenda

4 Testing Methodology

5 Results

Page 12: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Testing Methodology

What do we need to find out ?

Does discard really work ? Is it reliable ?

How fast/slow is it ?

Is there any difference between devices from different vendors?

What is the ideal discard size ?

SSD performance degradation

Page 13: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Testing Methodology

How do we test it ?

BLKDISCARD ioctl()

Automatic discard of different ranges

Different discard patterns

1 sequential performance2 random IO peformance3 discard already discarded blocks

test-discard - discard benchmarking tool

http://sourceforge.net/projects/test-discard/

impression - filesystem aging tool

Page 14: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Results

Sequential discard performance

0

50

100

150

200

250

300

10 100 1000 0

200

400

600

800

1000

1200

Dur

atio

n [s

]

Thr

ough

put [

MB

/s]

Record size [kB]

Duration SummaryThroughput

Page 15: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Results

Different modes comparison

0

200

400

600

800

1000

1200

10 100 1000

Thr

ough

put [

MB

/s]

Record size [kB]

Throughput (sequential)Throughput (random IO)

Throughput (discard2)

Page 16: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Results

Difference between various vendors

0

200

400

600

800

1000

1200

10 100 1000

Thr

ough

put [

MB

/s]

Record size [kB]

Throughput Vendor 1Throughput Vendor 2Throughput Vendor 3

Page 17: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Results

SSD performance degradation

10

20

30

40

50

60

70

0 50 100 150 200 250 300 350 400

Writ

e pe

rfor

man

ce [M

B/s

]

Filesystem saturation [%]

Vendor1Vendor2Vendor3

Vendor3 discard

Page 18: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Part III

Discard Support for Linux File systems

Page 19: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Agenda

6 Periodic Discard

7 Discard Batching

8 Different Approach

Page 20: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Periodic Discard

Periodic discard

Easy to implement

File system support

1 ext4 (v2.6.27-5185-g8a0aba7)2 btrfs (since upstream)3 gfs2 (v2.6.29-9-gf15ab56)4 fat, swap, nilfs

mount -o discard /dev/sdc /mnt/test

TRIM is non-queueable command - implications ?

Page 21: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Periodic Discard

Benchmarking periodic discard

Expectations ?

Testing methodology

1 Metadata intensive load2 Load with removing files3 Reasonable file size distribution

Discard-kit

1 Using PostMark2 http://sourceforge.net/projects/test-discard/files/

Page 22: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Periodic Discard

Ext4 performance (18% hit)

100

200

300

400

500

600

700

800

nodiscard discard

Ope

tatio

n/s

Deleted/sAppend/s

Read/sFiles-created/sTransactions/s

Read[B/s]Write[B/s]

Page 23: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Periodic Discard

Performance with various file systems

350

400

450

500

550

600

650

700

750

nodiscard

discard

nodiscard

discard

nodiscard

discard

Tra

nsac

tions

/s

ext4

btrfs

gfs2

-63%-7%-18%

Page 24: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Discard Batching

Discard Batching - The idea

Fine-grained discard is not necessarily needed

Small extents are slow

With time, freed extents tends to coalesce

Disadvantages

1 There is a price for tracking freed extents2 Discarding already discarded blocks should be easy, but...3 Daemon (in-kernel, user-space) needed.4 File system independent solution would most likely be pain to

do right (if possible).

Page 25: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Discard Batching

Batched discard support

File system specific solution

Provide ioctl() interface - FITRIM

Do not disturb other ongoing IO too much

1 Prevent allocations while trimming2 How to handle huge filesystem ?

File system support

1 ext4 (v2.6.36-rc6-35-g7360d17)2 ext3 (v2.6.37-11-g9c52749)3 xfs (v2.6.37-rc4-63-ga46db60)

Page 26: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Discard Batching

FITRIM ioctl

Ioctl with one RW parameter defined in linux/fs.hstruct fstrim range {u64 start;u64 len;u64 minlen;

}fstrim tool

http://sourceforge.net/projects/fstrim/

util-linux-ng

Since v2.18-165-gd9e2d0d

Page 27: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Discard Batching

Batched discard benchmark results

0

1

2

3

4

5

6

0 20 40 60 80 100

Dur

atio

n [s

]

Filesystem saturation [%]

FITRIM on ext4BLKDISCARD

Page 28: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Different Approach

Alternative approach

It is always a compromise

The future of SSD’s and thinly provisioned LUN’s (???)

Page 29: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Part IV

Discard Support in user-space

Page 30: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Agenda

9 e2fsprogs

10 Other utilities

Page 31: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

e2fsprogs

Discard in e2fsprogs tools

Using BLKDISCARD ioctl()

mke2fs

1 Refresh SSD’s garbage collector2 discard zeroes data - significant speed boost3 mkfs.ext4 -E discard /dev/sdc

e2fsck

1 After the last check discard free space2 Non detected file system errors ? oops3 fsck.ext4 -E discard /dev/sdc

resize2fs

1 Refresh SSD’s garbage collector2 discard zeroes data - significant speed boost3 resize2fs -E discard /dev/sdc

Page 32: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

e2fsprogs

File system creation

0

5

10

15

20

25

30

EXT4 XFS

Dur

atio

n [s

]

File system

nodiscarddiscard

Page 33: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Other utilities

Fstrim tool

Very simple tool to invoke FITRIM ioctl on mounted filesystem

Stand-alone tool

http://sourceforge.net/projects/fstrim/

Since v2.18-165-gd9e2d0d part of util-linux-ng

Page 34: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Part V

Summary

Page 35: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Summary

Linux Discard support is a abstraction for underlyingspecification

Exported via BLKDISCARD ioctl to user-space andblkdev issue discard() for filesystems

Discard testing kit (Discard-kit)

1 test-discard2 PostMark

Filesystem support

1 Fine grained (online) discard - mount -o discard2 Batched discard support - fstrim from util-linux-ng

Support in user-space utilities

1 Filesystem creation (mkfs)2 e2fsprogs - mkfs,e2fsck,resize2fs3 xfsprogs - mkfs4 fstrim

Page 36: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

The end.Thanks for listening.

Page 37: (Overview, benchmark results, current status)people.redhat.com/lczerner/discard/files/Performance...3 mkfs.ext4 -E discard /dev/sdc e2fsck 1 After the last check discard free space

Useful links

http://sourceforge.net/projects/fstrim/

http://sourceforge.net/projects/test-discard/

http://people.redhat.com/lczerner/discard/