From nobody Wed Jan 26 18:00:19 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F22AF197C40F for ; Wed, 26 Jan 2022 18:00:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JkWhz4qzgz3H9J for ; Wed, 26 Jan 2022 18:00:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 860D9272D4 for ; Wed, 26 Jan 2022 18:00:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 20QI0JMU069159 for ; Wed, 26 Jan 2022 18:00:19 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 20QI0JrS069158 for bugs@FreeBSD.org; Wed, 26 Jan 2022 18:00:19 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 261496] sort -S size documentation is wrong Date: Wed, 26 Jan 2022 18:00:19 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: wosch@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643220019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4yhH+RUHj/nO+wsf1LBqB2EjHZvc1Ig3ItGtPGZWVZI=; b=Z1mPn7y74RLI7USTBLECA4meA2GkBwqvWlSsq6sBFPeFxAVoIl3ml60KNFJSppQf1h9jQI GrTqe7SLvwB/RfxZju4DrD4lYLT9TOOsu8d84wou2kI0uhBTJ59/bD2C1k8aKB7R8fR6Bj gTV6mEv5IurcmNk25jXTZKpwRTcQ5xIKcYu/oAPn6cBLkEtBm4uHkgXG972eSn6t/+nNF0 p5IT0kpiTMP0jmDZoLTgEkrXEUaN34mPJCZuS0Y4FgNc0ZdYcCTqMNe/EJdjdss8/K8yv2 ifIK+yNRdSt0bSO4CbXVCTaHgfhsFslJc6Nwq2CHhGHhXpW0lznPPHddkRGZwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643220019; a=rsa-sha256; cv=none; b=XByX7x7yI8dN0+6JXA/kw3WND2E6gQ6/XXCiTrGl4B6lrQSqwQLOlq/+nmxj6BlebKEWgR dmTSSHbg29O6nmRfubFyeFGzLIQfY/cq54FLArjmOVqU2wir0oAJ/F+hL1RmTnSkVtqsOd 8Hconkj3r82VLBP/sPX8jlwF1Q2efUhRS042NzSv/as7TcOtheMVhyib2vmurKZKVz6H7q yATaOpbXxvasVRdtPhBLUDmBeUnz4rdwT/sewVk70zwXk/Bf01+1cAS+3g4ni+FA3Ay3pb Zy97KBf6SkA9KBAkgCttbQ1sgWAJWG+YAG03cR70MyUJkzEx1rc/eVgLW0KaLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D261496 Bug ID: 261496 Summary: sort -S size documentation is wrong Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: wosch@FreeBSD.org BSD sort has an option to configure the size of the memory buffer: =C2=A0 =C2=A0 =C2=A0-S size, --buffer-size=3Dsize =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Use size for the maximum si= ze of the memory buffer. =C2=A0Size =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0modifiers %,b,K,M,G,T,P,E,Z= ,Y can be used. =C2=A0If a memory limit is =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0not explicitly specified, s= ort takes up to about 90% of available =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memory. =C2=A0If the file s= ize is too big to fit into the memory =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0buffer, the temporary disk = files are used to perform the sorting. Looking at the source I see no reference to the default 90% except in the manual page. It appears that sort(1) use by default 50% of main memory, whi= ch is more reasonable for a server OS. $ sysctl hw.physmem hw.physmem: 68576686080 $ cat /dev/null =C2=A0| sort --debug Memory to be used for sorting: 34288343040 $ expr 34288343040 \* 2 68576686080 the 50% is apparently from =C2=A0free_memory / 2; sort.c: available_free_memory =3D free_memory / 2; However, this is not right for percentage modifiers. $ cat /dev/null =C2=A0| sort -S 100% --debug Memory to be used for sorting: 34288343040 so, 100% use only 32GB (50%) of main memory, and=20 cat /dev/null =C2=A0| sort -S 20% --debug=20 Memory to be used for sorting: 6857668608 use only 6.5GB (10%) of main memory. --=20 You are receiving this mail because: You are the assignee for the bug.=