Skip to content

Conversation

@paulomorgado
Copy link
Contributor

@paulomorgado paulomorgado commented Jun 30, 2025

NEW FEATURES:

  • turns implementation

PERFORMANCE OPTIMIZATIONS:

Memory Management:

  • Add PooledSegmentedBuffer<T> for efficient buffer pooling with ArrayPool<T> integration
  • Implement MemoryOperations helper for optimized memory operations
  • Add ValueStringBuilder for stack-allocated string building to reduce heap allocations
  • Introduce SearchValues for optimized span-based searching
  • Use NetEscapades.EnumGenerators to optimize enum usage.

Socket and Network Layer:

  • Refactor NetServices with connection pooling and reduced allocations
  • Add SocketConnection abstraction with concrete implementations (SocketTcpConnection,
    SocketUdpConnection, SocketTlsConnection) for better resource management
  • Optimize IPSocket with span-based parsing and reduced string allocations
  • Enhance PortRange with improved allocation patterns

System Utilities:

  • Add BinaryOperations for bit manipulation optimizations
  • Implement EncodingExtensions for efficient encoding/decoding operations
  • Add HashExtensions for streamlined hash computations

Crypto and Security:

  • Refactor Crypto class with reduced allocations
  • Add SslClientAuthenticationOptions and SslStreamExtensions for down-level targets
  • Optimize CRC32 implementation

Data Serialization:

  • Add SipSorceryJsonSerializerContext for AOT-friendly JSON serialization
  • Remove legacy JSONWriter and JsonParser in favor of System.Text.Json

Protocol Implementations:

  • Optimize RTP/RTCP packet handling with span-based operations
  • Refactor SCTP chunks for reduced allocations
  • Improve SDP parsing with ValueStringBuilder
  • Optimize STUN attribute handling

Codec Optimizations:

  • Extensive refactoring of codes to optimize memory usage
  • Update AudioEncoder with more efficient buffer handling

HIGH-PERFORMANCE LOGGING:

Structured Logging Infrastructure:

  • Introduce LoggerMessageAttribute source generator pattern across all modules
  • Add domain-specific logging extensions for compile-time log message generation

Benefits:

  • Zero-cost logging when log level is disabled
  • Compile-time string formatting
  • Reduced memory allocations in hot paths
  • Type-safe structured logging
  • Improved debuggability with consistent log patterns

MODERNIZATION:

  • Standardize on .NET 10.0 and C# 14.0
    • Used Meziantou.Polyfill for down-level targets
      • Added other polyfills to keep the source code clean of conditional compilation symbols.
    • Introduce BouncyCastleExtensions for down-level targets

RETARGETING:

  • Removed .NET Framework targets from libraries
  • Keep dependencies on the lowest supported LTS version for non-.NET targets
  • Target the same channel for supported .NET targets

SUPPORTING CHANGES:

Type System:

  • Refactor TypeExtensions
  • Add IByteSerializable interface for consistent serialization
  • Add ProtocolTypeExtensions for protocol type handling

Testing:

Supersedes #1335, #1338, #1407, #1414, #1423

@paulomorgado paulomorgado force-pushed the turns branch 13 times, most recently from aadd289 to 007701a Compare January 6, 2026 18:48
NEW FEATURES:

- turns implementation

PERFORMANCE OPTIMIZATIONS:

Memory Management:
- Add PooledSegmentedBuffer<T> for efficient buffer pooling with ArrayPool<T> integration
- Implement MemoryOperations helper for optimized memory operations
- Add ValueStringBuilder for stack-allocated string building to reduce heap allocations
- Introduce SearchValues for optimized span-based searching
- Replace BufferUtils with more efficient memory operation primitives
- Use NetEscapades.EnumGenerators to optimize enum usage.

Socket and Network Layer:
- Refactor NetServices with connection pooling and reduced allocations
- Add SocketConnection abstraction with concrete implementations (SocketTcpConnection,
  SocketUdpConnection, SocketTlsConnection) for better resource management
- Optimize IPSocket with span-based parsing and reduced string allocations
- Enhance PortRange with improved allocation patterns

System Utilities:
- Add BinaryOperations for bit manipulation optimizations
- Implement EncodingExtensions for efficient encoding/decoding operations
- Add HashExtensions for streamlined hash computations

Crypto and Security:
- Refactor Crypto class with reduced allocations
- Add SslClientAuthenticationOptions and SslStreamExtensions for down-level targets
- Optimize CRC32 implementation

Data Serialization:
- Add SipSorceryJsonSerializerContext for AOT-friendly JSON serialization
- Remove legacy JSONWriter and JsonParser in favor of System.Text.Json

Protocol Implementations:
- Optimize RTP/RTCP packet handling with span-based operations
- Refactor SCTP chunks for reduced allocations
- Improve SDP parsing with ValueStringBuilder
- Optimize STUN attribute handling

Codec Optimizations:
- Extensive refactoring of codes to otpimize memory usage
- Update AudioEncoder with more efficient buffer handling

HIGH-PERFORMANCE LOGGING:

Structured Logging Infrastructure:
- Introduce LoggerMessage source generator pattern across all modules
- Add domain-specific logging extensions for compile-time log message generation

Benefits:
- Zero-cost logging when log level is disabled
- Compile-time string formatting
- Reduced memory allocations in hot paths
- Type-safe structured logging
- Improved debuggability with consistent log patterns

MODERNIZATION:

- Standardize on .NET 10.0 and C# 14.0
  - Used Meziantou.Polyfill for down-level targets
    - Added other polyfills to keep the source code clean of conditional compilation symbols.
  - Introduce BouncyCastleExtensions for down-level targets

SUPPORTING CHANGES:

Type System:
- Refactor TypeExtensions
- Add IByteSerializable interface for consistent serialization
- Add ProtocolTypeExtensions for protocol type handling

Testing:
- Update existing tests to use new optimized APIs
- Replaced Serilog with MartinCostello.Logging.XUnit
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