# [Solve] Slow write transfers from disk to usb storage device

## jpnag

Hi,

I need help from you guys. 

I have noticed poor performance when transfering files from my disks to an USB pen drive. Basically the transfer starts at 8Mbytes/s but after transfering 160Mbytes, more or less, the transfer rate starts decreasing reaching less than 1Mbyte/s after 700-800Mbytes!! Yes an USB 2.0 controller is being used, but strangely it shares the same IRQ as my Audio or Video card!

Filtered output of lspci -v

```
/home/jpnag # lspci -v | grep -B2 IRQ

00:01.1 SMBus: nVidia Corporation MCP67 SMBus (rev a2)

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherbord

   Flags: 66MHz, fast devsel, IRQ 10

--

00:02.0 USB Controller: nVidia Corporation MCP67 OHCI USB 1.1 Controller (rev a2) (prog-if 10 [OHCI])

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherboard

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 23

--

00:02.1 USB Controller: nVidia Corporation MCP67 EHCI USB 2.0 Controller (rev a2) (prog-if 20 [EHCI])

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherboard

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 21

--

00:04.0 USB Controller: nVidia Corporation MCP67 OHCI USB 1.1 Controller (rev a2) (prog-if 10 [OHCI])

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherboard

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 22

--

00:04.1 USB Controller: nVidia Corporation MCP67 EHCI USB 2.0 Controller (rev a2) (prog-if 20 [EHCI])

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherboard

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 20

--

00:07.0 Audio device: nVidia Corporation MCP67 High Definition Audio (rev a1)

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherboard

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 21

--

00:09.0 IDE interface: nVidia Corporation MCP67 AHCI Controller (rev a2) (prog-if 85 [Master SecO PriO])

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherboard

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 23

--

00:0a.0 Ethernet controller: nVidia Corporation MCP67 Ethernet (rev a2)

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherbord

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 47

--

00:12.0 VGA compatible controller: nVidia Corporation C68 [GeForce 7050 PV / nForce 630a] (rev a2) (prog-if 00 [VGA controller])

   Subsystem: ASUSTeK Computer Inc. M2N68-AM Motherbord

   Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 20

```

This happens with other devices...

How can I fix this? Anyone was any ideas? (No control on BIOS that can help me solving this btw! Been there...)

Thanks and regards!

----------

## eccerr0r

For the most part IRQ sharing really doesn't mean much anymore.  Hardware is designed so that interrupt lines can be shared and interrupt handlers can deal with finding which device requested the interrupt.

What kind of data are you transferring, are they big files at first and then drop to little small ones when things slow down?  Are they all little small files (say, 32KB or less perhaps?)

What's the condition of the media?  Does this happen with USB connected hard drives?

[/code]

----------

## jpnag

I haven't tried with USB hard drives, I don't have one. In the test I have made I was using big data files - avi files - in most of the cases only one file involved. Small files could explain the problem but that's no it.

If sharing the same IRQ is not an issue I'll change the post subject and wait for someone's idea, because I don't have one. Everything seems to be ok on the SW side but it's not likely to be an HW issue since the problem only show up after a while.

More data, hdparm reports the following:

```
/dev/sdb1:

 Timing cached reads:   2492 MB in  2.00 seconds = 1246.17 MB/sec

 Timing buffered disk reads:  22 MB in  3.01 seconds =   7.30 MB/sec

```

and found out that the problem only show up on write operations!

Thanks!

----------

## Hu

USB sticks tend to have very poor write throughput rates, relative to other modern storage.  The kernel can hide this for a short period of time by allowing the data to accumulate in kernel buffers.  Eventually, the kernel buffers reach the point that they must be flushed.  When this happens, your apparent throughput will slow to the actual throughput.

----------

## jpnag

Ok, so I'll assume there is no issue with my system configuration - closing the thread!

Thanks a lot for your inputs!

----------

## HeissFuss

You may also be able to improve throughput if your flash drive's partition isn't aligned.  You can check it with 'fdisk -l /dev/sdb'.  If it's not aligned, you'll need to recreate the partition to fix it.

In general though, a lot of usb drives are quite slow with writes.

----------

