From 3bf7d3c192845351f298438c751b744148d63e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Fri, 8 Nov 2024 13:18:27 +0100 Subject: [PATCH] Sync tweak --- bin/servers.ml | 1 + lib/db/sync.ml | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/servers.ml b/bin/servers.ml index 76f85b6..e3cb66b 100644 --- a/bin/servers.ml +++ b/bin/servers.ml @@ -174,6 +174,7 @@ let ui () = Lwd_seq.map (fun (_, server) -> ui_status server) servers_with_status in let ui_form = + (* FIXME: user can validate multiple times *) Lwd.map servers_with_status ~f:(fun s -> match Lwd_seq.view s with | Empty -> Lwd_seq.element @@ Elwd.div [ `R (ui_form ()) ] diff --git a/lib/db/sync.ml b/lib/db/sync.ml index ac769b2..c7c632e 100644 --- a/lib/db/sync.ml +++ b/lib/db/sync.ml @@ -32,7 +32,7 @@ open Source.Api prefixed by one of the view's virtual folder locations. *) -let chunk_size = 2000 +let chunk_size = 500 let include_item_types = [ Source.Api.Item.MusicArtist; MusicAlbum; Audio; MusicGenre; Genre ] @@ -353,7 +353,7 @@ let sync ?(report = fun _ -> ()) ~(source : Source.connexion) idb = in enqueue ~start_index:first total; let total_queries = Queue.length fetch_queue in - let rec run_queue ?(threads = 2) q = + let rec run_queue ?(threads = 4) q = assert (threads > 0); let rec take_n acc n = if n = 0 then List.rev acc @@ -367,6 +367,7 @@ let sync ?(report = fun _ -> ()) ~(source : Source.connexion) idb = We could send the next request while handling the previous results. This should speed up the process a lot. (Also there might be opportunities to speed up result handling.) *) + (* TODO: there's a stack overflow somewhere...*) let f req = let+ { Api.Items.start_index; items; _ } = query source (module Api.Items) req ()