Initial setup

This commit is contained in:
Chuck Ard
2026-03-14 16:37:03 -05:00
commit 06d6eeaad6
4 changed files with 648 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
### Day 1 — GIL + CPU-bound vs I/O-bound threading
#### Goals (what "done" means)
- [ ] I can explain the GIL in 23 sentences and why it impacts **CPU-bound** threading more than **I/O-bound** threading.
- [ ] I can choose between threads, processes, and asyncio for a given workload and justify it.
- [ ] I have benchmark results (numbers) that demonstrate the above.
#### Reading (mostly)
- [ ] Read: [What Is the Python Global Interpreter Lock (GIL)? (Real Python)](https://realpython.com/python-gil/)
- [ ] Write 5 bullets: what the GIL is, what it is *not*, and why it exists.
- [ ] Read: [Understanding the Python GIL (PDF)](http://www.dabeaz.com/python/UnderstandingGIL.pdf)
- [ ] Write 5 bullets: where threads *do* help, where they dont, and what "switch interval" means (high level).
- [ ] Skim (reference): [concurrent.futures — Python docs](https://docs.python.org/3/library/concurrent.futures.html)
- [ ] Note the difference between `ThreadPoolExecutor` vs `ProcessPoolExecutor`.
#### Hands-on (benchmark + notes)
- [ ] Create a benchmark script that compares these variants for a **CPU-bound** function:
- [ ] Serial (single process, no threads)
- [ ] `ThreadPoolExecutor`
- [ ] `ProcessPoolExecutor`
- [ ] Use a **repeatable** timing method (pick one):
- [ ] `timeit` (preferred for small benchmarks): [timeit — Python docs](https://docs.python.org/3/library/timeit.html)
- [ ] or wall-clock timing with `time.perf_counter()` (fine for longer tasks)
- [ ] Record results in a small table (example format):
- [ ] workload size parameters (so you can reproduce)
- [ ] runtime for each approach
- [ ] notes on CPU utilization / behavior
- [ ] Add an **I/O-bound** comparison:
- [ ] Serial loop calling `time.sleep(x)`
- [ ] Thread pool version (expect improvement)
- [ ] Write "Conclusions" (minimum 6 sentences):
- [ ] What happened for CPU-bound?
- [ ] What happened for I/O-bound?
- [ ] What I would choose in real systems and why
#### Stretch (optional)
- [ ] Skim: [PEP 703 Making the Global Interpreter Lock Optional in CPython](https://peps.python.org/pep-0703/)
- [ ] Write 3 bullets: what changes, tradeoffs, and why it matters.
#### Deliverables (to commit)
- [ ] `notes.md` updated with:
- [ ] explanation bullets
- [ ] benchmark table
- [ ] conclusions
- [ ] `benchmark.py` (or similar) added with instructions to run
#### Suggested commits
- [ ] `day01: add GIL notes + benchmark scaffolding`
- [ ] `day01: record CPU vs IO benchmark results and conclusions`