{"id":19381132,"url":"https://github.com/j2kun/riemann-divisor-sum","last_synced_at":"2025-04-23T20:31:51.595Z","repository":{"id":49882576,"uuid":"291831263","full_name":"j2kun/riemann-divisor-sum","owner":"j2kun","description":"Code for the series \"Searching for Riemann Hypothesis Counterexamples\"","archived":false,"fork":false,"pushed_at":"2023-07-04T02:04:02.000Z","size":7504,"stargazers_count":21,"open_issues_count":5,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T19:46:55.768Z","etag":null,"topics":["docker","gmp","mathematics","postgres","riemann-hypothesis"],"latest_commit_sha":null,"homepage":"https://jeremykun.com/2020/09/11/searching-for-rh-counterexamples-setting-up-pytest/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j2kun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-31T21:44:56.000Z","updated_at":"2024-07-16T21:17:35.000Z","dependencies_parsed_at":"2023-01-25T14:00:35.623Z","dependency_job_id":null,"html_url":"https://github.com/j2kun/riemann-divisor-sum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2kun%2Friemann-divisor-sum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2kun%2Friemann-divisor-sum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2kun%2Friemann-divisor-sum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2kun%2Friemann-divisor-sum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j2kun","download_url":"https://codeload.github.com/j2kun/riemann-divisor-sum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250509683,"owners_count":21442476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","gmp","mathematics","postgres","riemann-hypothesis"],"created_at":"2024-11-10T09:16:05.731Z","updated_at":"2025-04-23T20:31:50.042Z","avatar_url":"https://github.com/j2kun.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Divisor Sums for the Riemann Hypothesis\n\n[![CircleCI](https://circleci.com/gh/j2kun/riemann-divisor-sum.svg?style=shield)](https://circleci.com/gh/j2kun/riemann-divisor-sum)\n[![Coverage Status](https://coveralls.io/repos/github/j2kun/riemann-divisor-sum/badge.svg?branch=main)](https://coveralls.io/github/j2kun/riemann-divisor-sum?branch=main)\n[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/j2kun/riemann-divisor-sum.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/j2kun/riemann-divisor-sum/context:python)\n\nAn application that glibly searches for RH counterexamples,\nwhile also teaching software engineering principles.\n\nBlog posts:\n\n- [Setting up Pytest](https://jeremykun.com/2020/09/11/searching-for-rh-counterexamples-setting-up-pytest/)\n- [Adding a Database](https://jeremykun.com/2020/09/11/searching-for-rh-counterexamples-adding-a-database/)\n- [Search Strategies](https://jeremykun.com/2020/09/28/searching-for-rh-counterexamples-search-strategies/)\n- [Unbounded Integers](https://jeremykun.com/2020/10/13/searching-for-rh-counterexamples-unbounded-integers/)\n- [Deploying with Docker](https://jeremykun.com/2021/01/04/searching-for-rh-counterexamples-deploying-with-docker/)\n- [Performance Profiling](https://jeremykun.com/2021/02/02/searching-for-rh-counterexamples-performance-profiling/)\n- [Scaling Up](https://jeremykun.com/2021/02/16/searching-for-rh-counterexamples-scaling-up/)\n- [Productionizing](https://jeremykun.com/2021/03/06/searching-for-rh-counterexamples-productionizing/)\n- [Exploring data](https://jeremykun.com/2021/06/14/searching-for-rh-counterexamples-exploring-data/)\n\n## Development requirements\n\nRequires Python 3.7 and\n\n- [GMP](https://gmplib.org/) for arbitrary precision arithmetic\n- [gmpy2](https://gmpy2.readthedocs.io/en/latest/intro.html) for Python GMP bindings\n- postgres\n\nOn Mac OS X these can be installed via brew as follows\n\n```\nbrew install gmp mpfr libmpc postgresql\n```\n\nOr using `apt`\n\n```\napt install -y libgmp3-dev libmpfr-dev libmpc-dev postgresql-12\n```\n\nThen, in a virtualenv,\n\n```\npip install -r requrements.txt\n```\n\n### Local development with PostgreSQL\n\nFor postgres, create a new database cluster\nand start the server.\n\n```\ninitdb --locale=C -E UTF-8 /usr/local/var/postgres\npg_ctl -D /usr/local/var/postgres -l /tmp/logfile start\n```\n\nThen create a database like\n\n```\nCREATE DATABASE divisor\n    WITH OWNER = jeremy;  -- or whatever your username is\n```\n\nThen install the pgmp extension using pgxn\n\n```\nsudo pip install pgxnclient\npgxn install pgmp\npgxn load -d divisor pgmp\n```\n\nNote you may need to add the location of `gmp.h` to `$C_INCLUDE_PATH`\nso that the build step for `pgmp` can find it.\nThis appears to be a problem mostly on Mac OSX.\nSee https://github.com/dvarrazzo/pgmp/issues/4 if you run into issues.\n\n```bash\n# your version may be different than 6.2.0. Find it by running\n# brew info gmp\nexport C_INCLUDE_PATH=\"/usr/local/Cellar/gmp/6.2.0/include:$C_INCLUDE_PATH\"\n```\n\nIn this case, you may also want to build pgmp from source,\n\n```bash\ngit clone https://github.com/j2kun/pgmp \u0026\u0026 cd pgmp\nmake\nsudo make install\n```\n\n## Running the program\n\nRun some combination of the following three worker jobs\n\n```bash\npython -m riemann.generate_search_blocks\npython -m riemann.process_search_blocks\npython -m riemann.cleanup_stale_blocks\n```\n\n## Deploying with Docker\n\nRunning with docker removes the need to install postgres and dependencies.\n\n### Locally\n\n```bash\ndocker build -t divisordb -f docker/divisordb.Dockerfile .\ndocker build -t generate -f docker/generate.Dockerfile .\ndocker build -t process -f docker/process.Dockerfile .\ndocker build -t cleanup -f docker/cleanup.Dockerfile .\n\ndocker volume create pgdata\n\ndocker run -d --name divisordb -p 5432:5432 -v pgdata:/var/lib/postgresql/data divisordb:latest\nexport PGHOST=$(docker inspect -f \"{{ .NetworkSettings.IPAddress }}\" divisordb)\n\ndocker run -d --name generate --env PGHOST=\"$PGHOST\" generate:latest\ndocker run -d --name cleanup --env PGHOST=\"$PGHOST\" cleanup:latest\ndocker run -d --name process --env PGHOST=\"$PGHOST\" process:latest\n```\n\n#### Manual inspection\n\nAfter the `divisordb` container is up, you can test whether it's working by\n\n```\npg_isready -d divisor -h $PGHOST -p 5432 -U docker\n```\n\nor by going into the container and checking the database manually\n\n```\n$ docker exec -it divisordb /bin/bash\n# now inside the container\n$ psql\ndivisor=# \\d   # \\d is postgres for 'describe tables'\n\n              List of relations\n Schema |        Name        | Type  | Owner\n--------+--------------------+-------+--------\n public | riemanndivisorsums | table | docker\n public | searchmetadata     | table | docker\n(2 rows)\n```\n\n#### On EC2\n\n```bash\n# install docker, see get.docker.com\ncurl -fsSL https://get.docker.com -o get-docker.sh\nsudo sh get-docker.sh\nsudo usermod -aG docker ubuntu\n\n# log out and log back in\n\ngit clone https://github.com/j2kun/riemann-divisor-sum \u0026\u0026 cd riemann-divisor-sum\n```\n\n#### Updating existing EC2 deployment\n\nFill out the environment variables from `.env.template` in `.env`,\nthen run `python deploy.py`.\n\nThis will only work if the application has been set up initially\n(docker installed and the repository cloned).\n\n#### Running the monitoring script\n\n```bash\nsudo apt install -y python3-pip ssmtp\npip3 install -r alerts/requirements.txt\nsudo -E alerts/configure_ssmtp.sh\nnohup python3 -m alerts.monitor_docker \u0026\n```\n\n## Exporting and plotting data\n\n```bash\npython -m riemann.export_for_plotting --data_source_name='dbname=divisor' --divisor_sums_filepath=divisor_sums.csv\n\n# sort the csv by log_n using gnu sort\nsort -t , -n -k 1 divisor_sums.csv -o divisor_sums_sorted.csv\n\n# convert to hdf5\npython -c \"import vaex; vaex.from_csv('divisor_sums.csv', convert=True, chunk_size=5_000_000)\"\n\npython -m plot.plot_divisor_sums --divisor_sums_hdf5_path=divisor_sums.hdf5\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj2kun%2Friemann-divisor-sum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj2kun%2Friemann-divisor-sum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj2kun%2Friemann-divisor-sum/lists"}