Skip to content

Conversation

@cbuctok
Copy link
Owner

@cbuctok cbuctok commented Nov 7, 2025

No description provided.

Major performance improvements:
- Base32 Decode: Removed UTF8.GetBytes allocation by working directly with string chars
- IsValidPrefix: Replaced char.IsLower with direct ASCII range checks (a-z)
- IsValidSuffix: Replaced char.IsLetterOrDigit with fast range checks
- Parse: Replaced Split with IndexOf to avoid array allocation
- GuidToUuid/SuffixToGuid: Use Span<byte> with in-place byte swapping instead of Array.Copy
- GetGuid: Use stackalloc and tuple swaps for zero-allocation byte reversal
- Base32.Encode: Implement unsafe EncodeCore with fixed pointers to avoid allocations
- NewTypeId/Constructor: Use TryWriteBytes with stackalloc instead of ToByteArray
- ToString: Use string interpolation instead of concatenation
- Enable unsafe code blocks in project files for maximum performance

All optimizations maintain correctness while significantly reducing memory allocations
and improving execution speed for TypeID generation and parsing operations.
Implemented three automated workflows for continuous integration and testing:

1. Main CI Pipeline (ci.yml):
   - Multi-version .NET testing (6.0.x, 8.0.x)
   - Build verification in Debug and Release modes
   - Comprehensive test execution
   - Code formatting validation
   - NuGet package creation
   - Artifact uploading

2. Performance Testing (performance.yml):
   - Dedicated performance benchmarks
   - Target: <0.003ms per TypeID generation
   - Scheduled weekly runs (Mondays 9 AM UTC)
   - Detailed performance metrics reporting
   - Encode/decode performance validation

3. Pull Request Validation (pr-validation.yml):
   - Automated PR testing
   - Spec compliance validation
   - Code coverage reporting
   - API compatibility checks
   - Non-draft PR filtering

Additional improvements:
- Added workflow documentation in .github/workflows/README.md
- Updated main README.md with CI status badges
- Configured triggers for main/master/develop branches
- Added manual workflow dispatch options
- Comprehensive test output in GitHub Actions summaries

All workflows follow best practices with proper error handling,
detailed reporting, and efficient resource usage.
Critical fixes:
1. CI Workflow (.github/workflows/ci.yml):
   - Separated library build (multi-version) from tests (.NET 8.0 only)
   - Build library on both .NET 6.0.x and 8.0.x for compatibility
   - Run tests only on .NET 8.0 (matches test project target)
   - Updated job dependencies and status checks

2. Base32 Encoding (TypeId/Base32JetPack.cs):
   - Removed unsafe pointer code that could cause invalid memory access
   - Replaced unsafe EncodeCore with safe stackalloc implementation
   - Span<byte> overload now uses direct encoding to stackalloc'd chars
   - Byte array overload uses string.Create for zero-allocation
   - All encoding paths remain highly optimized and allocation-free

3. Project Configuration:
   - Removed AllowUnsafeBlocks from both .csproj files
   - Code is now safer and more maintainable without unsafe blocks

These fixes resolve:
- Test failures on .NET 6.0 (tests require .NET 8.0)
- Potential memory safety issues with unsafe pointer passing
- Build errors related to unsafe code

All optimizations maintained while improving code safety and reliability.
Critical fixes:
1. Validation Job (ci.yml):
   - Added restore dependencies step before building
   - Added build step before packing NuGet package
   - Changed pack command to use --no-build flag
   - Fixes error: DLL not found when packing

The validation job now properly:
- Restores dependencies
- Builds the library in Release configuration
- Packs the NuGet package from the built DLL
- Uploads artifacts correctly
@cbuctok cbuctok merged commit 2ec7cbb into main Nov 7, 2025
10 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.

3 participants