Skip to content

[Optimize] Switch DirectoryProcessor to in-memory mode (bypassing intermediate disk writes) - #62

Merged
Haralishev77 merged 22 commits into
CAVISE:mainfrom
Parallelogramator:optimization-IO-1
Mar 29, 2026
Merged

[Optimize] Switch DirectoryProcessor to in-memory mode (bypassing intermediate disk writes)#62
Haralishev77 merged 22 commits into
CAVISE:mainfrom
Parallelogramator:optimization-IO-1

Conversation

@Parallelogramator

@Parallelogramator Parallelogramator commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Previously, sensor data was written to disk on every tick and then re-read by BaseDataset to form batches. This caused double I/O, serialization/deserialization overhead, and heavy dependency on disk speed - typical data preparation time ranged from 30–90 ms with spikes up to 350+ ms.

Changes:

  • Refactored DirectoryProcessor into a hybrid class supporting both disk-based and direct in-memory input.
  • Added optional input_data parameter to update_dataset:
    • If provided -> data is taken directly from memory, disk is completely bypassed;
  • Implemented cleanup of the previous tick's in-memory data - only the current frame is kept, preventing memory leaks during long runs.
  • Ensured in-memory data format is 100% identical to what BaseDataset expects from disk files -> no changes required in models or downstream pipeline.

Results (100-tick co-perception scenario):

  • Average time per tick: was ~37–350 ms -> now 0.108 ms
  • Median: 0.092 ms
  • 95th percentile: 0.170 ms
  • Maximum: 0.344 ms

Data preparation accelerated by more than 300× on average and median values. Completely eliminated fsync, file write/read, and directory scanning delays. System no longer depends on storage speed.

How to test:

  • Run a scenario with in-memory mode enabled
  • Compare timing logs for data preparation / dataset update
  • Verify that detections, visualizations, and quality metrics remain identical to the previous version
  • Run a long session (15–60 min) and confirm memory usage stays stable (no growth)

The main bottleneck has now shifted further down the pipeline (inference, post-processing, etc.). A major step toward real-time co-perception performance.

Comment thread opencda/core/common/coperception_model_manager.py Outdated
Comment thread opencda/scenario_testing/scenario.py Outdated
Comment thread opencda/scenario_testing/scenario.py
Comment thread opencda/core/common/coperception_model_manager.py
Comment thread opencda/core/common/coperception_model_manager.py
Comment thread opencda/core/common/test/test_coperception_model_manager.py
@Haralishev77
Haralishev77 merged commit df03306 into CAVISE:main Mar 29, 2026
7 checks passed
Haralishev77 pushed a commit that referenced this pull request Jul 21, 2026
…ermediate disk writes) (#62)

* fix bug with docker

Update mesa-vulkan-drivers to version 25.2.8-0ubuntu0.24.04.1

* fix bug with docker

Update libglib2.0 to version  2.80.0-6ubuntu3.7

* fix bug with name

* first version

* fix bugs with delete directory

* delete pass and update checkers

* fix tests and comments

* add test in memory

* Fix H1 and H2

* Remove comment in clear_directory_now method

* git check

* git check 2

* add empty memory_data test
meaning-0f-life pushed a commit to meaning-0f-life/OpenCDA that referenced this pull request Jul 25, 2026
…ermediate disk writes) (CAVISE#62)

* fix bug with docker

Update mesa-vulkan-drivers to version 25.2.8-0ubuntu0.24.04.1

* fix bug with docker

Update libglib2.0 to version  2.80.0-6ubuntu3.7

* fix bug with name

* first version

* fix bugs with delete directory

* delete pass and update checkers

* fix tests and comments

* add test in memory

* Fix H1 and H2

* Remove comment in clear_directory_now method

* git check

* git check 2

* add empty memory_data test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

982 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants