mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-04 06:52:26 +02:00
Playlist Update Optimization: Reduced Memory Usage
An optimization has been introduced to reduce memory consumption during playlist updates.
Overview
Previously, provider playlists were fully loaded into memory during the update process. For large playlists (e.g. hundreds of thousands of entries or multiple providers), this could result in significant RAM usage.
With the new implementation, it is now possible to optionally read provider playlists directly from disk instead of keeping them entirely in memory.
How It Works
- users can configure whether:
- Provider playlists are loaded into memory (previous behavior), or
- Provider playlists are streamed to/from disk to minimize RAM usage.
Processing remains sequential and batch-based, ensuring identical functional behavior.
This approach significantly lowers peak memory usage, especially on systems with limited resources.
Benefits
- Reduced peak RAM consumption during playlist updates
- Better scalability for large playlists and multiple providers
- Full backward compatibility
Trade-offs / Drawbacks
- Increased processing time due to reduced in-memory caching
- Higher disk I/O usage, especially for large or fragmented playlists
- Performance depends more strongly on disk speed (Nvme SSD, HDD)
- Slightly increased CPU overhead due to repeated parsing and deserialization
- Not optimal for environments where fast updates are more important than memory usage
Recommendation
- Use in-memory mode for systems with sufficient RAM and a focus on update speed
- Use disk-based mode for large playlists, multiple providers, or memory-constrained environments
This commit is contained in:
@@ -319,7 +319,7 @@ async fn playlist_download_from_input(client: &reqwest::Client, app_config: &Arc
|
||||
let (p, e) = m3u::download_m3u_playlist(client, config, input).await;
|
||||
(p, e, false)
|
||||
}
|
||||
InputType::Xtream => xtream::download_xtream_playlist(config, client, input, clusters_to_download.as_deref()).await,
|
||||
InputType::Xtream => xtream::download_xtream_playlist(app_config, client, input, clusters_to_download.as_deref()).await,
|
||||
InputType::M3uBatch | InputType::XtreamBatch => (vec![], vec![], false),
|
||||
InputType::Library => {
|
||||
let (p, e) = library::download_library_playlist(client, app_config, input).await;
|
||||
@@ -398,14 +398,13 @@ async fn process_source(source_idx: usize, ctx: &PlaylistProcessingContext) -> (
|
||||
(playlist, download_err)
|
||||
};
|
||||
|
||||
let (tvguide, mut tvguide_errors) = if input.input_type == InputType::Library {
|
||||
(None, vec!())
|
||||
let tvguide = if input.input_type == InputType::Library {
|
||||
None
|
||||
} else {
|
||||
download_input_epg(ctx,input, &mut errors).await
|
||||
download_input_epg(ctx,input, &mut error_list).await
|
||||
};
|
||||
|
||||
errors.append(&mut error_list);
|
||||
errors.append(&mut tvguide_errors);
|
||||
let group_count = playlist_groups.get_group_count();
|
||||
let channel_count = playlist_groups.get_channel_count();
|
||||
let input_name = &input.name;
|
||||
@@ -455,16 +454,16 @@ async fn process_source(source_idx: usize, ctx: &PlaylistProcessingContext) -> (
|
||||
}
|
||||
|
||||
async fn download_input_epg(ctx: &PlaylistProcessingContext, input: &Arc<ConfigInput>,
|
||||
error_list: &mut [TuliproxError]) -> (Option<TVGuide>, Vec<TuliproxError>) {
|
||||
error_list: &mut Vec<TuliproxError>) -> Option<TVGuide> {
|
||||
// Download epg for input
|
||||
let (tvguide, tvguide_errors) = if error_list.is_empty() {
|
||||
debug!("Downloading epg for input '{}'", input.name);
|
||||
let (tvguide, mut tvguide_errors) = if error_list.is_empty() {
|
||||
let working_dir = &ctx.config.config.load().working_dir;
|
||||
epg::get_xmltv(ctx, input, working_dir).await
|
||||
} else {
|
||||
(None, vec![])
|
||||
};
|
||||
(tvguide, tvguide_errors)
|
||||
error_list.append(&mut tvguide_errors);
|
||||
tvguide
|
||||
}
|
||||
|
||||
async fn download_input(ctx: &PlaylistProcessingContext, input: &Arc<ConfigInput>)
|
||||
|
||||
Reference in New Issue
Block a user