diskcache-rs 0.4.8__tar.gz → 0.4.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/actions/setup-diskcache-rs/action.yml +1 -1
  2. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/workflows/benchmark.yml +24 -26
  3. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/workflows/build.yml +16 -2
  4. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/workflows/release.yml +1 -1
  5. diskcache_rs-0.4.10/.release-please-manifest.json +3 -0
  6. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/CHANGELOG.md +20 -0
  7. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/Cargo.lock +35 -26
  8. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/Cargo.toml +3 -3
  9. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/PKG-INFO +1 -1
  10. diskcache_rs-0.4.10/benchmarks/batch_write_comparison.py +161 -0
  11. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/performance_comparison.py +34 -0
  12. diskcache_rs-0.4.10/benchmarks/pickle_bridge_comparison.py +73 -0
  13. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/justfile +6 -0
  14. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/pyproject.toml +2 -0
  15. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/__init__.py +2 -5
  16. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/__init__.pyi +49 -17
  17. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/cache.py +19 -6
  18. diskcache_rs-0.4.10/python/diskcache_rs/djangocache.py +118 -0
  19. diskcache_rs-0.4.10/python/diskcache_rs/rust_pickle.py +77 -0
  20. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/cache.rs +62 -22
  21. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/memory_cache.rs +1 -0
  22. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/migration.rs +1 -1
  23. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/storage/optimized_backend.rs +375 -504
  24. diskcache_rs-0.4.10/tests/test_batch_operations.py +183 -0
  25. diskcache_rs-0.4.10/tests/test_issue_125_djangocache_multiprocess.py +194 -0
  26. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_issue_17_configurable_threshold.py +19 -18
  27. diskcache_rs-0.4.10/tests/test_issue_345_nfs_safe_sqlite.py +58 -0
  28. diskcache_rs-0.4.10/tests/test_rust_pickle_performance.py +339 -0
  29. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_version_and_disk_threshold.py +18 -18
  30. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/uv.lock +414 -18
  31. diskcache_rs-0.4.8/.release-please-manifest.json +0 -3
  32. diskcache_rs-0.4.8/benchmarks/batch_write_comparison.py +0 -90
  33. diskcache_rs-0.4.8/python/diskcache_rs/rust_pickle.py +0 -71
  34. diskcache_rs-0.4.8/tests/test_batch_operations.py +0 -83
  35. diskcache_rs-0.4.8/tests/test_rust_pickle_performance.py +0 -266
  36. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  37. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  38. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/actions/build-and-test/action.yml +0 -0
  39. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/pull_request_template.md +0 -0
  40. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/workflows/build-abi3.yml +0 -0
  41. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.github/workflows/ci.yml +0 -0
  42. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.gitignore +0 -0
  43. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/.pre-commit-config.yaml +0 -0
  44. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/API_COMPATIBILITY.md +0 -0
  45. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/Dockerfile.test +0 -0
  46. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/LICENSE +0 -0
  47. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/README.md +0 -0
  48. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/comprehensive_performance_test.py +0 -0
  49. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/detailed_profiling.py +0 -0
  50. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/final_performance_comparison.py +0 -0
  51. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/high_performance_test.py +0 -0
  52. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/memory_usage_test.py +0 -0
  53. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/micro_benchmark.py +0 -0
  54. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/optimization_validation_test.py +0 -0
  55. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/precise_benchmark.py +0 -0
  56. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/benchmarks/set_performance_analysis.py +0 -0
  57. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/docker-compose.test.yml +0 -0
  58. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/examples/basic_usage.py +0 -0
  59. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/examples/special_chars_keys_example.py +0 -0
  60. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/_diskcache_rs.pyi +0 -0
  61. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/constants.py +0 -0
  62. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/core.py +0 -0
  63. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/disk.py +0 -0
  64. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/fast_cache.py +0 -0
  65. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/pickle_cache.py +0 -0
  66. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/python/diskcache_rs/recipes.py +0 -0
  67. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/release-please-config.json +0 -0
  68. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/renovate.json +0 -0
  69. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/scripts/generate_stubs.py +0 -0
  70. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/scripts/sync_version.py +0 -0
  71. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/scripts/test-docker-network.sh +0 -0
  72. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/error.rs +0 -0
  73. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/eviction.rs +0 -0
  74. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/lib.rs +0 -0
  75. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/pickle_cache.rs +0 -0
  76. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/serialization.rs +0 -0
  77. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/storage/tests.rs +0 -0
  78. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/storage.rs +0 -0
  79. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/src/utils.rs +0 -0
  80. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/__init__.py +0 -0
  81. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/benchmark_official.py +0 -0
  82. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/conftest.py +0 -0
  83. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_api_compatibility.py +0 -0
  84. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_basic_operations.py +0 -0
  85. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_ci_benchmark.py +0 -0
  86. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_compatibility.py +0 -0
  87. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_complete_api_gaps.py +0 -0
  88. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_cross_platform_network.py +0 -0
  89. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_diskcache_rs_persistence_suite.py +0 -0
  90. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_docker_network.py +0 -0
  91. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_fast_cache.py +0 -0
  92. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_full_api_compatibility.py +0 -0
  93. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_issue_73_deterministic_hashing.py +0 -0
  94. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_issue_78_expire_method.py +0 -0
  95. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_network_filesystem.py +0 -0
  96. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_performance.py +0 -0
  97. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_pickle_cache.py +0 -0
  98. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_recipes_and_constants.py +0 -0
  99. {diskcache_rs-0.4.8 → diskcache_rs-0.4.10}/tests/test_special_chars_keys.py +0 -0
@@ -18,7 +18,7 @@ runs:
18
18
  using: 'composite'
19
19
  steps:
20
20
  - name: Install uv
21
- uses: astral-sh/setup-uv@v7
21
+ uses: astral-sh/setup-uv@v8.1.0
22
22
  with:
23
23
  python-version: ${{ inputs.python-version }}
24
24
 
@@ -33,7 +33,7 @@ jobs:
33
33
  uses: dtolnay/rust-toolchain@stable
34
34
 
35
35
  - name: Install uv
36
- uses: astral-sh/setup-uv@v7
36
+ uses: astral-sh/setup-uv@v8.1.0
37
37
 
38
38
  - name: Install dependencies
39
39
  run: |
@@ -63,7 +63,7 @@ jobs:
63
63
 
64
64
  - name: Comment PR with benchmark results
65
65
  if: github.event_name == 'pull_request'
66
- uses: actions/github-script@v8
66
+ uses: actions/github-script@v9
67
67
  with:
68
68
  script: |
69
69
  const fs = require('fs');
@@ -72,33 +72,31 @@ jobs:
72
72
  const results = JSON.parse(fs.readFileSync('benchmark_results.json', 'utf8'));
73
73
 
74
74
  let comment = '## 📊 Performance Benchmark Results\n\n';
75
- comment += '| Benchmark | python-diskcache | diskcache_rs | Winner |\n';
76
- comment += '|-----------|------------------|--------------|--------|\n';
75
+ comment += '| Benchmark | Metric | python-diskcache | diskcache_rs | Winner |\n';
76
+ comment += '|-----------|--------|------------------|--------------|--------|\n';
77
77
 
78
- for (const [name, result] of Object.entries(results)) {
79
- // Handle both old and new result formats
80
- let dcOps, rsOps;
81
- if (result.diskcache && result.diskcache_rs) {
82
- // New format with nested operations
83
- if (result.diskcache.get && result.diskcache_rs.get) {
84
- dcOps = result.diskcache.get.ops_per_sec;
85
- rsOps = result.diskcache_rs.get.ops_per_sec;
86
- } else {
87
- dcOps = result.diskcache.ops_per_sec || 0;
88
- rsOps = result.diskcache_rs.ops_per_sec || 0;
89
- }
90
- } else {
91
- continue; // Skip malformed results
92
- }
78
+ const addRow = (name, metric, dcOps, rsOps) => {
79
+ if (!dcOps || !rsOps) return;
80
+ const winner = dcOps > rsOps
81
+ ? `python-diskcache (${(dcOps/rsOps).toFixed(1)}x)`
82
+ : `diskcache_rs (${(rsOps/dcOps).toFixed(1)}x)`;
83
+ comment += `| ${name} | ${metric} | ${dcOps.toFixed(1)} ops/s | ${rsOps.toFixed(1)} ops/s | ${winner} |\n`;
84
+ };
93
85
 
94
- let winner;
95
- if (dcOps > rsOps) {
96
- winner = `python-diskcache (${(dcOps/rsOps).toFixed(1)}x)`;
97
- } else {
98
- winner = `diskcache_rs (${(rsOps/dcOps).toFixed(1)}x)`;
86
+ for (const [name, result] of Object.entries(results)) {
87
+ if (!result.diskcache || !result.diskcache_rs) continue;
88
+
89
+ const weighted = result.weighted_ops_per_sec || {};
90
+ addRow(name, 'weighted', weighted.diskcache, weighted.diskcache_rs);
91
+
92
+ for (const metric of ['get', 'set', 'delete']) {
93
+ addRow(
94
+ name,
95
+ metric,
96
+ result.diskcache[metric]?.ops_per_sec,
97
+ result.diskcache_rs[metric]?.ops_per_sec
98
+ );
99
99
  }
100
-
101
- comment += `| ${name} | ${dcOps.toFixed(1)} ops/s | ${rsOps.toFixed(1)} ops/s | ${winner} |\n`;
102
100
  }
103
101
 
104
102
  comment += '\n> 💡 **Note**: Performance varies based on storage type and network conditions.\n';
@@ -63,7 +63,14 @@ jobs:
63
63
  args: --release --out dist --find-interpreter
64
64
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
65
65
  manylinux: auto
66
- - uses: uraimo/run-on-arch-action@v3.0.1
66
+ - name: Pre-pull binfmt image
67
+ run: |
68
+ for attempt in 1 2 3; do
69
+ docker pull tonistiigi/binfmt:latest && break
70
+ if [ "$attempt" = "3" ]; then exit 1; fi
71
+ sleep $((attempt * 5))
72
+ done
73
+ - uses: uraimo/run-on-arch-action@v3.1.0
67
74
  if: matrix.target != 'ppc64le'
68
75
  name: Install built wheel
69
76
  with:
@@ -152,7 +159,14 @@ jobs:
152
159
  args: --release --out dist --find-interpreter
153
160
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
154
161
  manylinux: musllinux_1_2
155
- - uses: uraimo/run-on-arch-action@v3.0.1
162
+ - name: Pre-pull binfmt image
163
+ run: |
164
+ for attempt in 1 2 3; do
165
+ docker pull tonistiigi/binfmt:latest && break
166
+ if [ "$attempt" = "3" ]; then exit 1; fi
167
+ sleep $((attempt * 5))
168
+ done
169
+ - uses: uraimo/run-on-arch-action@v3.1.0
156
170
  name: Install built wheel
157
171
  with:
158
172
  arch: ${{ matrix.platform.arch }}
@@ -28,7 +28,7 @@ jobs:
28
28
  tag_name: ${{ steps.release.outputs.tag_name }}
29
29
  releases_created: ${{ steps.release.outputs.releases_created }}
30
30
  steps:
31
- - uses: googleapis/release-please-action@v4
31
+ - uses: googleapis/release-please-action@v5
32
32
  id: release
33
33
  with:
34
34
  token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.4.10"
3
+ }
@@ -4,6 +4,26 @@
4
4
 
5
5
  - sync Cargo.toml version with .cz.toml and update CHANGELOG for v0.4.0
6
6
 
7
+ ## [0.4.10](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.9...diskcache_rs-v0.4.10) (2026-04-15)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **deps:** update rust crate redb to v4 ([910b7c4](https://github.com/loonghao/diskcache_rs/commit/910b7c4ac70fe4d2a3f0c81a8899ab6522f7f1b8))
13
+
14
+ ## [0.4.9](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.8...diskcache_rs-v0.4.9) (2026-03-25)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * unblock batch writes and expand perf coverage ([e28f9b5](https://github.com/loonghao/diskcache_rs/commit/e28f9b574b4375b90b38fa92a4f759e0820692b9))
20
+ * unblock batch writes and expand perf coverage ([d235250](https://github.com/loonghao/diskcache_rs/commit/d23525069ef524a92120f846104d7824a0a47fd5))
21
+
22
+
23
+ ### Performance Improvements
24
+
25
+ * default to CPython pickle fast path ([#101](https://github.com/loonghao/diskcache_rs/issues/101)) ([0e78be8](https://github.com/loonghao/diskcache_rs/commit/0e78be82eb48a05b642e6732da37543210fab59c))
26
+
7
27
  ## [0.4.8](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.7...diskcache_rs-v0.4.8) (2026-03-24)
8
28
 
9
29
 
@@ -78,9 +78,9 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
78
78
 
79
79
  [[package]]
80
80
  name = "blake3"
81
- version = "1.8.3"
81
+ version = "1.8.4"
82
82
  source = "registry+https://github.com/rust-lang/crates.io-index"
83
- checksum = "2468ef7d57b3fb7e16b576e8377cdbde2320c60e1491e961d11da40fc4f02a2d"
83
+ checksum = "4d2d5991425dfd0785aed03aedcf0b321d61975c9b5b3689c774a2610ae0b51e"
84
84
  dependencies = [
85
85
  "arrayref",
86
86
  "arrayvec",
@@ -161,9 +161,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
161
161
 
162
162
  [[package]]
163
163
  name = "cpufeatures"
164
- version = "0.2.17"
164
+ version = "0.3.0"
165
165
  source = "registry+https://github.com/rust-lang/crates.io-index"
166
- checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
166
+ checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
167
167
  dependencies = [
168
168
  "libc",
169
169
  ]
@@ -246,7 +246,7 @@ dependencies = [
246
246
 
247
247
  [[package]]
248
248
  name = "diskcache_rs"
249
- version = "0.4.8"
249
+ version = "0.4.10"
250
250
  dependencies = [
251
251
  "anyhow",
252
252
  "bincode",
@@ -392,6 +392,15 @@ name = "hashbrown"
392
392
  version = "0.16.1"
393
393
  source = "registry+https://github.com/rust-lang/crates.io-index"
394
394
  checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
395
+ dependencies = [
396
+ "foldhash 0.2.0",
397
+ ]
398
+
399
+ [[package]]
400
+ name = "hashbrown"
401
+ version = "0.17.0"
402
+ source = "registry+https://github.com/rust-lang/crates.io-index"
403
+ checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
395
404
  dependencies = [
396
405
  "allocator-api2",
397
406
  "equivalent",
@@ -499,9 +508,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
499
508
 
500
509
  [[package]]
501
510
  name = "libc"
502
- version = "0.2.183"
511
+ version = "0.2.185"
503
512
  source = "registry+https://github.com/rust-lang/crates.io-index"
504
- checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
513
+ checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
505
514
 
506
515
  [[package]]
507
516
  name = "libsqlite3-sys"
@@ -537,18 +546,18 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
537
546
 
538
547
  [[package]]
539
548
  name = "lru"
540
- version = "0.16.3"
549
+ version = "0.18.0"
541
550
  source = "registry+https://github.com/rust-lang/crates.io-index"
542
- checksum = "a1dc47f592c06f33f8e3aea9591776ec7c9f9e4124778ff8a3c3b87159f7e593"
551
+ checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9"
543
552
  dependencies = [
544
- "hashbrown 0.16.1",
553
+ "hashbrown 0.17.0",
545
554
  ]
546
555
 
547
556
  [[package]]
548
557
  name = "lz4_flex"
549
- version = "0.13.0"
558
+ version = "0.13.1"
550
559
  source = "registry+https://github.com/rust-lang/crates.io-index"
551
- checksum = "db9a0d582c2874f68138a16ce1867e0ffde6c0bb0a0df85e1f36d04146db488a"
560
+ checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e"
552
561
  dependencies = [
553
562
  "twox-hash",
554
563
  ]
@@ -683,9 +692,9 @@ dependencies = [
683
692
 
684
693
  [[package]]
685
694
  name = "pyo3"
686
- version = "0.28.2"
695
+ version = "0.28.3"
687
696
  source = "registry+https://github.com/rust-lang/crates.io-index"
688
- checksum = "cf85e27e86080aafd5a22eae58a162e133a589551542b3e5cee4beb27e54f8e1"
697
+ checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
689
698
  dependencies = [
690
699
  "libc",
691
700
  "once_cell",
@@ -697,18 +706,18 @@ dependencies = [
697
706
 
698
707
  [[package]]
699
708
  name = "pyo3-build-config"
700
- version = "0.28.2"
709
+ version = "0.28.3"
701
710
  source = "registry+https://github.com/rust-lang/crates.io-index"
702
- checksum = "8bf94ee265674bf76c09fa430b0e99c26e319c945d96ca0d5a8215f31bf81cf7"
711
+ checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
703
712
  dependencies = [
704
713
  "target-lexicon",
705
714
  ]
706
715
 
707
716
  [[package]]
708
717
  name = "pyo3-ffi"
709
- version = "0.28.2"
718
+ version = "0.28.3"
710
719
  source = "registry+https://github.com/rust-lang/crates.io-index"
711
- checksum = "491aa5fc66d8059dd44a75f4580a2962c1862a1c2945359db36f6c2818b748dc"
720
+ checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
712
721
  dependencies = [
713
722
  "libc",
714
723
  "pyo3-build-config",
@@ -716,9 +725,9 @@ dependencies = [
716
725
 
717
726
  [[package]]
718
727
  name = "pyo3-macros"
719
- version = "0.28.2"
728
+ version = "0.28.3"
720
729
  source = "registry+https://github.com/rust-lang/crates.io-index"
721
- checksum = "f5d671734e9d7a43449f8480f8b38115df67bef8d21f76837fa75ee7aaa5e52e"
730
+ checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
722
731
  dependencies = [
723
732
  "proc-macro2",
724
733
  "pyo3-macros-backend",
@@ -728,9 +737,9 @@ dependencies = [
728
737
 
729
738
  [[package]]
730
739
  name = "pyo3-macros-backend"
731
- version = "0.28.2"
740
+ version = "0.28.3"
732
741
  source = "registry+https://github.com/rust-lang/crates.io-index"
733
- checksum = "22faaa1ce6c430a1f71658760497291065e6450d7b5dc2bcf254d49f66ee700a"
742
+ checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
734
743
  dependencies = [
735
744
  "heck",
736
745
  "proc-macro2",
@@ -756,9 +765,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
756
765
 
757
766
  [[package]]
758
767
  name = "redb"
759
- version = "3.1.1"
768
+ version = "4.1.0"
760
769
  source = "registry+https://github.com/rust-lang/crates.io-index"
761
- checksum = "ef99362319c782aa4639ad3a306b64c3bb90e12874e99b8df124cb679d988611"
770
+ checksum = "8e925444704b5f17d32bf42f5b6e2df050bceebc3dcd6e71cc73dafe8092e839"
762
771
  dependencies = [
763
772
  "libc",
764
773
  ]
@@ -1052,9 +1061,9 @@ checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
1052
1061
 
1053
1062
  [[package]]
1054
1063
  name = "uuid"
1055
- version = "1.22.0"
1064
+ version = "1.23.1"
1056
1065
  source = "registry+https://github.com/rust-lang/crates.io-index"
1057
- checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37"
1066
+ checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76"
1058
1067
  dependencies = [
1059
1068
  "getrandom",
1060
1069
  "js-sys",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "diskcache_rs"
3
- version = "0.4.8"
3
+ version = "0.4.10"
4
4
  edition = "2021"
5
5
  authors = ["longhao <hal.long@outlook.com>"]
6
6
  description = "A high-performance disk cache implementation in Rust with Python bindings"
@@ -56,10 +56,10 @@ crossbeam = "0.8"
56
56
  # Cross-platform file locking for NFS support
57
57
  fs4 = "0.13"
58
58
 
59
- lru = "0.16"
59
+ lru = "0.18"
60
60
 
61
61
  # Embedded key-value database for persistent index
62
- redb = "3.1"
62
+ redb = "4.0"
63
63
 
64
64
  [lints.clippy]
65
65
  dbg_macro = "warn"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diskcache_rs
3
- Version: 0.4.8
3
+ Version: 0.4.10
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -0,0 +1,161 @@
1
+ """Compare batch-write throughput across high-level and low-level cache APIs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import statistics
6
+ import tempfile
7
+ import time
8
+ from collections.abc import Callable
9
+
10
+ import diskcache
11
+ from diskcache_rs import Cache, rust_pickle_dumps
12
+ from diskcache_rs._diskcache_rs import PyCache
13
+
14
+ PAYLOAD_COUNT = 500
15
+ PAYLOAD_SIZE = 1024
16
+ PREFILL_COUNT = 10_000
17
+ ROUNDS = 5
18
+
19
+ PAYLOAD = {f"key-{index}": b"x" * PAYLOAD_SIZE for index in range(PAYLOAD_COUNT)}
20
+ SERIALIZED_PAYLOAD = {key: rust_pickle_dumps(value) for key, value in PAYLOAD.items()}
21
+ PREFILL_PAYLOAD = {
22
+ f"prefill-{index}": b"p" * 128 for index in range(PREFILL_COUNT)
23
+ }
24
+ SERIALIZED_PREFILL_PAYLOAD = {
25
+ key: rust_pickle_dumps(value) for key, value in PREFILL_PAYLOAD.items()
26
+ }
27
+
28
+
29
+ BenchmarkFn = Callable[[], float]
30
+
31
+
32
+ def benchmark_diskcache_rs_loop(prefill: bool = False) -> float:
33
+ with tempfile.TemporaryDirectory(prefix="diskcache_rs_loop_") as cache_dir:
34
+ cache = Cache(cache_dir)
35
+ if prefill:
36
+ cache.set_many(PREFILL_PAYLOAD)
37
+
38
+ start = time.perf_counter()
39
+ for key, value in PAYLOAD.items():
40
+ cache.set(key, value)
41
+ cache.close()
42
+ return time.perf_counter() - start
43
+
44
+
45
+ def benchmark_diskcache_rs_batch(prefill: bool = False) -> float:
46
+ with tempfile.TemporaryDirectory(prefix="diskcache_rs_batch_") as cache_dir:
47
+ cache = Cache(cache_dir)
48
+ if prefill:
49
+ cache.set_many(PREFILL_PAYLOAD)
50
+
51
+ start = time.perf_counter()
52
+ cache.set_many(PAYLOAD)
53
+ cache.close()
54
+ return time.perf_counter() - start
55
+
56
+
57
+ def benchmark_diskcache_loop(prefill: bool = False) -> float:
58
+ with tempfile.TemporaryDirectory(prefix="diskcache_py_loop_") as cache_dir:
59
+ cache = diskcache.Cache(cache_dir)
60
+ if prefill:
61
+ for key, value in PREFILL_PAYLOAD.items():
62
+ cache.set(key, value)
63
+
64
+ start = time.perf_counter()
65
+ for key, value in PAYLOAD.items():
66
+ cache.set(key, value)
67
+ cache.close()
68
+ return time.perf_counter() - start
69
+
70
+
71
+ def benchmark_pycache_loop(prefill: bool = False) -> float:
72
+ with tempfile.TemporaryDirectory(prefix="diskcache_pycache_loop_") as cache_dir:
73
+ cache = PyCache(cache_dir)
74
+ if prefill:
75
+ cache.set_many(list(SERIALIZED_PREFILL_PAYLOAD.items()))
76
+
77
+ start = time.perf_counter()
78
+ for key, value in SERIALIZED_PAYLOAD.items():
79
+ cache.set(key, value)
80
+ cache.close()
81
+ return time.perf_counter() - start
82
+
83
+
84
+ def benchmark_pycache_batch(prefill: bool = False) -> float:
85
+ with tempfile.TemporaryDirectory(prefix="diskcache_pycache_batch_") as cache_dir:
86
+ cache = PyCache(cache_dir)
87
+ if prefill:
88
+ cache.set_many(list(SERIALIZED_PREFILL_PAYLOAD.items()))
89
+
90
+ start = time.perf_counter()
91
+ cache.set_many(list(SERIALIZED_PAYLOAD.items()))
92
+ cache.close()
93
+ return time.perf_counter() - start
94
+
95
+
96
+ def run_rounds(benchmark: BenchmarkFn) -> list[float]:
97
+ return [benchmark() for _ in range(ROUNDS)]
98
+
99
+
100
+ def average_duration(samples: list[float]) -> float:
101
+ return statistics.mean(samples)
102
+
103
+
104
+ def print_metric(name: str, samples: list[float]) -> None:
105
+ avg = average_duration(samples)
106
+ print(f"{name}_avg={avg:.6f}")
107
+ print(f"{name}_ops_per_sec={PAYLOAD_COUNT / avg:.1f}")
108
+
109
+
110
+ def print_scenario_results(name: str, samples: dict[str, list[float]]) -> None:
111
+ print(f"scenario={name}")
112
+ for metric_name, metric_samples in samples.items():
113
+ print_metric(f"{name}_{metric_name}", metric_samples)
114
+
115
+ rs_loop_avg = average_duration(samples["rs_loop"])
116
+ rs_batch_avg = average_duration(samples["rs_batch"])
117
+ py_loop_avg = average_duration(samples["py_loop"])
118
+ pycache_loop_avg = average_duration(samples["pycache_loop"])
119
+ pycache_batch_avg = average_duration(samples["pycache_batch"])
120
+
121
+ print(f"{name}_high_level_batch_speedup_vs_rs_loop={rs_loop_avg / rs_batch_avg:.2f}")
122
+ print(
123
+ f"{name}_low_level_batch_speedup_vs_pycache_loop={pycache_loop_avg / pycache_batch_avg:.2f}"
124
+ )
125
+ print(f"{name}_batch_speedup_vs_diskcache_loop={py_loop_avg / rs_batch_avg:.2f}")
126
+ print()
127
+
128
+
129
+ def main() -> None:
130
+ print(
131
+ f"payload_count={PAYLOAD_COUNT} payload_size={PAYLOAD_SIZE} prefill_count={PREFILL_COUNT} rounds={ROUNDS}"
132
+ )
133
+ print()
134
+
135
+ fresh_samples = {
136
+ "rs_loop": run_rounds(lambda: benchmark_diskcache_rs_loop(prefill=False)),
137
+ "rs_batch": run_rounds(lambda: benchmark_diskcache_rs_batch(prefill=False)),
138
+ "py_loop": run_rounds(lambda: benchmark_diskcache_loop(prefill=False)),
139
+ "pycache_loop": run_rounds(lambda: benchmark_pycache_loop(prefill=False)),
140
+ "pycache_batch": run_rounds(lambda: benchmark_pycache_batch(prefill=False)),
141
+ }
142
+ print_scenario_results("fresh", fresh_samples)
143
+
144
+ prefilled_samples = {
145
+ "rs_loop": run_rounds(lambda: benchmark_diskcache_rs_loop(prefill=True)),
146
+ "rs_batch": run_rounds(lambda: benchmark_diskcache_rs_batch(prefill=True)),
147
+ "py_loop": run_rounds(lambda: benchmark_diskcache_loop(prefill=True)),
148
+ "pycache_loop": run_rounds(lambda: benchmark_pycache_loop(prefill=True)),
149
+ "pycache_batch": run_rounds(lambda: benchmark_pycache_batch(prefill=True)),
150
+ }
151
+ print_scenario_results("prefilled", prefilled_samples)
152
+
153
+ print("analysis_hint=high_level Cache.set_many is still bounded by Python-side pickle serialization")
154
+ print("analysis_hint=low_level PyCache.set_many better isolates Rust storage batching gains")
155
+ print(
156
+ "analysis_hint=prefilled scenarios highlight the cost of per-write cache limit bookkeeping when the cache is already large"
157
+ )
158
+
159
+
160
+ if __name__ == "__main__":
161
+ main()
@@ -198,6 +198,23 @@ def benchmark_large_values(cache_dir, implementation="diskcache", operations=100
198
198
  return results
199
199
 
200
200
 
201
+ def calculate_weighted_ops(benchmark_name, result):
202
+ """Calculate weighted throughput for the benchmark's operation mix."""
203
+ weights = (
204
+ {"get": 0.89, "set": 0.10, "delete": 0.01}
205
+ if "Standard Workload" in benchmark_name
206
+ else {"set": 0.50, "get": 0.50}
207
+ )
208
+ total = 0.0
209
+ total_weight = 0.0
210
+ for operation, weight in weights.items():
211
+ op_result = result.get(operation)
212
+ if op_result:
213
+ total += op_result["ops_per_sec"] * weight
214
+ total_weight += weight
215
+ return total / total_weight if total_weight else 0.0
216
+
217
+
201
218
  def run_benchmarks(test_dir):
202
219
  """Run all benchmarks following diskcache methodology"""
203
220
 
@@ -234,6 +251,10 @@ def run_benchmarks(test_dir):
234
251
  results[benchmark_name] = {
235
252
  "diskcache": diskcache_result,
236
253
  "diskcache_rs": diskcache_rs_result,
254
+ "weighted_ops_per_sec": {
255
+ "diskcache": calculate_weighted_ops(benchmark_name, diskcache_result),
256
+ "diskcache_rs": calculate_weighted_ops(benchmark_name, diskcache_rs_result),
257
+ },
237
258
  }
238
259
 
239
260
  # Print detailed comparison
@@ -308,6 +329,19 @@ def print_summary(results):
308
329
  for benchmark_name, result in results.items():
309
330
  dc_result = result["diskcache"]
310
331
  rs_result = result["diskcache_rs"]
332
+ weighted = result.get("weighted_ops_per_sec", {})
333
+ dc_weighted = weighted.get("diskcache", 0.0)
334
+ rs_weighted = weighted.get("diskcache_rs", 0.0)
335
+ if dc_weighted or rs_weighted:
336
+ winner = (
337
+ f"diskcache ({dc_weighted / rs_weighted:.1f}x)"
338
+ if dc_weighted > rs_weighted
339
+ else f"diskcache_rs ({rs_weighted / dc_weighted:.1f}x)"
340
+ )
341
+ bench_short = benchmark_name.split("(")[0].strip()
342
+ print(
343
+ f"{bench_short:<25} {'weighted':<8} {dc_weighted:>12.1f} ops/s {rs_weighted:>12.1f} ops/s {winner}"
344
+ )
311
345
 
312
346
  for operation in ["get", "set", "delete"]:
313
347
  if operation in dc_result and operation in rs_result:
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env python3
2
+ """Compare CPython pickle, diskcache_rs default pickle helpers, and the direct bridge path."""
3
+
4
+ import os
5
+ import pickle
6
+ import time
7
+
8
+ os.environ.pop("DISKCACHE_RS_USE_RUST_PICKLE_BRIDGE", None)
9
+
10
+ import diskcache_rs.rust_pickle as rust_pickle
11
+ from diskcache_rs import rust_pickle_dumps, rust_pickle_loads
12
+
13
+
14
+ def benchmark(label, dumps_fn, loads_fn, payload, iterations=200):
15
+ start = time.perf_counter()
16
+ for _ in range(iterations):
17
+ encoded = dumps_fn(payload)
18
+ _ = loads_fn(encoded)
19
+ elapsed = time.perf_counter() - start
20
+ ops_per_sec = iterations / elapsed if elapsed > 0 else float("inf")
21
+ return {"label": label, "elapsed": elapsed, "ops_per_sec": ops_per_sec}
22
+
23
+
24
+ def print_results(results):
25
+ print("\nPickle path comparison")
26
+ print("=" * 72)
27
+ print(f"{'Path':<24} {'Time':>12} {'Ops/sec':>16} {'Relative'}")
28
+ print("-" * 72)
29
+
30
+ baseline = results[0]["elapsed"]
31
+ for result in results:
32
+ relative = result["elapsed"] / baseline if baseline > 0 else 1.0
33
+ print(
34
+ f"{result['label']:<24} {result['elapsed']:>10.4f}s {result['ops_per_sec']:>14.1f} {relative:>8.2f}x"
35
+ )
36
+
37
+
38
+ def main():
39
+ payload = {
40
+ "text": "diskcache_rs" * 100,
41
+ "numbers": list(range(500)),
42
+ "nested": {"alpha": list(range(50)), "beta": {"ok": True}},
43
+ "binary": b"abc123" * 200,
44
+ }
45
+
46
+ results = [
47
+ benchmark("CPython pickle", pickle.dumps, pickle.loads, payload),
48
+ benchmark("default helper path", rust_pickle.dumps, rust_pickle.loads, payload),
49
+ ]
50
+
51
+ if rust_pickle_dumps is not None and rust_pickle_loads is not None:
52
+ results.append(
53
+ benchmark("direct Rust bridge", rust_pickle_dumps, rust_pickle_loads, payload)
54
+ )
55
+
56
+ print_results(results)
57
+
58
+ if len(results) > 2:
59
+ helper = results[1]
60
+ bridge = results[2]
61
+ if helper["elapsed"] > 0 and bridge["elapsed"] > 0:
62
+ if helper["elapsed"] < bridge["elapsed"]:
63
+ print(
64
+ f"\nDefault helper path is {bridge['elapsed'] / helper['elapsed']:.2f}x faster than the direct bridge."
65
+ )
66
+ else:
67
+ print(
68
+ f"\nDirect bridge is {helper['elapsed'] / bridge['elapsed']:.2f}x faster than the default helper path."
69
+ )
70
+
71
+
72
+ if __name__ == "__main__":
73
+ main()
@@ -97,11 +97,17 @@ bench:
97
97
  @echo "⚡ Running benchmarks..."
98
98
  uv run python -m pytest tests/ -v -k benchmark
99
99
 
100
+ # Compare pickle bridge overhead
101
+ bench-pickle:
102
+ @echo "⚡ Comparing pickle bridge overhead..."
103
+ uv run python benchmarks/pickle_bridge_comparison.py
104
+
100
105
  # Update dependencies
101
106
  update:
102
107
  @echo "⬆️ Updating dependencies..."
103
108
  uv sync --upgrade
104
109
 
110
+
105
111
  # Show project info
106
112
  info:
107
113
  @echo "📊 Project Information:"
@@ -39,8 +39,10 @@ dependencies = [
39
39
  test = [
40
40
  "pytest>=7.0.0",
41
41
  "pytest-benchmark>=4.0.0",
42
+ "pytest-cov>=5.0.0",
42
43
  "psutil>=5.9.0",
43
44
  ]
45
+
44
46
  benchmark = [
45
47
  { include-group = "test" },
46
48
  "diskcache>=5.6.3",