y-cruncher - Developments

(Last updated: December 9, 2018)



Back To:


Active Branches:


This is a table of all the active branches of y-cruncher. As this is just a side-hobby, overall development is slow and there is no formal release cycle. But in recent years, feature releases have been approximately every 4 - 8 months with multiple patches in between.

Branch Version # Changes (from v0.7.6.9490)
v0.7.6 v0.7.6.9490


trunk v0.7.7-9483-133

New Features:

  • Custom Formulas: y-cruncher can now run a limited set of user-specified formulas. This allows the user to compute more than just the built-in constants. It also allows the user to implement alternative formulas for the existing constants. Sample formulas have been included in the y-cruncher downloads.

  • Catalan's Constant Algorithms: 3 new algorithms have been added for Catalan's Constant. Due to the speed of these new algorithms, the existing Lupas and Huvent formulas are now outdated. But they will remain in y-cruncher for the time being.

  • Lemniscate with AGM: The AGM algorithm has been implemented for Lemniscate. This algorithm is about 2x faster than Gauss' formula in memory. But may be slower in Swap Mode.

  • Brent-McMillan Formula with explicit n: This allows you to run the Brent-McMillan formula for the Euler-Mascheroni Constant with a manually specified n parameter. This is somewhat of a useless feature that has existed internally since 2013.

  • Digit and Validation Output Path Improvements:
    • The "-o" command line option will now be used for both the digit output as well as the validation file.
    • A new "-od" option has been added to suppress digit output. This is the new method for disabling output.
    • Added a command line option to set the priority which y-cruncher runs at.
    • When output verification is enabled, there is now an additional verification step to detect data corruption of the source data during digit output that may go undetected in previous versions.

  • The TBB parallel framework now has sub-options to tinker with.

  • There is now a command line option to override the process priority that y-cruncher will run at.

Removed Features:

  • ArcCoth(x) has been removed. It has become superfluous as it remains accessible from the Custom Formula feature.


  • AMD Jaguar processors will now choose the 11-SNB binary instead of the 08-NHM binary.
  • The TBB parallel framework now uses slightly different library calls which may affect performance.


  • The file extension for configuration files has been changed to ".cfg".
  • The naming of some of the algorithms has been changed.
  • Minor speed differences due to numerous internal refactorings.
  • Non-fatal errors that occur during memory allocation are now logged to the event log.
  • More run-time warnings will now propagate to the client in Slave Mode.
  • The format for the PauseWarning message in Slave Mode has been updated.




y-cruncher was pretty heavily developed between 2008 - 2013. But I've since left school and found a full-time job. While y-cruncher will probably remain a side-hobby for the near future, it won't get as much attention as it used to get. At the very least, I'll continue to fix whatever bugs that are discovered. And I'll make an effort to keep the program up-to-date with the latest instruction set extensions and development toolchains. But for the most part, the project is done.


Most of the work right now is in cleaning up the code and refactoring it into idiomatic C++ for long-term maintainability. The program was (and still largely is) a fragile mess of unreadable C hackery with little to no documentation. So at the very least, I'd like to get it into a state where someone other than myself can read it.


Nevertheless, it's a never-ending project. So there are things on the to-do list. But it can be a long time before anything gets done.




Feature Description Status
Slave Mode

Provide a way to control y-cruncher through TCP. This will allow 3rd party applications to build a GUI around y-cruncher.


More details here: https://github.com/Mysticial/y-cruncher-GUI

An early version of this was launched with v0.7.6. As of v0.7.7, it theoretically should be complete enough to implement a full GUI for both the stress tester and custom compute options.


Incremental progress will continue to be made. In particular a unified way to express menus and suboptions is still needed.


Ideas on the Radar:

Feature Description Status
Nth Root Radicals

Custom Formulas:


Add support for nth root radicals.

This will enable the computation of Gamma(1/3).

This was originally slated for v0.7.7 with the first release of the Custom Formula feature. But on further analysis, it isn't as simple as it appears.


A preliminary analysis on the numeric behavior of Newton's Method showed some non-linear effects which warrant further investigation before it can be implemented.


Implementing this efficiently will require a specially optimized power function that y-cruncher currently doesn't have.


Given the sheer number of bugs that were showing up in v0.7.7, this was dropped indefinitely and will be reconsidered for v0.7.8.


Custom Formulas:


Add support for the exponential function.

This will enable the fully generic non-integer power function for real numbers.


This involves inverting log(x) with Newton's Method.

This hasn't really been looked at yet. So it's unknown how many numerical and implementation complications there will be like in the case of the nth root radicals.


At the very least, designing a way to do status printing that is both useful and not overly spammy might be tricky.

Improved Stress Test

The current stress-tester has increasingly poor coverage in today's processors. In fact, the program's unit and integration test frameworks are a better stress test than the dedicated stress test itself!


Find a way build a new stress test around these "better" workloads.

The difficulty here is that the "best" stress test requires mixing all the different instruction sets (SSE, AVX, AVX512). But each of y-cruncher's binaries focuses on only one of them and it's not easy to use a "lower" ISA when compiling for a "higher" one since the compiler will try to vectorize the code to use the higher one.

Optimized Square Root

Custom Formulas:


The current square root is just the inverse square root followed by a multiply by the input.


It may be possible to do better by merging that multiply in the final iteration - as is the case for division and reciprocal.

Optimize the AGM

Custom Formulas:


In the final iterations of the AGM, much of the output is already known. These can be used to skip some of the early iterations of the Newton's Method square root.
Optimize log(x)

Custom Formulas:


The current log(x) implementation is a dumb wrapper around AGM(1,x).


There are ways to make the AGM require fewer iterations that should be investigated.

Non-Monotonically Convergent Hypergeometric Series

Custom Formulas:


Extend the SeriesHypergeometric function to allow series that are not monotonically convergent.


This is needed for confluent hypergeometic functions at large inputs where the series initially diverges before eventually converging.


This will allow certain approximation algorithms to be implemented:

  • Sweeney's method for the Euler-Mascheroni Constant
  • Gamma function at rational inputs.

This is expected to be very difficult.


Irregular convergence behavior wreaks havoc on the Binary Splitting implementation since a lot of assumptions break down. While the Brent-McMillan formula for the Euler-Mascheroni Constant already exhibits this behavior, it is specially handled.


The most difficult part of this is precision control. In order to do precision control, y-cruncher needs to know:

  1. How large the series terms can get.
  2. What magnitude the final value converges to.

#1 is complicated, but likely doable.

#2 doesn't seem approachable in the generic case with the mathematical techniques that I know of.


#2 is difficult due to destructive cancellation. Confluent hypergeometric functions are notorious for this behavior. And it is just the simplest case.


Take a series and something as simple as taking its derivative can drastically alter the magnitude of the value that it converges to. (i.e. exp(-x2) and the Error Function for very large x)


It is likely that #2 will require the user to explicitly tell y-cruncher what the final magnitude will be.



These are projects which have either stalled made no recent progress or are so long term that there is no roadmap.

Feature Description Status
Rewrite the Radix Conversion

The current radix conversion code is actually a prototype that ended up in production. It has so many problems that it's basically unsalvageable.

  • It's not possible to do checkpoints.
  • It uses more memory than necessary.
  • It's completely inflexible to any modifications that affect the memory layout.
  • It's very fragile and very easy to break.

The current code is actually the 3rd radix conversion to be used in y-cruncher (and the 2nd to use the Scaled Remainder Tree). But it's still a prototype since it's the first to combine all of the following features/optimizations:

  • Scaled Remainder Tree
  • Middle Product
  • Removal of Trailing Zeros
  • Precomputation of the forward FFTs of the powers.
  • Parallelization with bounded memory usage.
  • Swap Mode (out-of-core) Computation

At the time (2011), this was very ambitious - perhaps a little too ambitious. In the end, it required so many hacks that the thing became a complete mess.


The radix conversion will need to be completely redesigned and rewritten.

Stalled. No progress has been made in years.




Still trying to figure out a way to approach this in a way that will be maintainable without sacrificing any performance...


The existing radix conversion has virtually no internal abstraction. This makes it both very fast and unmaintainable.



No progress has been made in years due to a backlog of higher priority issues.


The only work has been maintenance to keep the current work-in-progress code working with respect to breaking changes in other parts of y-cruncher.

Reduced Memory Mode

For Pi Chudnovsky and Ramanujan, add a mode that will allow a computation to be done using less memory/disk at the cost of slower performance.


For a typical computation, most of the work requires very little memory. It's the occasional memory spike that causes y-cruncher to have such a high memory requirement.


There are about 4 large memory spikes in a Pi computation. In approximate descending order of size, they are:

  1. The final Binary Splitting merge in the series summation.

  2. The Final Multiply.

  3. The radix conversion verification.

  4. The first split of the radix conversion.

These spikes can be flattened via space-time tradeoffs in the respective algorithms. Since the trade-off only needs to be done at the spikes, the overall performance hit should be reasonably small.

Stalled. No progress has been made in years.




As of v0.6.8, only the first two memory spikes have been suppressed. The overall memory reduction is not enough to be worth enabling the feature publicly.


The last two spikes both involve the radix conversion which is completely blocked pending the rewrite of the radix conversion code.


This partially completed feature was used for the 12.1 trillion digit computation of Pi.



As of 2017, this is low priority due to a backlog of higher priority issues.


MRFM stands for "Multi-Region Far Memory". It is a very large experimental project that will attempt to solve the NUMA problem and more generally, the supercomputer problem.


The current design of MRFM that is planned is a fundamental departure from y-cruncher's battle-tested model of computation. So virtually all high-level code will need new implementations for MRFM.


As a result, the plan calls for two completely new computation modes:

  • Multi-Region NUMA
  • Multi-Region Swap

This will bring the total number of modes to 4. But if all goes as planned, Multi-Region Swap will become a no-compromise generalization of the current Swap Mode. So it will be possible to remove the current Swap Mode without losing much functionality.


Due to the sheer scale of this project along with a large number of unknowns, this was expected to be (and has become) a multi-year project with no guarantee of success.

Much of the planning for this began years ago. But actual coding didn't start until around September of 2016.


As of 2018, progress is stalled due to large amounts of technical debt in y-cruncher's high-level code which have been accumulating for years. The radix conversion mentioned above is one such example of this technical debt.


MRFM remains a multi-year project with no end in sight.



Areas of Research:


Silent Data Corruption:

Disk I/O is the bane of large number computations. Historically, it was bad only because it is slow. Nowadays, it's also unreliable.


"Unreliability" comes in several forms:

  1. Basic I/O errors where an API call to read or write fails.
  2. The entire drive fails completely leading to permenant data loss.
  3. Silent data corruption that is neither detected by the hardware nor the operating system.

(1) and (2) are easily solved using checkpoint-restart and periodic backups. y-cruncher has supported checkpointing this since v0.5.4 so it isn't really a problem anymore. But (3) is very scary and remains a huge problem today.


Silent data corruption is the worst since it's undetected. It plagues database applications, and unfortunately, y-cruncher is extremely vulnerable as well. If an error manages to slip through y-cruncher's built-in redundancy checks, it will cause a computation to finish with the wrong digits.





Hard drives already use error-correction and CRCs to ensure data integrity. And transfers between the drive to the controller are also protected with CRCs. So you would expect that data corruption would be detected by the operating system right? Nope...


When a hard drive fails to read a sector due to CRC failures, it usually propagates all the way back into the program and manifests as a (1). So that's not a problem. But transfer errors between the drive and the controller are less ideal. Supposedly, transfer errors lead to retransmission. But this isn't always the case.


Throughout the years of developing y-cruncher, transfer errors have also been observed to:

  1. Severely slow down or hang the drive in question.
  2. Silent data corruption.
  3. Silent data corruption and an increase to the S.M.A.R.T. "Ultra ATA CRC error count".

(1) is to be expected if the connection quality is so bad that the data gets stuck in a retransmission loop.

(2) is also be expected if the corrupted data passes a CRC by chance. (I have no idea how long the CRC is, but if it's CRC32, a 1 in 4 billion chance isn't small.)

(3) makes absolutely no sense at all. If the hard drive was able to detect the error, then why the hell doesn't it notify the OS that the operation failed?


In any case, there are other things that don't add up. And in the end, we are forced to accept the reality.


To date, y-cruncher's only defense for silent data corruption is the RAID3. When the swap file configuration is set to use RAID3, (almost) all reads are parity checked. And if the data is bad, it will report a failure. The parity bits are flipped so that zeroing errors that zero everything will fail the parity.


Unfortunately, this is far from sufficient:

To date, silent data corruption has yet to bring down a world-record attempt. But it happens regularly in the development test machines (which contain some very old hard drives). There has also been an instance reported on a forum where a 1 trillion digit computation of Pi failed - presumably due to silent data corruption.


Approximately 80% of the disk I/Os that y-cruncher does are covered by redundancy checks at a higher level. So in the absence of RAID 3, silent data corruption will be detected with 80% probability if we assume uniform distribution. To put it simply, 80% is not good enough. But at the very least, failing a redundancy check should be an immediate and serious red flag.



Possible Solutions:


Use a filesystem designed for data integrity (such ZFS). While this is almost too obvious, there will also be performance trade-offs.


The other approaches involve adding checksumming into y-cruncher's raid-file implementation. But this is easier said than done:

Inlining checksums into the data will break sector-alignment and incur copy-shifting overhead. But perhaps this can be merged with the RAID interleaving. Placing the checksums elsewhere will add seek overhead. Either way, it will be messy.


Due to the poor state of the current raid-file code, any significant change will likely imply a complete rewrite of the entire raid-file implementation.



Non-Uniform Memory Access (NUMA):

y-cruncher is currently a shared memory program. So it will run efficiently given the following assumptions:

  1. All the memory in the system is shared and can be accessed by all processor cores.
  2. All processor cores have low latency and high-bandwidth access to all the memory.

As of 2016, these assumptions hold for almost all single-socket systems - which include the majority of personal desktop computers and low-end servers.


But due to the laws of physics and the speed of light, assumption #2 does not hold for larger systems. So now we're into the territory of Non-Uniform Memory Access (NUMA), cluster/distributed computing. For now the focus will be on NUMA systems since that's what the majority of the multi-socket systems are.


In short, y-cruncher does not run efficiently on NUMA. While it scales reasonably well onto dual-socket, it all goes downhill after that. There have been numerous reports of non-scaling (and even backwards scaling) on quad-Opteron systems. And all of this is due to the NUMA.


To exacerbate the problem, OS's normally default to a "first-touch" policy for memory allocation. The problem is that y-cruncher allocates all its memory at the start of a computation with a single thread. With the first-touch policy, all the memory will be allocated (or heavily biased) on one NUMA mode. So during the computation, all the cores from all the NUMA nodes will be hammering that one node for memory access. The interconnect going in and out of that one node will be overwhelmed by the traffic which leads to terrible performance.


y-cruncher v0.7.3 adds the ability to interleave memory across nodes. This balances the interconnect traffic and leads to a significant performance on modern dual and quad-socket systems. But ultimately, this doesn't actually solve the problem of NUMA since the memory accesses (which are now randomized) will still be hitting remote nodes over the interconnect.


To be efficient, the program needs to be aware of the NUMA and needs to be designed specifically for it. This is a fairly difficult task which is made worse by the unlimited combinations of NUMA topologies. Long story short, making y-cruncher NUMA aware will require changing the way that memory is fundamentally stored and managed. This means that it will need to be done as a new "mode" much like how "Ram Only" and "Swap Mode" have completely different data storage formats.



Currently, the most promising solution is to generalize the functionality of swap mode in the following ways:

  1. Instead of using a disk array, replace it with a "far memory" interface which can be anything from disk to interleaved NUMA or even cloud storage.
  2. Leverage the swap mode algorithms for minimizing disk access to minimize access to far memory.
  3. Duplicate shared resources into each NUMA node to reduce interconnect thrashing.


GCD Factorization:

Many binary splitting recursions have a lot of common factors between the fraction numerators and denominators. Implement an optimization that seeks to remove these common factors so that the numbers are smaller in size.


GCD Factorization was first described here (now a dead link). Since then, there have been subsequent publications that describe the method:

The general idea of the optimization is to keep the prime factorization of some of the recursion variables. Then use this factorization to obtain the GCD of the numerator and denominator terms. Obtaining this prime factorization is done using a sieve.


Current implementations of this optimization include GMP Pi Chudnovsky and TachusPi. And most literature reports a speedup of about 20 - 30% for Pi Chudnovsky.


In the context of y-cruncher, this optimization is applicable to the following constants/algorithms:


Current Problems:


Even though GCD factorization has been known for years, y-cruncher has yet to use it for a number of reasons:

  1. The naive approach to sieving the index terms will require a prohibitive amount of memory. This problem exists in GMP Pi Chudnovsky. Fabrice Bellard's TachusPi has a more efficient approach that does it using O( sqrt(N) ) memory - presumably using some sort of sieve segmentation. But he left few details on this approach.

  2. The data structure that is needed to perform the sieve and store the prime factorization is somewhat incompatible with y-cruncher's memory model.

  3. y-cruncher lacks the ability to efficiently perform integer divisions.

While (1) and (3) are certainly solvable, (2) is more difficult. All the ideas so far for attacking (2) are either complicated and fragile, or they require breaking out of the current memory model. For now, there's bigger fish to fry.