Skip to content

Feature/epg refresh performance optimization#317

Merged
ProdigyV21 merged 3 commits into
ProdigyV21:mainfrom
saidai-bhuvanesh:feature/epg-refresh-performance-optimization
Jun 5, 2026
Merged

Feature/epg refresh performance optimization#317
ProdigyV21 merged 3 commits into
ProdigyV21:mainfrom
saidai-bhuvanesh:feature/epg-refresh-performance-optimization

Conversation

@saidai-bhuvanesh
Copy link
Copy Markdown
Contributor

📝 Description

This PR introduces a set of reliability and performance improvements for the IPTV and EPG loading pipeline.

Reliability Improvements

XMLTV Parsing Optimization

Improved BackslashEscapeSanitizingInputStream to correctly process bulk reads used by XML parsers.

Previously, sanitization logic was only applied to single-byte reads, allowing malformed XMLTV data to bypass sanitization during normal parser execution.

The implementation now performs efficient block-based sanitization while preserving compatibility with existing XMLTV workflows.

Concurrent Playlist Aggregation Safety

Resolved a concurrency issue during simultaneous playlist loading where channel aggregation callbacks could trigger ConcurrentModificationException while playlists were being processed concurrently.

Channel snapshots are now generated using synchronized access before UI updates are dispatched.


Performance Improvements

Guide Key Candidate Caching

Added an in-memory cache for guide key candidate generation to reduce repeated normalization and alias generation work during EPG matching.

HTTP Conditional Requests

Added support for:

  • ETag caching
  • Last-Modified caching
  • HTTP 304 Not Modified handling

This allows unchanged EPG sources to reuse existing guide data without reprocessing large XMLTV datasets.

Incremental EPG Refresh

Improved refresh workflows to avoid unnecessary index persistence and guide regeneration when XMLTV content has not changed.

This reduces disk operations and refresh overhead for large IPTV installations.


Test Coverage

Added dedicated tests covering:

  • XMLTV sanitization bulk reads
  • Escape sequence boundary conditions
  • Trailing escape handling
  • Concurrent playlist aggregation safety
  • Guide key cache behavior
  • HTTP 304 EPG refresh handling

Benefits

  • Improved IPTV stability
  • Improved EPG reliability
  • Reduced concurrent update failures
  • Reduced EPG processing overhead
  • Improved guide refresh performance
  • Better scalability for large IPTV libraries

Testing

  • Verified IPTV playlist loading
  • Verified EPG refresh workflows
  • Verified XMLTV parsing behavior
  • Verified cache behavior
  • Verified concurrency handling
  • Added automated regression tests

@ProdigyV21
Copy link
Copy Markdown
Owner

Looks good to me. I tested it against latest main: it merges cleanly, Play/Sideload Kotlin compile passes, and the new IPTV optimization tests pass.

Only small cleanup: git diff --check reports trailing whitespace in IptvRepository.kt and IptvRepositoryOptimizationTest.kt. This is not a runtime/app issue, just invisible extra spaces at the end of some lines, but it can fail style/CI checks and is easy to clean.

After that, I think this is safe to merge. Also PR317 includes the same core fixes as PR316 plus extra EPG performance work, so we probably don’t need PR316 separately if this one is merged.

@saidai-bhuvanesh
Copy link
Copy Markdown
Contributor Author

saidai-bhuvanesh commented Jun 5, 2026 via email

@ProdigyV21
Copy link
Copy Markdown
Owner

PR317 now conflicts with latest main because PR316 has already been merged.

Please rebase PR317 on latest main and keep the PR316 changes that are already there. Then reapply only the extra PR317 parts: guide-key candidate caching, ETag/Last-Modified/HTTP 304 handling, and incremental EPG refresh persistence changes.

Current conflicts are in:

  • IptvRepository.kt
  • IptvRepositoryOptimizationTest.kt

After it merges cleanly again, I can retest compile and unit tests. Same in PR318 you did.

@saidai-bhuvanesh
Copy link
Copy Markdown
Contributor Author

saidai-bhuvanesh commented Jun 5, 2026 via email

@saidai-bhuvanesh saidai-bhuvanesh force-pushed the feature/epg-refresh-performance-optimization branch from 93e3709 to 376d266 Compare June 5, 2026 14:35
@ProdigyV21 ProdigyV21 merged commit 25ce683 into ProdigyV21:main Jun 5, 2026
1 check 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