https://github.com/rescrv/napkin Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} rescrv / napkin Public * Notifications You must be signed in to change notification settings * Fork 0 * Star 11 Back-of-the-envelope stuffs in Python License BSD-3-Clause license 11 stars 0 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights rescrv/napkin This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 6 Commits napkin napkin .gitignore .gitignore LICENSE LICENSE README.md README.md setup.py setup.py View all files Repository files navigation * README * BSD-3-Clause license napkin Napkin is a tool for doing back-of-the-envelope calculations in the style of Python. Concretely, a napkin listing specs for i3.metal machines looks like this: MACHINE_CPUS = 72 MACHINE_MEMORY = 512 * Gi # bytes MACHINE_NUM_DISKS = 8 MACHINE_STORAGE = MACHINE_NUM_DISKS * 1900 * Gi # bytes MACHINE_NET_RATE = 10 * 1024**3 / 8 # bytes/sec MACHINE_IOP_SIZE = 4096 # bytes MACHINE_IOPS_RAND_READ = MACHINE_NUM_DISKS * 3.3 * M MACHINE_IOPS_SEQ_WRITE = MACHINE_NUM_DISKS * 1.4 * M When rendered with napkin, the calculations get performed and substituted in for values. Our annotations on each line list the units that napkin will render. MACHINE_CPUS = 72 MACHINE_MEMORY = 512GiB MACHINE_NUM_DISKS = 8 MACHINE_STORAGE = 14.8TiB MACHINE_NET_RATE = 1.2GiB/s MACHINE_IOP_SIZE = 4kiB MACHINE_IOPS_RAND_READ = 26.4M MACHINE_IOPS_SEQ_WRITE = 11.2M Napkin IS Python. It uses the 2to3 library to transform any UPPERCASE_VARIABLE into its substituted form. Latency Estimation Napkin has some in-built primitives for handling latency estimates. It is possible to define a service level objective (SLO) and then compute the latency of sequential SLOs. # Our service sla specified at the 50%, 75%, 95%, 99% and 100% percentiles. OUR_SLO = SLO((.5, .002), (.75, .003), (.95, 0.010), (.99, 0.050), (1.0, 1.)) # percentiles:seconds TWO_OPS_IN_SERIES = combine_in_series(OUR_SLO, OUR_SLO, scale=5000) # percentiles:seconds The output of an SLO looks like this: # Our service sla specified at the 50%, 75%, 95%, 99% and 100% percentiles. OUR_SLO = SLO((0.5, 2ms), (0.75, 3ms), (0.95, 10ms), (0.99, 50ms), (1.0, 1s)) TWO_OPS_IN_SERIES = SLO((0.5, 5ms), (0.75, 9ms999us999ns), (0.95, 38ms999us999ns), (0.99, 528ms), (1.0, 2s)) Warts and Such * Latency estimation doesn't do operations in series (yet). * Variables cannot be redefined. About Back-of-the-envelope stuffs in Python Resources Readme License BSD-3-Clause license Activity Stars 11 stars Watchers 1 watching Forks 0 forks Report repository Releases No releases published Packages 0 No packages published Languages * Python 100.0% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.