# dm-crypt performance on SSD RAID0

## mbar

I have a laptop with Core i7 and two 256GB SSD drives (Samsung PM800 and Liteon with Sandforce controller -- somewhat higher performance than PM800). For quite a long time I used encrypted /home partition on single SSD (and even earlier on rotational HDD) and the loss of file transfer speed was of little concern for me until today  :Smile: 

Today I compared encrypted / non-ecrypted block device raw speeds:

```
gen2-dell ~ # hdparm -tT /dev/md1

/dev/md1:

 Timing cached reads:   15372 MB in  2.00 seconds = 7693.19 MB/sec

 Timing buffered disk reads: 1304 MB in  3.00 seconds = 434.35 MB/sec

gen2-dell ~ # hdparm -tT /dev/mapper/home

/dev/mapper/home:

 Timing cached reads:   16638 MB in  2.00 seconds = 8327.04 MB/sec

 Timing buffered disk reads: 376 MB in  3.01 seconds = 124.82 MB/sec
```

During the test I noticed that only one i7 core is used during the transfer, though I have "Parallel crypto engine" and "Software async crypto daemon" kernel options enabed. Unfortunately my i7 does not have AES-NI instructions.

I use AES-XTS encryption with 256 bits key size (I think it's divided 128/128 bits for AES/XTS). 

Is there anything I could try to increase raw transfer speed of dm-crypt device?

Does any of you have processor with AES-NI instructions and is willing to share AES-NI disabled/enabled benchmarks for dm-crypt?

----------

## frostschutz

hdparm is not a benchmark. See what happens if you have multiple processes doing reads and writes in parallel. The alternative is using separate encrypted devices (even partitions) and putting it back together with LVM. But even then only with multiple separate processes doing read/write on separate partitions will you see more than one CPU core used for encryption.

 *Quote:*   

> Unfortunately my i7 does not have AES-NI instructions.

 

Don't expect performance then. Without AES-NI, 124MB/s as shown by dd is already a very good value.

----------

## mbar

 *frostschutz wrote:*   

> hdparm is not a benchmark.

 

Yep, I know, that's why I'm talking about raw speed. But of course:

 *frostschutz wrote:*   

> See what happens if you have multiple processes doing reads and writes in parallel. The alternative is using separate encrypted devices (even partitions) and putting it back together with LVM.

 

Definately worth trying, will do. But I think I'll encrypt /dev/sdaX and /dev/sdaY with two keys and then I'll combine them via /dev/mapper/abcd into /dev/mdX and I'll put /home on top of that /dev/mdX. I would like to avoid LVM this time.

 *frostschutz wrote:*   

> But even then only with multiple separate processes doing read/write on separate partitions will you see more than one CPU core used for encryption.

 

And what about "DM-CRYPT: Scale to multiple CPUs" patch? I lost it from my radar some time ago. Was it finally merged? EDIT: Yep, It was merged in 2.6.38.

 *frostschutz wrote:*   

>  *Quote:*   Unfortunately my i7 does not have AES-NI instructions. 
> 
> Don't expect performance then. Without AES-NI, 124MB/s as shown by dd is already a very good value.

 

I was afraid so  :Smile: 

----------

## mbar

 *mbar wrote:*   

> Definately worth trying, will do. But I think I'll encrypt /dev/sdaX and /dev/sdaY with two keys and then I'll combine them via /dev/mapper/abcd into /dev/mdX and I'll put /home on top of that /dev/mdX. I would like to avoid LVM this time.

 

This didn't help at all:

```
gen2-dell ~ # hdparm -tT /dev/sda6

/dev/sda6:

 Timing cached reads:   16168 MB in  2.00 seconds = 8091.50 MB/sec

 Timing buffered disk reads: 814 MB in  3.00 seconds = 271.30 MB/sec

gen2-dell ~ # hdparm -tT /dev/mapper/sda6

/dev/mapper/sda6:

 Timing cached reads:   16194 MB in  2.00 seconds = 8104.91 MB/sec

 Timing buffered disk reads: 386 MB in  3.01 seconds = 128.11 MB/sec

gen2-dell ~ # hdparm -tT /dev/sdb6

/dev/sdb6:

 Timing cached reads:   16628 MB in  2.00 seconds = 8322.16 MB/sec

 Timing buffered disk reads: 668 MB in  3.01 seconds = 222.09 MB/sec

gen2-dell ~ # hdparm -tT /dev/mapper/sdb6

/dev/mapper/sdb6:

 Timing cached reads:   16426 MB in  2.00 seconds = 8220.76 MB/sec

 Timing buffered disk reads: 368 MB in  3.00 seconds = 122.53 MB/sec

gen2-dell ~ # hdparm -tT /dev/md2

/dev/md2:

 Timing cached reads:   16124 MB in  2.00 seconds = 8069.56 MB/sec

 Timing buffered disk reads: 358 MB in  3.00 seconds = 119.17 MB/sec
```

md2 is created of /dev/mapper/sda6 and /dev/mapper/sdb6.

Oh well  :Smile: 

----------

