From owner-freebsd-current@freebsd.org Thu Nov 26 09:46:48 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0BFD4A7086 for ; Thu, 26 Nov 2020 09:46:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChXw85x6Sz3kZB; Thu, 26 Nov 2020 09:46:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:470:7a58:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id A5243FCAC; Thu, 26 Nov 2020 09:46:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:470:7a58::ec74:5d3a:9570:54b5] (unknown [IPv6:2001:470:7a58:0:ec74:5d3a:9570:54b5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 9924843345; Thu, 26 Nov 2020 10:46:46 +0100 (CET) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_43784985-B155-4E1E-89DC-97D72CD098C5"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: possible usb3-connected hard drive spin down causing lag Date: Thu, 26 Nov 2020 10:46:36 +0100 In-Reply-To: Cc: freebsd-current@freebsd.org To: tech-lists References: X-Mailer: Apple Mail (2.3445.104.17) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 09:46:48 -0000 --Apple-Mail=_43784985-B155-4E1E-89DC-97D72CD098C5 Content-Type: multipart/mixed; boundary="Apple-Mail=_06AAB545-0BBB-49DD-B7E8-ECA0CB147400" --Apple-Mail=_06AAB545-0BBB-49DD-B7E8-ECA0CB147400 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 26 Nov 2020, at 01:10, tech-lists wrote: >=20 > I have a usb3-connected harddrive. dmesg shows this: > [...] > da0: Fixed Direct Access SPC-4 SCSI device > [...] >=20 > running current-r367806-arm64 >=20 > I think it might be auto-spinning-down or auto-sleeping. It's > making initial interaction lag of 2-3 seconds. Is there a sysctl or = something somewhere where I can tell it to never sleep? Or is that = something I'd need to contact the manufacturer about? Or is there an = alternative strategy like tmpfs. It's not a "green" drive but I guess it = might > be "green" in that it's usb3 powered. >=20 > I have vfs.read_max=3D128 in /etc/sysctl.conf > zdb has ashift=3D12 >=20 > In case it's relevant, the filesystem on the disk is zfs. Once > "woken up", inferaction is quick, as expected. > thanks, I have been using the attached rc.d script for a long time now, which uses camcontrol(8)'s "apm" and "aam" commands to set drives to 'maximum performance' (aka don't try to save power by shutting down all the time). Just drop this into /usr/local/etc/rc.d, and add something like the following to your rc.conf: camperf_devices=3D"da0 da1" camperf_enable=3D"YES" You can also manually start the rc.d script by running: sudo service camperf start -Dimitry --Apple-Mail=_06AAB545-0BBB-49DD-B7E8-ECA0CB147400 Content-Disposition: attachment; filename=camperf Content-Type: application/octet-stream; x-unix-mode=0755; name="camperf" Content-Transfer-Encoding: 7bit #!/bin/sh # PROVIDE: camperf # BEFORE: LOGIN # # Add the following lines to /etc/rc.conf to enable camperf: # # camperf_enable (bool): set to NO by default. # Set to YES to enable camperf. # camperf_devices: list of devices on which to run camperf # Example: # Set the disks da0 and da1 to max APM and AAM performance: # # camperf_devices="da0 da1" # . /etc/rc.subr name="camperf" rcvar=camperf_enable command=/sbin/camcontrol start_cmd=camperf_start load_rc_config $name : ${camperf_enable="NO"} camperf_start() { if [ -n "${camperf_devices}" ]; then for i in ${camperf_devices}; do echo "camperf: configuring device /dev/${i}" ${command} apm /dev/${i} -l 254 ${command} aam /dev/${i} -l 254 done fi } run_rc_command "$1" --Apple-Mail=_06AAB545-0BBB-49DD-B7E8-ECA0CB147400-- --Apple-Mail=_43784985-B155-4E1E-89DC-97D72CD098C5 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCX795fAAKCRCwXqMKLiCW o3mlAKC41pQgVpoxPhCCHpFLjj7YjiqbPQCfUP1tY1RcnqEeLwmU7XFAMw1cvTg= =pBI5 -----END PGP SIGNATURE----- --Apple-Mail=_43784985-B155-4E1E-89DC-97D72CD098C5--