lazy_init 0.1.2 → 0.2.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -3
- data/README.md +26 -8
- data/benchmarks/benchmark.rb +616 -145
- data/benchmarks/benchmark_performance.rb +3 -66
- data/benchmarks/benchmark_threads.rb +83 -89
- data/lazy_init.gemspec +1 -0
- data/lib/lazy_init/class_methods.rb +565 -242
- data/lib/lazy_init/instance_methods.rb +90 -66
- data/lib/lazy_init/ruby_capabilities.rb +39 -0
- data/lib/lazy_init/version.rb +1 -1
- data/lib/lazy_init.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3024a39cbf18995df1c62d61d21e7c108be16f92ae8d6e403be33219d33e8194
|
4
|
+
data.tar.gz: 45da9a21782a4b33135e5e535f73cee0b49f9b0e91bc14816dc9b6ae666e7e76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0820f40375bcdfda2f9d4e91610860cfd872e69f4036f181be012b7544422cd8779f53127658bd27427915a0356e1dd79d8a1b5a5b9b8319c821daebe66f01a5'
|
7
|
+
data.tar.gz: f002dc16e9198decc47565e026c7090862acea11aa01774a1ebdace7bee5f64cc2ce2c979595e277438876920668f6a21b787243e5c46586b3dcd8dd5e514482
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,33 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
# 0.2.1 (2025/27/07)
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
- Documentation URL in gem metadata
|
6
|
+
|
7
|
+
# 0.2.0 (2025/25/07)
|
8
|
+
|
9
|
+
### Added
|
10
|
+
- Ruby 3.0+ performance optimizations
|
11
|
+
- Eval-based method generation for 2x faster hot path
|
12
|
+
- Version-specific implementation selection
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Significant performance improvements on Ruby 3.0+
|
16
|
+
- Internal RubyCapabilities module cleanup
|
17
|
+
|
18
|
+
### Performance
|
19
|
+
- Hot path: 1.1x overhead (vs 4.5x on Ruby 2.6)
|
20
|
+
- 50% faster method generation on Ruby 3+
|
21
|
+
|
22
|
+
## 0.1.2 (2025/11/07)
|
2
23
|
|
3
24
|
* Fix bug with missing yard documentation link
|
4
25
|
|
5
|
-
|
26
|
+
## 0.1.1 (2025/06/07)
|
6
27
|
|
7
28
|
* Added YARD configuration for automatic documentation generation
|
8
29
|
* Enhanced code comments for better API documentation
|
9
30
|
|
10
|
-
|
31
|
+
# 0.1.0 (2025/06/07)
|
11
32
|
|
12
33
|
* Initial public release
|
data/README.md
CHANGED
@@ -66,7 +66,7 @@ Or install it yourself as:
|
|
66
66
|
```
|
67
67
|
## Requirements:
|
68
68
|
|
69
|
-
- Ruby 2.6 or higher
|
69
|
+
- Ruby 2.6 or higher (Ruby 3.0+ recommended for best performance)
|
70
70
|
- No external dependencies
|
71
71
|
|
72
72
|
## Quick Start
|
@@ -89,6 +89,7 @@ client.connection # "Establishing connection..." - computed once
|
|
89
89
|
client.connection # Returns cached result (thread-safe)
|
90
90
|
```
|
91
91
|
|
92
|
+
|
92
93
|
### With Dependencies
|
93
94
|
```ruby
|
94
95
|
class WebService
|
@@ -529,15 +530,22 @@ LazyInit is optimized for production use:
|
|
529
530
|
```
|
530
531
|
## Performance
|
531
532
|
|
532
|
-
|
533
|
+
Performance varies by Ruby version:
|
534
|
+
|
535
|
+
**Ruby 3.0+ (Recommended):**
|
536
|
+
- Hot path: 1.1-1.4x overhead
|
537
|
+
- Cold start: ~13-19x overhead
|
538
|
+
- Thread safety: Near-zero overhead
|
539
|
+
|
540
|
+
**Ruby 2.6-2.7:**
|
541
|
+
- Hot path: 4x overhead
|
542
|
+
- Use mainly for expensive operations or critical thread safety
|
533
543
|
|
534
|
-
|
535
|
-
-
|
536
|
-
-
|
537
|
-
-
|
538
|
-
- Trade-off: 3.5x cached access cost for 100% thread safety
|
544
|
+
**Benchmark Summary (Ruby 3.3.1):**
|
545
|
+
- Simple lazy attributes: ~10% overhead
|
546
|
+
- Complex dependencies: 4x overhead
|
547
|
+
- Thread safety: Better than manual synchronization
|
539
548
|
|
540
|
-
[Full details can be found here](https://github.com/N3BCKN/lazy_init/blob/main/benchmarks/benchmark_performance.rb)
|
541
549
|
|
542
550
|
### Optimization Strategies
|
543
551
|
LazyInit automatically selects the best implementation:
|
@@ -546,6 +554,16 @@ LazyInit automatically selects the best implementation:
|
|
546
554
|
- Optimized dependency (single dependency): Balanced performance
|
547
555
|
- Full LazyValue (complex scenarios): Full feature set
|
548
556
|
|
557
|
+
### Ruby Version Comparison
|
558
|
+
|
559
|
+
| Ruby Version | Hot Path Overhead | Best Use Case |
|
560
|
+
|--------------|-------------------|---------------|
|
561
|
+
| 3.3.1 | 1.1x | Production ready everywhere |
|
562
|
+
| 3.0.2 | 1.4x | Production ready everywhere |
|
563
|
+
| 2.7.5 | 3.5x | Expensive operations mainly |
|
564
|
+
| 2.6.6 | 4.3x | Expensive operations mainly |
|
565
|
+
|
566
|
+
|
549
567
|
|
550
568
|
## Thread Safety
|
551
569
|
LazyInit provides comprehensive thread safety guarantees:
|