Skip to content

Optimize opacity data reading performance#360

Draft
natashabatalha wants to merge 1 commit into
gridtreefrom
optimize-opacity-reads-2624491173451506681
Draft

Optimize opacity data reading performance#360
natashabatalha wants to merge 1 commit into
gridtreefrom
optimize-opacity-reads-2624491173451506681

Conversation

@natashabatalha
Copy link
Copy Markdown
Owner

This PR addresses the performance bottleneck in reading monochromatic opacities from SQLite databases.

Key improvements:

  1. SQLite Indexing: New databases now include indexes on (molecule, ptid) and (molecule, temperature), significantly speeding up targeted queries.
  2. NumPy Vectorization: Replaced slow Python loops for PT point matching in optics.py with vectorized broadcasting and np.argmin, reducing overhead for many-layer atmospheres.
  3. HDF5 Backend: Introduced HDF5 as an alternative storage format for monochromatic opacities. HDF5 is ~3-4x faster than indexed SQLite for this use case and handles large numerical arrays more efficiently.
  4. Migration Utility: Provided convert_sqlite_to_h5 to allow users to upgrade their existing databases to the faster format.
  5. Robustness: Fixed file handle management and redundant file opening in the HDF5 implementation.

Benchmarks showed up to 17x speedup over the original unindexed SQLite implementation and ~4x speedup over the optimized indexed SQLite for realistic monochromatic opacity reads.


PR created automatically by Jules for task 2624491173451506681 started by @natashabatalha

…support

- Added SQLite indexes to `molecular` and `continuum` tables for faster queries.
- Vectorized PT point identification and nearest neighbor search in `optics.py` using NumPy.
- Implemented HDF5 support in `RetrieveOpacities` for high-performance monochromatic opacity reading.
- Added `convert_sqlite_to_h5` utility in `opacity_factory.py` for database migration.
- Optimized HDF5 data retrieval with unique index sorting and vectorized slicing.
- Fixed potential file handle leaks and redundant I/O in HDF5 backend.

Co-authored-by: natashabatalha <6554465+natashabatalha@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant