Skip to content

Code formatting and performance optimizations#3

Merged
naftaly merged 2 commits intomainfrom
code-formatting-and-optimizations
Nov 30, 2025
Merged

Code formatting and performance optimizations#3
naftaly merged 2 commits intomainfrom
code-formatting-and-optimizations

Conversation

@naftaly
Copy link
Copy Markdown
Owner

@naftaly naftaly commented Nov 30, 2025

Summary

  • Add .swiftformat configuration file for consistent code style
  • Apply code formatting across the codebase
  • Run memory and disk cache operations concurrently in forEachResource using async let
  • Remove unnecessary async from cost() and costLimit() methods
  • Optimize purgeUnowned() to use single-pass instead of multiple array iterations
  • Add test for purgeUnowned behavior

Test plan

  • Run existing test suite (33 tests passing)
  • Verify formatting is consistent
  • Verify optimizations don't change behavior

- Add .swiftformat configuration file
- Remove .swift-version file
- Apply consistent code formatting across codebase
- Optimize MemoryArsenal set operation to reduce lookups
- Update tests and benchmarks
@naftaly naftaly force-pushed the code-formatting-and-optimizations branch from 1c6df18 to 0d5774e Compare November 30, 2025 16:50
- Run memory and disk operations concurrently in forEachResource using async let
- Remove unnecessary async from cost() and costLimit() methods
- Optimize purgeUnowned() to use single-pass instead of multiple array iterations
- Add test for purgeUnowned behavior
@naftaly naftaly changed the title Add swiftformat and apply code formatting Code formatting and performance optimizations Nov 30, 2025
Repository owner deleted a comment from github-actions Bot Nov 30, 2025
@github-actions
Copy link
Copy Markdown

🚀 Arsenal Cache Performance Benchmarks

Multi-layer caching with LRU eviction and disk persistence

Test Hardware: Apple M1 (Virtual), 7 GB RAM

Memory Cache Operations

Operation Items Time Per-Op Status
Get 1000 166.0ms 166.0 μs ⚠️ OK
Set 1000 172.0ms 172.0 μs ⚠️ OK
Set (with purge) 500 200.0ms 400.0 μs ⚠️ OK

Disk Cache Operations

Operation Items Time Per-Op Status
Get 100 154.0ms 1.54 ms ✅ Excellent
Set 100 132.0ms 1.32 ms ✅ Excellent

Combined Cache (Memory + Disk)

Operation Items Time Per-Op Status
Get (disk→memory promotion) 100 126.0ms 1.26 ms ✅ Excellent
Set (both layers) 100 667.0ms 6.67 ms ✅ Good

Large Items (1 MB each)

Storage Items Time Per-Item Status
Disk 20 155ms 7.8ms ✅ Excellent
Memory 50 147ms 2.9ms ✅ Excellent

Throughput (Mixed Read/Write)

Operation Ops Time Ops/sec Status
Memory (33% write, 67% read) 5,000 201ms 24,876 ⚠️ OK

Clear Operations

Storage Items Time Status
Disk 100 152ms ✅ Good
Memory 1000 179ms ✅ Good

Performance Characteristics

Status Legend

  • Excellent/Good: Optimal performance
  • ⚠️ OK: Acceptable, monitor in production
  • Review: May need optimization

Architecture

  • Memory cache: LRU eviction with cost-based limits
  • Disk cache: File-based with staleness and cost eviction
  • Combined: Automatic disk→memory promotion on read
  • Thread safety: @globalActor isolation via ArsenalActor

Total benchmarks: 12 passed | Generated 2025-11-30 17:15:28

@naftaly naftaly marked this pull request as ready for review November 30, 2025 17:17
@naftaly naftaly merged commit 641e62e into main Nov 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant