Dan*_*anB 5 performance hard-drive
在我的计算机上,双启动 Ubuntu 12.04 LTS(内核 3.5)和 Windows 7,硬盘驱动器速度在 Windows 上非常快,但在 Ubuntu 上非常慢。当我在 13.04(内核 3.8)和预发布 13.10(内核 3.11)的 Ubuntu Live CD 上启动时,速度仍然很慢。但是,当我在 Knoppix(内核 3.9)上启动时,缓慢消失了!
有谁知道为什么,或者如何在 Ubuntu 中修复它?
以下是使用完全相同硬件的速度:
内部和外部驱动器都会出现速度缓慢的情况:内部 SSD RAID(3ware 9750-4i 卡)、内部 Western Digital Red(不在 RAID 卡上)以及使用 USB 3.0、Firewire 和 eSATA 的外部驱动器。
这台计算机本身有一个非常快的 6 核 CPU 和 32 GB 内存,因此计算机性能不是问题。这是一台全新的计算机,因此可能配置错误。
花絮:最初,我认为问题仅限于 USB 3.0,我的供应商 (endpcnoise.com) 猜测我电脑上的 ASmedia 芯片组是罪魁祸首,因为 Ubuntu 对它的支持“充其量只是基本的”。
一些时间信息:从系统中的任何磁盘复制 20 MB 文件需要 15 秒。这是 Ubuntu 13.04 Live CD 上的 SSD RAID:
$ time cp bigfile bigfile2
real 0m14.866s
user 0m0.000s
sys 0m0.056s
Run Code Online (Sandbox Code Playgroud)
当我启动到 Knoppix 时,问题完全消失了:
$ time cp bigfile bigfile2
real 0m0.034s
user 0m0.000s
sys 0m0.013s
Run Code Online (Sandbox Code Playgroud)
当我在这样的副本之前和之后运行 dmesg /var/log/syslog 时,不会写入额外的消息。(请参阅完整的 dmesg 输出。)但我确实看到了一些与正在测试的 SSD 相关的消息:
...
[ 0.882760] LSI 3ware SAS/SATA-RAID Controller device driver for
Linux v3.26.02.000.
[ 0.883566] ahci 0000:00:1f.2: version 3.0
[ 0.883643] ahci 0000:00:1f.2: irq 80 for MSI/MSI-X
[ 0.889807] e1000e: Intel(R) PRO/1000 Network Driver - 2.0.0-k
[ 0.889809] e1000e: Copyright(c) 1999 - 2012 Intel Corporation.
[ 0.891377] xor: automatically using best checksumming function:
[ 0.899068] ahci 0000:00:1f.2: AHCI 0001.0300 32 slots 6 ports 6 Gbps
0x31 impl SATA mode
[ 0.899071] ahci 0000:00:1f.2: flags: 64bit ncq sntf pm led clo pio
slum part ems apst
[ 0.899074] ahci 0000:00:1f.2: setting latency timer to 64
...
[ 1.234773] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 1.234785] ata7: SATA link down (SStatus 0 SControl 300)
[ 1.234802] ata6: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 1.234820] ata5: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
...
[ 1.990817] sd 0:0:0:0: Attached scsi generic sg3 type 0
[ 1.990833] sd 0:0:0:0: [sdb] 1874978816 512-byte logical blocks: (959 GB/894 GiB)
[ 1.993034] sd 0:0:0:0: [sdb] Write Protect is off
[ 1.993036] sd 0:0:0:0: [sdb] Mode Sense: 23 00 10 00
[ 1.993158] sd 0:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 1.995812] sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 >
[ 2.000255] sd 0:0:0:0: [sdb] Attached SCSI disk
[ 2.292132] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
...
[ 9.428287] 3w-sas: scsi0: ERROR: (0x03:0x0101): Invalid command opcode:opcode=0x85.
Run Code Online (Sandbox Code Playgroud)
最后一行解释here。
这是否指向根本原因?
hdparm 在 Ubuntu 12.04 和 Knoppix 上报告相同的结果,除了 -Q (queue_depth),但在 Ubuntu 上更改它没有明显效果:
$ sudo hdparm -acdgkmurABCMNQW /dev/sda
/dev/sda:
multcount = 16 (on)
IO_support = 1 (32-bit)
readonly = 0 (off)
readahead = 256 (on)
geometry = 364801/255/63, sectors = 5860533168, start = 0
look-ahead = 1 (on)
APM_level = not supported
drive state is: active/idle
acoustic = not supported
max sectors = 5860533168/5860533168, HPA is disabled
queue_depth = 31 (Knoppix had value = 1, but changing on Ubuntu didn't help)
write-caching = 1 (on)
Run Code Online (Sandbox Code Playgroud)
这是lshw:
$ sudo lshw -c bus
*-core
description: Motherboard
product: P9X79
vendor: ASUSTeK COMPUTER INC.
physical id: 0
version: Rev 1.xx
serial: 130410781200420
slot: To be filled by O.E.M.
*-usb:0
description: USB controller
product: X79 series chipset USB2 Enhanced Host Controller #2
vendor: Intel Corporation
physical id: 1a
bus info: pci@0000:00:1a.0
version: 06
width: 32 bits
clock: 33MHz
capabilities: pm debug ehci bus_master cap_list
configuration: driver=ehci_hcd latency=0
resources: irq:23 memory:fb627000-fb6273ff
*-usb
description: USB controller
product: ASM1042 SuperSpeed USB Host Controller
vendor: ASMedia Technology Inc.
physical id: 0
bus info: pci@0000:06:00.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: msi msix pm pciexpress xhci bus_master cap_list
configuration: driver=xhci_hcd latency=0
resources: irq:17 memory:fb400000-fb407fff
*-usb
description: USB controller
product: ASM1042 SuperSpeed USB Host Controller
vendor: ASMedia Technology Inc.
physical id: 0
bus info: pci@0000:07:00.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: msi msix pm pciexpress xhci bus_master cap_list
configuration: driver=xhci_hcd latency=0
resources: irq:19 memory:fb300000-fb307fff
*-firewire
description: FireWire (IEEE 1394)
product: VT6315 Series Firewire Controller
vendor: VIA Technologies, Inc.
physical id: 0
bus info: pci@0000:09:00.0
version: 01
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress ohci bus_master cap_list
configuration: driver=firewire_ohci latency=0
resources: irq:17 memory:fb100000-fb1007ff ioport:b000(size=256)
*-usb:1
description: USB controller
product: X79 series chipset USB2 Enhanced Host Controller #1
vendor: Intel Corporation
physical id: 1d
bus info: pci@0000:00:1d.0
version: 06
width: 32 bits
clock: 33MHz
capabilities: pm debug ehci bus_master cap_list
configuration: driver=ehci_hcd latency=0
resources: irq:23 memory:fb626000-fb6263ff
*-serial UNCLAIMED
description: SMBus
product: X79 series chipset SMBus Host Controller
vendor: Intel Corporation
physical id: 1f.3
bus info: pci@0000:00:1f.3
version: 06
width: 64 bits
clock: 33MHz
configuration: latency=0
resources: memory:fb624000-fb6240ff ioport:f000(size=32)
Run Code Online (Sandbox Code Playgroud)
我从当前的 32 位 PAE 内核切换到 64 位内核。磁盘写入速度现在很快。这是 Ubuntu 13.04 的情况。
这个故事的寓意是:如果您有 4GB 以上的 RAM,请使用 64 位 Linux。即使PAE内核可以工作,它也可能存在这样的问题。