From nobody Tue Nov 26 21:12:33 2024 X-Original-To: standards@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 4XyZz527Qrz5f2C1 for ; Tue, 26 Nov 2024 21:12:33 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XyZz514HHz48vZ for ; Tue, 26 Nov 2024 21:12:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732655553; 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: in-reply-to:in-reply-to:references:references; bh=4neib4qRiBjsehWL35Eg2cVHxA6S568iTF5Niyra0GM=; b=IzKCN1juh91sDRYKmo8NQBB1XvIEWBUt9e+ayV8T5GQg1nfrLK9OdpiU2aL6zfFC7GKpET 2czgoq8UsDuS+fbibG7ID5Yv45OIOV3eTHvAfpzga34IskU76bG878quf3+BK/G0OUpVrk CeML3SyRcfTSiuO6s9BLVwBVcr0Wmim8QH7icGIPMRy02QqsKypzHSlLHbnkSTAhN53lTI mBIkxzwcZkmZn6Tu13+6/PeihkaVT+54emt0Jh+6CRicw+MXGX16PlMgGLB3v+cvHPKFtM /aKrMkTMzBj3MpJPSImtBZGDkZXT6V1Hx+6KSJ1MiUPEl0tFqlai61d1mbwJ7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732655553; a=rsa-sha256; cv=none; b=GNmRn+XaKlLyhwVQGL555SfyTbkxUHbywxtAOwRsZlEiz9rL/AC5/upMT7YP3hcVeVdQuI kDQi1de/iS5hqZrStOW7zVCbhninF/VefkfIXZbSE7JlXI6Yh6C/cgVTlloyerbab5u6ui rHS+wtP96Del30Wuxfi3w2qUcvU3v9bzmbU4osKJzom+Qt0hiYDlBUfZQuzHM9eICBYKjb c1t2e7BTqxSx9+p3GyQSXuTZMkyGmDMfWZRFbAzm0GHemw6pNXS/Te7nNWriRRBjWyoRBW yJQPmusPlO/3pDXjdmsxNpJEXfSWGRutKYi7RHL1qZRnSpHHgvstP3ZEt5oLzQ== 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 4XyZz50djCzhY6 for ; Tue, 26 Nov 2024 21:12:33 +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 4AQLCWrb005218 for ; Tue, 26 Nov 2024 21:12:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 4AQLCWTO005217 for standards@FreeBSD.org; Tue, 26 Nov 2024 21:12:32 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: standards@FreeBSD.org Subject: [Bug 275661] /usr/bin/dc really slow with a trivial calculation Date: Tue, 26 Nov 2024 21:12:33 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: se@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-standards@freebsd.org Sender: owner-freebsd-standards@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D275661 --- Comment #5 from Stefan E=C3=9Fer --- (In reply to Stefan E=C3=9Fer from comment #4) I have had some time to think about this issue, and improvements should be possible for some cases without loss of precision of the results. Error propagation allows to calculate the required number of digits in the fractional part of intermediate results. The following cases have to be distinguished: * base > 1 and positive exponent * base < 1 and positive exponent * base > 1 and negative exponent * base < 1 and negative exponent A base value < 1 with negative exponent requires very high precision of intermediate results: Consider a base value of 0.1 and a negative exponent "n", which should retu= rn 10^n for any scale >=3D 1 (i.e. at least 1 fractional digit). This requires intermediate results to be calculated with n fractional digits (e.g.: 0.1^-= 4 =3D 1/(0.1 ^4) =3D 1/0.0001 =3D 10^4). A possible optimization is to normalize the base value to have a leading di= git of 1..9 (i.e. multiply by a suitable power of 10; divide the result by that multiplicator^n to get the result using only the required precision of the result; multiplication by powers of 10 is a very efficient operation in this bc/dc implementation). The current implementation uses intermediate scale values (precision of the fractional part) that are proportional to the exponent, but this is not actually required for an exact result, if the above mentioned normalization= of the base value is applied. For the test cases with scale=3D16 and 1.0000001^(2^27) the intermediate results will have 16*2^27 fractional digi= ts ... I'll calculate the error propagation for the cases of positive and for nega= tive exponents (assuming a base value >=3D 1 after applying the above mentioned normalization). --=20 You are receiving this mail because: You are the assignee for the bug.=