Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

  • Fix regex pattern to handle whitespace/control characters after .aac filenames
  • Move extract_segments_from_playlist() call before removing segments from first playlist
  • Remove noisy trace log showing all 1844 segments
  • Optimize segment search to only look from last requested segment to end (not entire playlist)
  • Add cache size tracking and include in log messages
  • Track last requested segment per channel_id
  • Add segment count to cache logging (in addition to size)
  • Validation complete

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Optimize caching for playlist segments Implement segment precaching for HLS playlist streaming Jan 10, 2026
Copilot AI requested a review from paul-1 January 10, 2026 19:01
Copy link
Owner

@paul-1 paul-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot see comments

also, when logging number of segments to be cached, please include the total size of the cache for that channel


my @segments = ();
for my $line (split /\n/, $content) {
if ($line =~ /\.aac$/) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not finding any lines. there must be whitespace or other control character after the .aac

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 59b9808. Changed regex from /\.aac$/ to /\.aac/ and added explicit removal of carriage returns with $line =~ s/\r//g; to handle whitespace and control characters after the .aac extension.

}

# Extract and store segment list from the playlist
$self->extract_segments_from_playlist($content, $channel_id);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to before we remove the 3 segments from the first playlist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 59b9808. Moved extract_segments_from_playlist() call to before the segment removal logic, so it extracts from the original full playlist before any modifications.

$self->{playlists}->{$channel_id}->{'segments'} = \@segments;

main::log_debug("Extracted " . scalar(@segments) . " segments for channel $channel_id");
main::log_trace("Segments: " . join(", ", @segments));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this log, it is way to noisy. there are 1844 segments in each playlist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 59b9808. Removed the noisy trace log that was printing all 1844 segments. Only kept the debug log showing the segment count.

- Fix regex to handle whitespace/control characters after .aac
- Move segment extraction before playlist modification
- Remove noisy trace log of all segments
- Optimize to only search from last requested segment to end
- Add total cache size to logging output

Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot see comments

also, when logging number of segments to be cached, please include the total size of the cache for that channel

All comments addressed in commit 59b9808. Also added total cache size reporting - logs now show "X uncached segments, current cache size: Y.YY MB" when logging segment caching activity.

Copilot AI requested a review from paul-1 January 10, 2026 19:21
Copy link
Owner

@paul-1 paul-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot see comments

Comment on lines 1130 to 1132
main::log_info("Starting precache of " . scalar(@remaining_segments) .
" segments for channel $channel_id, current cache size: " .
sprintf("%.2f MB", $cache_size / 1024 / 1024));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like to know the number of segments in the cache, in addition to the total size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit a8fd745. Log now shows "current cache: X segments (Y.YY MB)" format, displaying both the segment count and total size.

Include number of cached segments in addition to total size in log messages

Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot see comments

All comments addressed in commit a8fd745. Cache logging now includes both segment count and total size in format: "X segments (Y.YY MB)".

Copilot AI requested a review from paul-1 January 10, 2026 19:42
@paul-1 paul-1 marked this pull request as ready for review January 10, 2026 20:10
@paul-1 paul-1 merged commit 2f656b5 into Optimize_playlist_handling Jan 10, 2026
@paul-1 paul-1 deleted the copilot/sub-pr-56 branch January 10, 2026 20:11
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.

2 participants