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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [0.2.0] - 2025-12-23
9
+
10
+
### Changed
11
+
-**Major Architecture Overhaul**: The library is now fully async-native.
12
+
-`TTLCache`, `SWRCache`, and `BGCache` now support `async def` functions natively using `await`.
13
+
- Synchronous functions are still supported via intelligent inspection, maintaining backward compatibility.
14
+
-**Unified Scheduling**: `SWRCache` (in sync mode) and `BGCache` now use `APScheduler` (`SharedScheduler` and `SharedAsyncScheduler`) for all background tasks, replacing ad-hoc threading.
15
+
-**Testing**: Integration tests rewritten to use `pytest-asyncio` with `mode="auto"`.
16
+
17
+
### Added
18
+
-`AsyncTTLCache`, `AsyncStaleWhileRevalidateCache`, `AsyncBackgroundCache` classes (aliased to `TTLCache`, `SWRCache`, `BGCache`).
19
+
-`SharedAsyncScheduler` for managing async background jobs.
20
+
-`pytest-asyncio` configuration in `pyproject.toml`.
BENCH_RUNS=1000 BENCH_MIXED_RUNS=2000 uv run python tests/benchmark.py
45
-
```
46
-
47
-
```bash
48
-
# Focus on decorator overhead (no artificial sleep)
49
-
BENCH_WORK_MS=0 BENCH_RUNS=200000 BENCH_MIXED_RUNS=300000 uv run python tests/benchmark.py
41
+
BENCH_RUNS=1000 uv run python tests/benchmark.py
50
42
```
51
43
52
44
### Step 3 — Compare two runs
53
45
54
-
There are two ways to select runs:
55
-
56
-
- Relative: `last` / `last-N`
57
-
- Explicit: integer indices (0-based; negatives allowed)
58
-
59
-
List run indices quickly:
46
+
The benchmark appends JSON lines to `benchmarks.log`. A quick helper to list runs:
60
47
61
48
```bash
62
49
uv run python - <<'PY'
63
50
import json
64
51
from pathlib import Path
65
52
runs=[]
53
+
if not Path('benchmarks.log').exists():
54
+
print("No benchmarks.log found")
55
+
exit(0)
66
56
for line in Path('benchmarks.log').read_text(encoding='utf-8', errors='replace').splitlines():
67
-
line=line.strip()
68
-
if not line.startswith('{'):
69
-
continue
70
-
try:
71
-
obj=json.loads(line)
72
-
except Exception:
73
-
continue
74
-
if isinstance(obj,dict) and 'results' in obj:
75
-
runs.append(obj)
57
+
line=line.strip()
58
+
if not line.startswith('{'):
59
+
continue
60
+
try:
61
+
obj=json.loads(line)
62
+
except Exception:
63
+
continue
64
+
if isinstance(obj,dict) and 'sections' in obj:
65
+
runs.append(obj)
76
66
print('count',len(runs))
77
67
for i,r in enumerate(runs):
78
-
print(i,r.get('ts'))
68
+
print(i,r.get('ts'))
79
69
PY
80
70
```
81
71
82
-
Compare (example: index 2 vs index 11):
83
-
84
-
```bash
85
-
uv run python tests/compare_benchmarks.py --a 2 --b 11
86
-
```
87
-
88
-
What to look at:
89
-
-**Hot TTL/SWR** medians: these are the pure “cache-hit overhead” numbers.
90
-
-**Mixed** medians: reflect a real-ish distribution; watch for regressions here.
91
-
- Ignore small (<5–10%) deltas unless they repeat across multiple clean runs.
72
+
To compare two indices (e.g., 2 vs 11), load the JSON objects in a notebook or script and diff the `sections` (hot medians for TTL/SWR/BG are the most sensitive to overhead changes).
92
73
93
74
### Step 4 — Make results stable (recommended practice)
0 commit comments