Repository navigation
feat(logbook_position_control): réutiliser un buffer mer précalculé entre appels - #16
Closed
JulienLebranchu wants to merge 1 commit into
Conversation
…r across calls Extracts the sea-buffering logic (simplify + terra::buffer, previously inline) into a new exported build_sea_buffer(dataframe3, buffer_sea, simplify_tolerance) helper, and adds an optional `sea_buffer` argument to logbook_position_control(). When NULL (default), behaviour is unchanged: the sea buffer is computed internally exactly as before. When provided, the (dominant) buffering step is skipped entirely and the precomputed sf object is used directly. Rationale: shape_sea is a session-level referential in callers like AkadoR, but logbook_position_control() is called every time a user (re-)runs a check within that same session, recomputing the identical buffer each time. See #13 for the original investigation. Targeted measurement (3 consecutive calls, same R process, real data: 1130 activities / 49 trips): | call 1 | call 2 | call 3 no caching | 6.39s | 6.49s | 6.19s precomputed | 0.54s | 0.46s | 0.36s (+5.96s paid once upfront) -> ~12-17x faster per repeated call once the buffer is precomputed. Peak memory (RSS) was comparable between the two scenarios at this data scale (~545-555 MiB either way) now that #13's simplify_tolerance fix is applied in both cases, so the measured gain here is on runtime, not memory, at this scale. Output verified identical() between logbook_position_control() called with sea_buffer = NULL vs sea_buffer = build_sea_buffer(...). Existing doctest for logbook_position_control unchanged and passing.
Collaborator
|
Je ferme cette issue, le patch sf::st_simplify() est implémenté directement dans AkadoR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15.
Empilée sur #14 (branche de base :
fix/logbook_position_control-buffer-performance) — merge/review #14 en premier.Changement
build_sea_buffer(dataframe3, buffer_sea = 925, simplify_tolerance = 50): extrait la logique de simplification + bufferisation de la mer, déjà présente danslogbook_position_control().sea_buffer = NULLsurlogbook_position_control():NULL(défaut) → comportement identique à aujourd'hui, aucun changement pour les appelants existants (ex. AkadoR n'a rien à modifier).Pas de changement cassant : paramètre additionnel, opt-in.
Mesure (détail dans #15)
3 appels consécutifs, même process R, données réelles (1130 activités / 49 marées) :
sea_bufferprécalculé (coût payé une fois : 5.96s)~12-17x plus rapide par appel répété. Pas de gain mémoire net mesuré à cette échelle (pic RSS comparable, ~545-555 Mio dans les deux cas) — #14 suffit déjà à stabiliser la mémoire pour ce volume ; le gain ici est sur le temps d'exécution.
Vérification
identical()==TRUEentre un appelsea_buffer = NULLet un appelsea_buffer = build_sea_buffer(...).logbook_position_controlinchangé et passant.build_sea_buffer(vérifie la structure de sortie).Usage côté appelant (ex. AkadoR)