{"id":16064498,"url":"https://github.com/antoniosbarotsis/mandelbrot","last_synced_at":"2025-04-05T09:21:08.522Z","repository":{"id":181278208,"uuid":"665707914","full_name":"AntoniosBarotsis/mandelbrot","owner":"AntoniosBarotsis","description":"Zooming in the Mandelbrot set with Rust","archived":false,"fork":false,"pushed_at":"2023-12-19T11:39:55.000Z","size":32745,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T18:59:23.314Z","etag":null,"topics":["mandelbrot","parallel","simd"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AntoniosBarotsis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-07-12T20:15:22.000Z","updated_at":"2023-07-20T16:31:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"c98f06a9-7efb-4110-bbcc-cecb4e0f6c28","html_url":"https://github.com/AntoniosBarotsis/mandelbrot","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"a378c1b0e9cd866d66a5f167bb81c00575171351"},"previous_names":["antoniosbarotsis/mandelbrot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoniosBarotsis%2Fmandelbrot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoniosBarotsis%2Fmandelbrot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoniosBarotsis%2Fmandelbrot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoniosBarotsis%2Fmandelbrot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntoniosBarotsis","download_url":"https://codeload.github.com/AntoniosBarotsis/mandelbrot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247313123,"owners_count":20918580,"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":["mandelbrot","parallel","simd"],"created_at":"2024-10-09T05:08:15.735Z","updated_at":"2025-04-05T09:21:08.485Z","avatar_url":"https://github.com/AntoniosBarotsis.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Mandelbrot-rs\n\nA Mandelbrot set renderer (with zoom!) I implemented for fun in Rust.\n\n[./assets/output2.mp4](https://github.com/AntoniosBarotsis/mandelbrot/assets/50240570/2343d8e7-c5a1-43d5-97c4-01bccead4d1a)\n\n## Usage\n\nRunning the project `cargo r -r` will create a \"slide show\" of separate frames in `./data`. These\ncan then be stitched together with [FFmpeg](https://ffmpeg.org/) with something like:\n\n```sh\nffmpeg -framerate 30 -i 'data/img%03d.png' -pix_fmt yuv420p output.mp4\n```\n\n\u003e **Note** If you're on Windows, you can install FFmpeg via\n\u003e [Chocolatey](https://community.chocolatey.org/) with\n\u003e\n\u003e ```sh\n\u003e choco install ffmpeg -y\n\u003e ```\n\n## Configurations\n\nCurrently, there's no \"nice\" way for users to do any sort of configuration without editing the code\ndirectly. As I worked on this purely for my own fun, I'm not too interested in implementing that.\n\nThere's a few things you might want to edit:\n\n| What | Where | Use |\n|:---:|:---:|:---:|\n| `point` | `main.rs/create_frames()` | This is the point the video will be zooming towards |\n| `scale_off` | `main.rs/create_frames()` | This determines the amount each thread will zoom by. Changing the denominator is an easy way to affect how quickly/slowly the zoom happens |\n| `width` | `main.rs` | The output image width. The FFmpeg command I mention works with 1920 and 480 so these are the two I left here for now. Use 480 for testing and 1920 for a nicer render. This can in theory just be whatever number you want (I rendered a 50kp frame at some point) |\n| `COLORS` | `colors.rs` | The color pallete. This should be 11 elements, if you want to use more, you probably need to make sure the `depth` works and is handled correctly. |\n| `MAX_DEPTH` | `common.rs` | The maximum depth used in the Mandelbrot calculations. I have not played with this at all 👍 |\n\n## SIMD\n\nMy SIMD code relies on a bunch of features that have not landed in stable Rust yet (it didn't\nreally need to use any of them but I just wanted to try some new stuff out) and thus you need\nthe Nightly toolchain to build those. They are put behind a `simd` feature so that you can still\ntinker with the rest of the project in stable Rust.\n\n```sh\nrustup default nightly\n# Might also need a `rustup update`\ncargo b -r -F simd\n```\n\n## Benchmarks\n\nI ran some simple benchmarks with [hyperfine](https://github.com/sharkdp/hyperfine) and got the\nfollowing results:\n\n```\n1920x1080p - 30 frames\n\nBenchmark 1: Simple\n  Time (mean ± σ):     68.014 s ±  1.744 s    [User: 66.984 s, System: 0.239 s]\n  Range (min … max):   66.985 s … 71.085 s    5 runs\n  \nBenchmark 2: Parallel (2 threads)\n  Time (mean ± σ):     41.453 s ±  4.840 s    [User: 75.976 s, System: 0.227 s]\n  Range (min … max):   38.249 s … 49.833 s    5 runs\n\nBenchmark 3: SIMD\n  Time (mean ± σ):     39.394 s ±  0.522 s    [User: 38.457 s, System: 0.203 s]\n  Range (min … max):   38.724 s … 39.954 s    5 runs\n  \nBenchmark 4: Parallel\n  Time (mean ± σ):     20.054 s ±  1.140 s    [User: 123.051 s, System: 0.649 s]\n  Range (min … max):   18.492 s … 21.706 s    5 runs\n  \nBenchmark 5: SIMD + Parallel\n  Time (mean ± σ):     14.300 s ±  0.235 s    [User: 70.323 s, System: 0.490 s]\n  Range (min … max):   13.912 s … 14.477 s    5 runs\n  \nBenchmark 6: SIMD (f64x8) + Parallel\n  Time (mean ± σ):     10.257 s ±  1.228 s    [User: 54.645 s, System: 0.259 s]\n  Range (min … max):    8.062 s … 10.859 s    5 runs\n```\n\n## Limitations\n\nTowards the ends of both videos in the [assets](./assets/) folder, you can see what I presume to be\nthe limitations of 64-bit floating number accuracy. Ways to go past that include using\n[128-bit floats](https://crates.io/crates/f128) or \n[multiple-precision floating-point numbers](https://crates.io/crates/gmp-mpfr-sys). Neither of these\nnatively support Windows which is why I chose to not go any further.\n\nThere's also [`astro-float`](https://crates.io/crates/astro-float) which is written in native Rust\nbut do keep in mind that it is much slower than using standard floats (as is likely the case with\nthe 2 other alternatives I mentioned previously, I've just happened to have only used this one).\n\n## Stuff that Helped me\n\n- [Render the Julia set in 3 dozen lines of Rust code](https://www.youtube.com/watch?v=g4vN2Z0JuZI)\n- [Online Mandelbrot Set Plotter](https://sciencedemos.org.uk/mandelbrot.php)\n- [Brute Force Processing](https://youtu.be/PBvLs88hvJ8)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniosbarotsis%2Fmandelbrot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoniosbarotsis%2Fmandelbrot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniosbarotsis%2Fmandelbrot/lists"}