Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog (2024)

Records are made to be broken. In 2019, we calculated 31.4 trillion digits of π — a world record at the time. Then, in 2021, scientists at the University of Applied Sciences of the Grisons calculated another 31.4 trillion digits of the constant, bringing the total up to 62.8 trillion decimal places. Today we're announcing yet another record: 100 trillion digits of π.

This is the second time we’ve used Google Cloud to calculate a record number1 of digits for the mathematical constant, tripling the number of digits in just three years.

This achievement is a testament to how much faster Google Cloud infrastructure gets, year in, year out. The underlying technology that made this possible is Compute Engine, Google Cloud’s secure and customizable compute service, and its several recent additions and improvements: the Compute Engine N2 machine family, 100 Gbps egress bandwidth, Google Virtual NIC, and balanced Persistent Disks. It's a long list, but we'll explain each feature one by one.

Before we dive into the tech, here’s an overview of the job we ran to calculate our 100 trillion digits of π.

  • Program: y-cruncher v0.7.8, by Alexander J. Yee
  • Algorithm: Chudnovsky algorithm
  • Compute node: n2-highmem-128 with 128 vCPUs and 864 GB RAM
  • Start time: Thu Oct 14 04:45:44 2021 UTC
  • End time: Mon Mar 21 04:16:52 2022 UTC
  • Total elapsed time: 157 days, 23 hours, 31 minutes and 7.651 seconds
  • Total storage size: 663 TB available, 515 TB used
  • Total I/O: 43.5 PB read, 38.5 PB written, 82 PB total
Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog (1)
Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog (2)

History of π computation from ancient times through today. You can see that we're adding digits of π exponentially, thanks to computers getting exponentially faster.

Architecture overview

Calculating π is compute-, storage-, and network-intensive. Here’s how we configured our Compute Engine environment for the challenge.

For storage, we estimated the size of the temporary storage required for the calculation to be around 554 TB. The maximum persistent disk capacity that you can attach to a single virtual machine is 257 TB, which is often enough for traditional single node applications, but not in this case. We designed a cluster of one computational node and 32 storage nodes, for a total of 64 iSCSI block storage targets.

Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog (3)
Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog (4)

The main compute node is a n2-highmem-128 machine running Debian Linux 11, with 128 vCPUs and 864 GB of memory, and 100 Gbps egress bandwidth support. The higher bandwidth support is a critical requirement for the system as we adopted a network-based shared storage architecture.

Each storage server is a n2-highcpu-16 machine configured with two 10,359 GB zonal balanced persistent disks. The N2 machine series provides balanced price/performance, and when configured with 16 vCPUs it provides a network bandwidth of 32 Gbps, with an option to use the latest Intel Ice Lake CPU platform, which makes it a good choice for high-performance storage servers.

Automating the solution

We used Terraform to set up and manage the cluster. We also wrote a couple of shell scripts to automate critical tasks such as deleting old snapshots, and restarting from snapshots (we didn't need to use this though). The Terraform scripts created OS guest policies to help ensure that the required software packages were automatically installed. Part of the guest OS setup process was handled by startup scripts. In this way, we were able to recreate the entire cluster with just a few commands.

We knew the calculation would run for several months and even a small performance difference could change the runtime by days or possibly weeks. There are also a number of combinations of parameters in the operating system, infrastructure, and application itself. Terraform helped us test dozens of different infrastructure options in a short time. We also developed a small program that runs y-cruncher with different parameters and automated a significant portion of the measurement. Overall, the final design for this calculation was about twice as fast as our first design. In other words, the calculation could’ve taken 300 days instead of 157 days!

The scripts we used are available on GitHub if you want to look at the actual code that we used to calculate the 100 trillion digits.

Choosing the right machine type for the job

Compute Engine offers machine types that support compute- and I/O-intensive workloads. The amount of available memory and network bandwidth were the two most important factors, so we selected n2-highmem-128 (Intel Xeon, 128 vCPUs and 864 GB RAM). It satisfied our requirements: high-performance CPU, large memory, and 100 Gbps egress bandwidth. This VM shape is part of the most popular general purpose VM family in Google Cloud.

100 Gbps networking

The n2-highmem-128 machine type’s support for up to 100 Gbps of egress throughput was also critical. Back in 2019 when we did our 31.4-trillion digit calculation, egress throughput was only 16 Gbps, meaning that bandwidth has increased by 600% in just three years. This increase was a big factor that made this 100-trillion experiment possible, allowing us to move 82.0 PB of data for the calculation, up from 19.1 PB in 2019.

We also changed the network driver from virtio to the new Google Virtual NIC (gVNIC). gVNIC is a new device driver and tightly integrates with Google's Andromeda virtual network stack to help achieve higher throughput and lower latency. It is also a requirement for 100 Gbps egress bandwidth.

Storage design

Our choice of storage was crucial to the success of this cluster – in terms of capacity, performance, reliability, cost and more. Because the dataset doesn't fit into main memory, the speed of the storage system was the bottleneck of the calculation. We needed a robust, durable storage system that could handle petabytes of data without any loss or corruption, while fully utilizing the 100 Gbps bandwidth.

Persistent Disk (PD) is a durable high-performance storage option for Compute Engine virtual machines. For this job we decided to use balanced PD, a new type of persistent disk that offers up to 1,200 MB/s read and write throughput and 15-80k IOPS, for about 60% of the cost of SSD PDs. This storage profile is a sweet spot for y-cruncher, which needs high throughput and medium IOPS.

Using Terraform, we tested different combinations of storage node counts, iSCSI targets per node, machine types, and disk size. From those tests, we determined that 32 nodes and 64 disks would likely achieve the best performance for this particular workload.

We scheduled backups automatically every two days using a shell script that checks the time since the last snapshots, runs the fstrim command to discard all unused blocks, and runs the gcloud compute disks snapshot command to create PD snapshots. The gcloud command returns and y-cruncher resumes calculations after a few seconds while the Compute Engine infrastructure copies the data blocks asynchronously in the background, minimizing downtime for the backups.

To store the final results, we attached two 50 TB disks directly to the compute node. Those disks weren’t used until the very last moment, so we didn't allocate the full capacity until y-cruncher reached the final steps of the calculation, saving four months worth of storage costs for 100 TB.

Results

All this fine tuning and benchmarking got us to the one-hundred trillionth digit of π — 0. We verified the final numbers with another algorithm (Bailey–Borwein–Plouffe formula) when the calculation was completed. This verification was the scariest moment of the entire process because there is no sure way of knowing whether or not the calculation was successful until it finished, five months after it began. Happily, the Bailey-Borwein-Plouffe formula found that our results were valid. Woo-hoo! Here are the last 100 digits of the result:

Loading...

You can also access the entire sequence of numbers on our demo site.

So what?

You may not need to calculate trillions of decimals of π, but this massive calculation demonstrates how Google Cloud’s flexible infrastructure lets teams around the world push the boundaries of scientific experimentation. It's also an example of the reliability of our products – the program ran for more than five months without node failures, and handled every bit in the 82 PB of disk I/O correctly. The improvements to our infrastructure and products over the last three years made this calculation possible.

Running this calculation was great fun, and we hope that this blog post has given you some ideas about how to use Google Cloud's scalable compute, networking, and storage infrastructure for your own high performance computing workloads. To get started, we've created a codelab where you can create and calculate pi on a Compute Engine virtual machine with step-by-step instructions. And for more on the history of calculating pi, check out this post on The Keyword. Here’s to breaking the next record!

We will be hosting a live webinar on June 15 to share more about the experimentation process and results. Sign-up here to join.

To learn more about Google Cloud Infrastructure, please Join us July 13 at 9am PST for the first ever Infrastructure Spotlight. Engineers from Snap and Broadcom will join Google leaders to discuss how Google Cloud Infrastructure helps them be more efficient and scale. Registerhere.

1. We are actively working with Guinness World Records to secure their official validation of this feat as a "World Record", but we couldn’t wait to share it with the world. This record has been reviewed and validated by Alexander J. Yee, the author of y-cruncher.

ComputePi in the sky: Calculating a record-breaking 31.4 trillion digits of Archimedes’ constant on Google CloudBy Emma Haruka Iwao • 5-minute read
Posted in
  • Compute
  • HPC
  • Google Cloud
Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog (2024)

FAQs

Calculating 100 trillion digits of pi on Google Cloud | Google Cloud Blog? ›

In 2019, she was able to calculate pi to its 31.4 trillionth digit, and now, using the same Google Cloud y-cruncher program, Iwao was able to find pi to its 100 trillionth digit, which is zero. After starting the process in October 2021, it took the computers until March 2022 to finish.

Who calculated 100 trillion digits of pi? ›

In April 2023, Solidigm matched the record of 100 trillion digits of pi, which was calculated by Google Cloud in 2022. Before that, the record was 62.8 trillion digits, which were calculated over 108 days by a supercomputer at the University of Applied Sciences of the Grisons in Switzerland in 2021.

How many digits of pi are there in Google cloud? ›

Last year, Google Cloud Developer Advocate Emma Haruka Iwao announced that she and her team had calculated Pi to 100 trillion digits, breaking her previous record of 31.4 trillion digits from 2019.

What is the 105 trillionth digit of pi? ›

Wenming Ye on X: "More digits in Pi than ever before. 105 Trillionth digit == 6 https://t.co/AEA6fBPLgU" / X.

What is the world record for calculating pi? ›

Engineers at StorageReview have shattered their own world record by calculating pi to an astounding 202,112,290,000,000 digits, smashing its previous record of 105 trillion digits set earlier this year in time for World Pi Day (March 14 - 3/14).

How many digits of pi does NASA use? ›

NASA uses 15 decimal places and by counting the 3, you have a total of 16 digits. And that is more than enough. NASA's Marc Rayman, who was the chief engineer on the Dawn mission, has revealed why you do not need more.

Who holds the current record for most digits of pi? ›

According to it, the current record is held by Suresh Kumar Sharma, who recited an incredible 70 030 digits of π in 17 hours and 14 minutes. That is an average of just over 1 digit per second. There are other unofficial record holders like Akira Haraguchi from Japan, who claims to have memorized 111 700 digits[2].

How do you memorize pi digits on Google? ›

Typing in a Google search for a simple math expression or just the word calculator will open Google's built in calculator. Frequent users may have noticed the shiny new π button on the left-hand corner. Click this button and the calculator turns into a memorization game with the digits of Pi.

How to memorize pi? ›

Rhyme to memorize.

This mnemonic relies on using the rhythm and pattern to recall the memorized numbers. Lots of other memorization songs use the same technique: "If numbers had a heaven / their God would surely be / 3.14159 / 26535." Try writing your own song or rhyme to help yourself remember.

How did Google calculate pi? ›

Iwao's team used the y-cruncher program and Chudnovsky algorithm. Their calculation ran for 157 days before finding the 100-trillionth decimal place — a 0. They then verified the final numbers with the Bailey–Borwein–Plouffe formula. In total, the process used a whopping 515 TB of storage and 82 PB of I/O.

Who memorized 100000 digits of pi? ›

Akira Haraguchi (原口 證, Haraguchi Akira) (born 1946, Miyagi Prefecture), is a retired Japanese engineer known for memorizing and reciting digits of pi.

How long did it take to calculate 31 trillion digits of pi? ›

In 2019, calculating 31.4 trillion digits took 121 days, making this year's calculation of 100 trillion digits more than 2x faster. "This massive calculation demonstrates how Google Cloud's flexible infrastructure lets teams around the world push the boundaries of scientific experimentation," Iwao wrote in a blog post.

How many digits of pi do scientists know? ›

We currently know more than 105 trillion digits of pi, thanks to a computer company that crunched the number for 75 days.

How much of pi can the average person remember? ›

When it comes to how many digits of pi people know by heart, the majority only know 3.14. Which is fine! Unless you're building a bridge, that's the most you will really need to know. If you can get to the first 3 after the decimal point, you're in the top 5 percent of pi memorizers.

How long did it take to find 62.8 trillion digits of pi? ›

Supercomputer took 108 days to run the calculations.

Is there a pattern to pi? ›

Calculations can continue infinitely without repetition or pattern, because Pi is an irrational number. Mathematicians called it irrational, because Pi cannot be expressed as a ratio of integers. To children and adults alike, Pi is perplexing… a constant with an infinity number of digits and no pattern.

Who calculated the first 100 digits of pi? ›

1400–1949
DateWhoDecimal places (world records in bold)
1706John Machin100
1706William Jones
1719Thomas Fantet de Lagny112
1721Anonymous152
36 more rows

Who calculated the full value of pi? ›

The first calculation of π was done by Archimedes of Syracuse (287–212 BC), one of the greatest mathematicians of the ancient world.

Who decided the digits of pi? ›

Around 250 BC, the Greek mathematician Archimedes created an algorithm to approximate π with arbitrary accuracy. In the 5th century AD, Chinese mathematicians approximated π to seven digits, while Indian mathematicians made a five-digit approximation, both using geometrical techniques.

How did Emma Haruka Iwao calculate pi? ›

The calculation used a multithreaded program called y-cruncher using over 25 machines for 121 days.

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Aron Pacocha

Last Updated:

Views: 6321

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.