Skip to content

Instantly share code, notes, and snippets.

@uucidl
Last active March 3, 2017 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uucidl/1437dbdad3e9b6ecd68c59b277c69353 to your computer and use it in GitHub Desktop.
Save uucidl/1437dbdad3e9b6ecd68c59b277c69353 to your computer and use it in GitHub Desktop.
grain-ratio.cpp
// @url: https://www.cs.utexas.edu/~EWD/transcriptions/EWD03xx/EWD340.html
// @url: https://www.cs.utexas.edu/~EWD/transcriptions/EWD03xx/EWD361.html
// @quote{
// For besides the need of precision and explicitness, the programmer is faced with a problem of size
// that seems unique to the programmer profession. When dealing with "mastered complexity", the idea
// of a hierarchy seems to be a key concept. But the notion of a hierarchy implies that what at one
// level is regarded as an unanalyzed unit, is regarded as a composite object at the next lower lever
// of greater detail, for which the appropriate grain (say, of time or space) is an order of magnitude
// smaller than the corresponding grain appropriate at the next higher level. As a result the number
// of levels that can meaningfully be distinguished in a hierarchical composition is kind of
// proportional to the logarithm of the ratio between the largest and the smallest grain. In programming,
// where the total computation may take an hour, while the smallest time grain is in the order of a
// microsecond, we have an environment in which this ratio can easily exceed 10^9 and I know of no
// other environment in which a single technology has to encompass so wide a span.
// }
//
// @url: https://twitter.com/mmalex/status/837630429960290305
// @quote{
// I guess this also applies for data too; petabyte bigdata db engineers care about
// bitpacking. thats 8*10^15 ~ 10^16
// }
#include <cmath>
#include <cstdio>
int main(int argc, char** argv)
{
const double CoreCount = 4.0;
const double CoreCyclesPerSecond = 3.0e9;
const double HumanReactionTimeInSeconds = 200.0; // Desktop application grain
const double ALUInstructionCycles = 1.0;
const double DesktopAppTimeGrainRatio = HumanReactionTimeInSeconds /
(ALUInstructionCycles / (CoreCount * CoreCyclesPerSecond));
std::printf("Desktop App Time Grain Ratio: %f (10^%f)\n", DesktopAppTimeGrainRatio, std::log10(DesktopAppTimeGrainRatio));
const double BatchTimeInSeconds = 3600.0;
const double ServerBatchTimeGrainRatio = BatchTimeInSeconds /
(ALUInstructionCycles / (CoreCount * CoreCyclesPerSecond));
std::printf("Server Batch Time Grain Ratio: %f (10^%f)\n", ServerBatchTimeGrainRatio, std::log10(ServerBatchTimeGrainRatio));
const double PetabytesInBits = 1.e15 * 8;
const double BigdataLowestGrainInBits = 1.0; // bigdata engineers care about bitpacking
const double BigdataDataGrainRatio = PetabytesInBits / BigdataLowestGrainInBits;
std::printf("Bigdata Data Grain Ratio: %f (10^%f)\n", BigdataDataGrainRatio, std::log10(BigdataDataGrainRatio));
}
@uucidl
Copy link
Author

uucidl commented Mar 3, 2017

Desktop App Grain Time Ratio: 2400000000000.000000 (10^12.380211)
Server Batch Grain Time Ratio: 43200000000000.000000 (10^13.635484)
Bigdata Data Grain Ratio: 8000000000000000.000000 (10^15.903090)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment