ThreadSafeCollections-FP v0.8.0 Release Notes
Documentation home ยท Current changelog
Historical release snapshot. This document records v0.8.0 and may contain older APIs, measurements, toolchains, or support statements. Use the current documentation for the present checkout.
Audience: users researching the v0.8.0 release and project maintainers.
Release Date: 2025-12-16
Overview#
Version 0.8.0 is a major performance-focused release that delivers significant speed improvements across all collection types while maintaining 100% backward compatibility. This release focuses on optimizing the underlying data structures and algorithms without changing any public APIs.
๐ Highlights#
Performance Improvements#
- TThreadSafeDeque: 5-10x faster with new circular array implementation
- TThreadSafeList: 2-3x faster bulk operations with smart pre-allocation
- TThreadSafeDictionary & TThreadSafeHashSet: 1.5-2x faster bulk operations
- Memory efficiency: Up to 100x fewer allocations for deque operations
- Cache locality: Dramatically improved with contiguous memory layout
Key Changes#
- Deque Architecture Rewrite (Breaking Performance Improvement)
- Converted from linked-list to circular array-based implementation
- Eliminated per-item heap allocations (New/Dispose calls removed)
- Power-of-2 capacity sizing for efficient modulo operations
- 100% API compatible - no code changes required
- List Pre-allocation Strategy
- New optional constructor:
Create(AComparer, AInitialCapacity) - Default initial capacity increased from 0 to 16 elements
- Smart growth: 2x for small lists, 1.5x for large lists
- Optimized
AddRangewith single pre-calculated resize
- Hash Table Bulk Optimization
AddRangemethods now pre-calculate required capacity- Single resize operation instead of multiple cascading resizes
- Reduced lock contention during bulk operations
๐ Performance Metrics#
Theoretical Improvements#
| Operation | Pre-v0.8 | v0.8 | Improvement |
|---|---|---|---|
| Deque: Push/Pop | O(1) with heap allocation | O(1) stack-based | ~5-10x faster |
| Deque: 1000 items | ~1000 allocations | ~10 allocations | ~100x fewer allocations |
| List: AddRange(1000) | ~10 resizes | ~1 resize | ~10x fewer resizes |
| List: Memory growth | 100% (doubles) | 50% (large lists) | ~33% less memory waste |
| HashSet: AddRange(1000) | Multiple resizes | Single resize | ~2-5x faster |
| Memory fragmentation | High (linked-list) | Low (array-based) | Significantly improved |
Real-world Characteristics#
From test suite execution (116 tests):
- List sorting (100k items): ~200-350ms
- Hash operations (10k items): <10ms for add/contains
- Concurrent access: Maintains thread safety with minimal overhead
- Deque operations: Now O(1) push/pop with better constant factors
๐ง Technical Details#
Memory Management Improvements#
- Deque: Eliminated heap allocations for individual nodes, reducing memory fragmentation
- List: Smarter capacity growth reduces wasted allocations
- Hash Tables: Pre-calculation prevents intermediate resize operations
Algorithm Optimizations#
- Deque: Circular array with bitwise AND for wraparound (efficient modulo)
- List: Geometric growth with size-dependent strategy
- Hash Tables: Bulk operation optimization with single resize
๐ API Changes#
New Constructors (Optional)#
TThreadSafeList:
// Before (still works):
List := specialize TThreadSafeList<Integer>.Create(@IntegerComparer);
// After (optional optimization):
List := specialize TThreadSafeList<Integer>.Create(@IntegerComparer, 1000);TThreadSafeDeque:
// Before (still works):
Deque := specialize TThreadSafeDeque<Integer>.Create;
// After (optional optimization):
Deque := specialize TThreadSafeDeque<Integer>.Create(1000);Behavior Changes#
- List initial capacity: Changed from 0 to 16 (performance optimization)
- Deque initial capacity: Changed from 0 to 16 (performance optimization)
All existing code continues to work without modifications.
โ Backward Compatibility#
100% backward compatible - All existing code will work without any changes.
- All public APIs remain unchanged
- All method signatures preserved
- All behaviors maintained (except performance improvements)
- Existing constructors still work as before
- New constructors are optional enhancements
๐งช Testing#
All optimizations verified with comprehensive test suite:
- โ 116 tests passing
- โ Thread safety verified with concurrent access tests
- โ Memory management tested with stress tests
- โ Hash collision handling verified
- โ Bulk operations tested with large datasets
- โ Iterator functionality confirmed
- โ Edge cases covered (empty collections, single items, etc.)
๐ซ Deferred Features#
The following optimizations were considered but deferred to future releases:
- Read-write locks (
TMultiReadExclusiveWriteSynchronizer)
- Would allow concurrent reads
- Requires extensive refactoring
- Planned for future release
- Lock-free atomic operations
- For simple checks (IsEmpty, Count)
- Requires significant architecture changes
- Planned for future release
๐ฆ Installation#
No installation changes - same as previous versions:
- Clone or download the repository
- Add
srcdirectory to your project's search path - Add units to your uses clause as needed
๐ Resources#
- Repository: https://github.com/ikelaiah/threadsafecollections-fp
- Documentation: See ../index.md
- Full Changelog: See CHANGELOG.md
- Issues: https://github.com/ikelaiah/threadsafecollections-fp/issues
๐ Acknowledgments#
- Free Pascal and Lazarus community
- FPCUnit testing framework
- All contributors and testers
โ ๏ธ Important Notes#
For Production Use#
This library is primarily a learning tool. For production applications, consider:
Upgrading from v0.7.x#
Simply replace your existing source files. No code changes required.
If you want to take advantage of the new performance optimizations:
- Use the new constructors with capacity hints when you know approximate collection sizes
- Recompile your application to pick up the performance improvements
---
What's Next?
Future releases will focus on:
- Read-write lock support for concurrent reads
- Lock-free operations for performance-critical paths
- Additional specialized collection types
- More comprehensive benchmarking suite
Thank you for using ThreadSafeCollections-FP!