Veet import efficiency - #90
Open
ThomasKraft wants to merge 3 commits into
Open
Conversation
…s to improve both memory efficiency and speed for the large files produced by VEETs. Versions of these and other strategies were tested and although data.table() approaches performed the best, it seemed prudent to introduce minimal changes within the tidyverse style in order to maintain consistency in the package.
Add data.table as an explicit package import and update the VEET import expression to parse modality-filtered rows with data.table::fread using explicit column names and column classes. Per-file VEET results are combined with data.table::rbindlist, and file.name plus Datetime are added/reordered by reference to reduce conversion and copy overhead versus the previous vroom/list_rbind/dplyr mutate path. Reduce downstream memory pressure for large VEET TOF imports by narrowing duplicate detection to likely duplicate Id/Datetime rows before doing full-row duplicate counting, and by using a minimal Id/Datetime data frame for the VEET TOF auto.plot overview so gap detection does not scan all 256 TOF measurement columns. Keep the public VEET API unchanged after removing the experimental low.memory/chunk.size approach, since the observed allocation failure is caused by final object size rather than chunked import intermediates. Add regression coverage for typed TOF imports and the lightweight TOF auto.plot path.
There was a problem hiding this comment.
Pull request overview
Improves performance and memory characteristics of VEET imports (especially TOF) by switching to data.table-based parsing and by reducing costly work during duplicate detection and auto-plotting.
Changes:
- Refactor VEET import expression to use
data.table::fread()andrbindlist()with explicit column typing. - Optimize duplicate detection to avoid full-width scans unless duplicates are plausible, and avoid expensive gap detection during TOF auto-plot.
- Add VEET-focused tests, update
NEWS.md, and adddata.tableto package imports.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
R/import_expressions.R |
Reworks VEET import parsing to use data.table and sets Datetime via data.table::set(). |
R/import_LL.R |
Optimizes duplicate detection prefiltering and special-cases VEET/TOF auto-plot to skip gap finding. |
tests/testthat/test-import_LL.R |
Adds VEET/TOF import and auto-plot tests. |
DESCRIPTION |
Adds data.table as an imported dependency. |
NEWS.md |
Documents VEET import efficiency improvements and TOF-specific optimizations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This PR stems from issue #85 and generally attempts to speed up and manage memory efficiency for VEET import, which can cause particular problems due to the large nature of data types such as TOF. Speed is improved here using the
data.tablepackage for import. There are also some relevant changes for auto.plot defaults when TOF data are imported to avoid unnecessary processing time. The basic testing code pasted below shows a general outcome I found of these changes cutting VEET import processing time by ~50%:Ultimately I discovered that VEET files are large enough that the main memory issue occurs simply due to using
map:::purr()on files that are of sufficient size to overwhelm a normal laptop when they are all loaded into memory. Packages such as GGIR manage this same type of issue by batch loading files and processing them into epochs in chunks before discarding the raw files during the process. Although something similar could be done here, the LightLogR infrastructure is sufficient for doing this manually with a short custom scripts (which is currently working well for me). So, I favor not introducing any changes for now.Basic benchmarking code: