[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/002 9433c8e 65/65: Discuss timing, and philo
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/002 9433c8e 65/65: Discuss timing, and philosophical and political questions |
Date: |
Wed, 16 Sep 2020 16:55:23 -0400 (EDT) |
branch: valyuta/002
commit 9433c8e2958a4bcf2cce3e9bc6fe5763b556e0cf
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Discuss timing, and philosophical and political questions
---
README.branch.patch | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 120 insertions(+)
diff --git a/README.branch.patch b/README.branch.patch
index b3605ad..7f89afa 100644
--- a/README.branch.patch
+++ b/README.branch.patch
@@ -1,3 +1,123 @@
+Final timings as of 2020-09-16:
+
+32-bit valyuta/002 commit d124022d
+ naic, no solve : 1.025e-01 s mean; 102020 us least of 10 runs
+ naic, specamt solve : 1.796e-01 s mean; 179040 us least of 6 runs
+ naic, ee prem solve : 1.787e-01 s mean; 162828 us least of 6 runs
+ finra, no solve : 2.663e-02 s mean; 26256 us least of 38 runs
+ finra, specamt solve: 9.554e-02 s mean; 94678 us least of 11 runs
+ finra, ee prem solve: 8.758e-02 s mean; 86966 us least of 12 runs
+
+64-bit valyuta/002 commit d124022d
+ naic, no solve : 3.514e-02 s mean; 34749 us least of 29 runs
+ naic, specamt solve : 5.748e-02 s mean; 56785 us least of 18 runs
+ naic, ee prem solve : 5.316e-02 s mean; 52317 us least of 19 runs
+ finra, no solve : 1.500e-02 s mean; 14669 us least of 67 runs
+ finra, specamt solve: 3.501e-02 s mean; 34537 us least of 29 runs
+ finra, ee prem solve: 3.414e-02 s mean; 32419 us least of 30 runs
+
+32-bit origin/master commit 3023433f
+
+ naic, no solve : 5.199e-02 s mean; 51227 us least of 20 runs
+ naic, specamt solve : 9.311e-02 s mean; 92312 us least of 11 runs
+ naic, ee prem solve : 8.570e-02 s mean; 84947 us least of 12 runs
+ finra, no solve : 2.110e-02 s mean; 20654 us least of 48 runs
+ finra, specamt solve: 5.881e-02 s mean; 58151 us least of 18 runs
+ finra, ee prem solve: 5.471e-02 s mean; 54206 us least of 19 runs
+
+64-bit origin/master commit 3023433f
+ naic, no solve : 2.502e-02 s mean; 24783 us least of 40 runs
+ naic, specamt solve : 4.071e-02 s mean; 40252 us least of 25 runs
+ naic, ee prem solve : 3.776e-02 s mean; 37410 us least of 27 runs
+ finra, no solve : 1.323e-02 s mean; 13009 us least of 76 runs
+ finra, specamt solve: 2.796e-02 s mean; 27122 us least of 36 runs
+ finra, ee prem solve: 2.669e-02 s mean; 26127 us least of 38 runs
+
+tabulating more compactly:
+
+ valyuta, master, ratio: 32 bit
+
+ 102020 51227 1.99 [scenarios in same order as above]
+ 179040 92312 1.94
+ 162828 84947 1.92
+ 26256 20654 1.27
+ 94678 58151 1.63
+ 86966 54206 1.60
+
+ valyuta, master, ratio: 64 bit
+ 34749 24783 1.40
+ 56785 40252 1.41
+ 52317 37410 1.40
+ 14669 13009 1.13
+ 34537 27122 1.27
+ 32419 26127 1.24
+
+The first three rows of each set of six are the most important, because
+they are the most solve-heavy.
+
+At first, it seemed that the solve-free fourth scenario might represent
+the true system speed, and that the other five scenarios demonstrated
+some unexplained penalty for solves, which we might have hoped to reduce
+or eliminate. However, the immediately-preceding commit showed that hope
+to be forlorn: to within the expected representation error for formatted
+numbers such as
+ iteration 17 iterand 1879003 value 136.140000000828877091 vs.
+ iteration 17 iterand 1879003 value 136.139999999999986358
+the traces of each solve iteration are identical. In reality, therefore,
+producing an illustration means
+ do_lots_of_setup(based_on_input)
+ for each basis in {current, guaranteed, midpoint} (e.g.)
+ call RunOneCell()
+ do_lots_of_output()
+while solves just invoke RunOneCell() iteratively, so the fourth
+scenario above measures the ratio of
+ one-time setup and output, plus about three calls to RunOneCell()
+while the second and third compare
+ one-time setup and output, plus about fifty calls to RunOneCell()
+The conclusion is that using the currency class imposes a speed
+penalty in the code that uses it (i.e., RunOneCell()) of about one
+hundred percent for 32- and forty percent for 64-bit builds.
+
+The reason is that lmi quantities are mostly integer-valued, but they're
+heavily dependent on floating-point calculations--for example:
+ monthly_interest_factor const = (1.04)^(1/12) - 1
+ old_value = $1,234.56
+ new_value = old_value + round_to_cents(old_value * monthly_interest_factor)
+At least in the present experimental branch, this is realized as if by:
+ double floating_old_value = static_cast<double>(100.0 * old_value)
+ double floating_increment = floating_old_value * monthly_interest_factor
+ new_value += round_to_cents(floating_increment / 100.0)
+It's certainly possible to rewrite the code to avoid multiplying and
+dividing by 100.0 repeatedly, although the effort would be considerable.
+But it is not possible to maintain values as integer and never transform
+them to floating-point and back--so, if such transformations are inherently
+very costly, then there's no way to avoid a penalty.
+
+OTOH, instead of an integer type like std::int64_t, we might use scaled,
+integer-valued doubles--e.g., instead of the problematic
+ double old_value = 1234.56; // actually 1234.55999999xyz
+we could store
+ double old_value = 123456; // exactly 123456.0000000000000000
+
+If we're going to use a currency class, we should make the switch before
+this branch rots. Taking the third scenario above as representative:
+ valyuta, master
+ 162828 84947 32 bit
+ 52317 37410 64 bit
+we can't go from 84947 us to 162828 us directly, because end users would
+not view that favorably. But we could go from 84947 to 52317 (releasing
+a currency-based 64-bit build to replace 32-bit master), and then make
+incremental improvements at our leisure. However, it's hard to tell
+whether the 'currency' penalty can be made close to zero, or possibly
+negative; if it can't, then is a currency class worth the bother? Pros:
+ - currency is natural in the problem domain
+ - it avoids some nasty catastrophic-cancellation issues
+Cons:
+ - it makes the code less clear
+ - it imposes a performance penalty that may turn out to be inherent
+
+//
+
64-bit valyuta/002 commit 49f84a1e
naic, no solve : 3.517e-02 s mean; 34812 us least of 29 runs
naic, specamt solve : 5.662e-02 s mean; 55880 us least of 18 runs
- [lmi-commits] [lmi] valyuta/002 9da6616 55/65: Round explicitly in a few more cases, (continued)
- [lmi-commits] [lmi] valyuta/002 9da6616 55/65: Round explicitly in a few more cases, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 0e8c429 12/65: rounding, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 794727e 22/65: Round when converting from double to currency, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 d137177 02/65: Currency, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 ba6a8d1 31/65: implement currency comparisons as free functions, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 28a5e54 39/65: make data_type public, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 e9f5447 30/65: round currency to currency? huh?, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 90773f3 47/65: currency() rather than currency(0.0), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 5f00c5a 43/65: Add a commented-out idea, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 2dabfcf 62/65: Try to make something a little less arcane, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9433c8e 65/65: Discuss timing, and philosophical and political questions,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/002 9bee994 19/65: use currency type, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 0bf83a4 18/65: augment, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 615a24c 48/65: round.c(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9a4b91d 51/65: Speed measurements, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 49f84a1 60/65: Don't convert type with operator=(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9a9665c 58/65: Record some speed improvements, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 ce34d89 04/65: improve, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 8331a5c 07/65: avoid catastrophic cancellation, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 0856081 20/65: improve currency, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 3d03e4a 41/65: fix typo, Greg Chicares, 2020/09/16