Skip to content

[BUGFIX] ParticleFile.write and read_particlefile memory footprint - #3083

Merged
erikvansebille merged 4 commits into
Parcels-code:mainfrom
erikvansebille:fix_particlefile_write_read_memory
Dec 1, 2026
Merged

erikvansebille merged 4 commits into
Parcels-code:mainfrom
erikvansebille:fix_particlefile_write_read_memory

Conversation

@erikvansebille

Copy link
Copy Markdown
Member

Description

Following work in the VirtualShip repository (Parcels-code/virtualship#433), I was surprised that the read_particlefile() function had such a large memory footprint. So I compared reading in a 90MB CTD file (see https://surfdrive.surf.nl/s/PsaG23Psn2jpXb4) with parcels.read_particlefile(), polars.read_parquet() and pandas.read_parquet()

With help of CoPilot, I found two issues in our particlefile writing and reading routines:

  1. We wrote a new rowgroup on every call to ParticleFile.write(), even if there were no particles to write. This is now fixed in e191027
  2. We don't read the entire table into memory when we parse the time units

These two changes make writing and reading Parcels parquet files much more efficient

Checklist

  • Tests added
  • This PR targets the correct branch (main for normal development, v3-support for v3 support)

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
    • Describe how you used it (e.g., by pasting your prompt):

I have asked COPilot to help me profile the parcels.read_particlefile() method, and then help me fix its large memory footprint

@ShaivanBhagat ShaivanBhagat left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Is now quicker to load data. Tested using the ctd.parquet file (https://surfdrive.surf.nl/s/PsaG23Psn2jpXb4) against Parcels 4.0.3 (current release)

@erikvansebille
erikvansebille merged commit 2050d93 into Parcels-code:main Dec 1, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants