Skip to content

perf: reduce CLI startup overhead - #171

Merged
galjos merged 5 commits into
devfrom
perf/startup-overhead
Aug 11, 2026
Merged

perf: reduce CLI startup overhead#171
galjos merged 5 commits into
devfrom
perf/startup-overhead

Conversation

@galjos

@galjos galjos commented Aug 11, 2026

Copy link
Copy Markdown
Member

Changes

  • Lazy-load package exports and unified CLI commands.
  • Reuse the RDF input batch for cell setup and histogramming.
  • Batch exact MSD calculations for changing orthorhombic cells.
  • Preserve bounded-memory fallbacks and the public msd, rdf, and vacf exports.

Performance

Cold-process startup against dev (cc67f768):

Command dev PR Speedup
Root help 287 ms 83 ms 3.47x
VACF help 469 ms 410 ms 1.15x
MSD help 385 ms 280 ms 1.38x
RDF help 322 ms 268 ms 1.20x
Momentum help 373 ms 303 ms 1.23x

Real-trajectory medians at b67b7fc; seven rotated rounds after one warmup, one fresh process per run, and legacy C compiled with -O2:

Analysis Legacy C PQAnalysis Speedup
VACF 0.775 s 0.417 s 1.86x
MSD 2.183 s 0.448 s 4.87x
RDF 1.926 s 1.363 s 1.41x
Combined 4.885 s 2.228 s 2.19x

Correctness

  • MSD is bitwise identical to exact streaming on the 75,000-frame changing-box trajectory.
  • RDF is bitwise identical to legacy C on the 12,500-frame, 428-atom trajectory.
  • Boundary coverage includes empty files, changing and unsupported cells, half-box ties, parser failures, memory limits, and one-atom self-selection.

Validation

  • DEBUG: 948 passed, 4 skipped
  • RELEASE: 948 passed, 4 skipped
  • PQEnalyzer: 272 passed
  • Pylint: 9.78/10
  • Sphinx and all GitHub/Codecov checks passed

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.17355% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.86%. Comparing base (cc67f76) to head (576eb98).

Files with missing lines Patch % Lines
PQAnalysis/__init__.py 0.00% 1 Missing ⚠️
PQAnalysis/_lazy_import.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #171      +/-   ##
==========================================
+ Coverage   93.82%   93.86%   +0.03%     
==========================================
  Files         176      177       +1     
  Lines        9108     9215     +107     
==========================================
+ Hits         8546     8650     +104     
- Misses        562      565       +3     
Flag Coverage Δ
unittests 93.86% <99.17%> (+0.03%) ⬆️
Files with missing lines Coverage Δ
PQAnalysis/analysis/__init__.py 100.00% <100.00%> (ø)
PQAnalysis/analysis/momentum/momentum.py 100.00% <100.00%> (ø)
PQAnalysis/analysis/msd/msd.py 99.38% <100.00%> (-0.02%) ⬇️
PQAnalysis/analysis/rdf/rdf.py 99.50% <100.00%> (+0.02%) ⬆️
PQAnalysis/analysis/vacf/vacf.py 99.59% <100.00%> (ø)
PQAnalysis/cli/_argument_parser.py 98.21% <100.00%> (+0.10%) ⬆️
PQAnalysis/cli/main.py 98.00% <100.00%> (+0.77%) ⬆️
PQAnalysis/core/__init__.py 100.00% <100.00%> (ø)
PQAnalysis/formats.py 100.00% <100.00%> (ø)
PQAnalysis/io/__init__.py 100.00% <100.00%> (ø)
... and 13 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

PYLINT REPORT

Your code has been rated at 9.78/10

Full report

Raw metrics

type number % previous difference
code 15638 45.62 NC NC
docstring 13023 37.99 NC NC
comment 463 1.35 NC NC
empty 5152 15.03 NC NC

Duplication

now previous difference
nb duplicated lines 0 NC NC
percent duplicated lines 0.000 NC NC

Messages by category

type number previous difference
convention 15 NC NC
refactor 134 NC NC
warning 17 NC NC
error 5 NC NC

% errors / warnings by module

module error warning refactor convention
PQAnalysis.type_checking 40.00 0.00 0.00 0.00
PQAnalysis.atomic_system.atomic_system 20.00 11.76 6.72 0.00
PQAnalysis.analysis.vibrational.vibrational_analysis 20.00 0.00 7.46 0.00
PQAnalysis 20.00 0.00 0.00 0.00
PQAnalysis.analysis.vacf._vacf_kernel_py 0.00 11.76 1.49 0.00
PQAnalysis.tools.traj_to_com_traj 0.00 11.76 0.00 0.00
PQAnalysis.io.traj_file._process_lines_py 0.00 11.76 0.00 0.00
PQAnalysis.io.moldescriptor_reader 0.00 11.76 0.00 0.00
PQAnalysis.tools.add_molecule 0.00 5.88 4.48 0.00
PQAnalysis.analysis.rdf._rdf_kernel_py 0.00 5.88 2.24 0.00
PQAnalysis.analysis.msd._msd_kernel_py 0.00 5.88 2.24 0.00
PQAnalysis.io.conversion_api 0.00 5.88 1.49 0.00
PQAnalysis.version 0.00 5.88 0.00 0.00
PQAnalysis.utils.custom_logging 0.00 5.88 0.00 0.00
PQAnalysis.io.write_api 0.00 5.88 0.00 0.00
PQAnalysis.core.atom.element 0.00 0.00 14.18 13.33
PQAnalysis.analysis.rdf.rdf 0.00 0.00 6.72 6.67
PQAnalysis.analysis.msd.msd 0.00 0.00 5.97 33.33
PQAnalysis.io.nep.nep_writer 0.00 0.00 5.22 6.67
PQAnalysis.analysis.vacf.vacf 0.00 0.00 4.48 13.33
PQAnalysis.io.traj_file._slab_parser_py 0.00 0.00 3.73 0.00
PQAnalysis.analysis.vacf.spectrum 0.00 0.00 3.73 0.00
PQAnalysis.io.traj_file.trajectory_reader 0.00 0.00 2.99 0.00
PQAnalysis.topology.bonded_topology.dihedral 0.00 0.00 2.24 0.00
PQAnalysis.core.residue 0.00 0.00 2.24 0.00
PQAnalysis.topology.bonded_topology.bonded_topology 0.00 0.00 1.49 0.00
PQAnalysis.topology.bonded_topology.bond 0.00 0.00 1.49 0.00
PQAnalysis.topology.bonded_topology.angle 0.00 0.00 1.49 0.00
PQAnalysis.io.traj_file.raw_frame_reader 0.00 0.00 1.49 0.00
PQAnalysis.core.cell.cell 0.00 0.00 1.49 0.00
PQAnalysis.atomic_system._standard_properties 0.00 0.00 1.49 0.00
PQAnalysis.analysis.vacf.api 0.00 0.00 1.49 0.00
PQAnalysis.analysis.spectrum_broadening.api 0.00 0.00 1.49 0.00
PQAnalysis.analysis.momentum.api 0.00 0.00 1.49 0.00
PQAnalysis.analysis.vibrational.vibrational_input_file_reader 0.00 0.00 0.75 6.67
PQAnalysis.traj.formats 0.00 0.00 0.75 0.00
PQAnalysis.topology.topology 0.00 0.00 0.75 0.00
PQAnalysis.topology.selection 0.00 0.00 0.75 0.00
PQAnalysis.io.traj_file.frame_reader 0.00 0.00 0.75 0.00
PQAnalysis.io.restart_file.restart_reader 0.00 0.00 0.75 0.00
PQAnalysis.io.input_file_reader.pq_analysis._parse 0.00 0.00 0.75 0.00
PQAnalysis.io.input_file_reader.pq.pq_input_file_reader 0.00 0.00 0.75 0.00
PQAnalysis.io.input_file_reader.input_file_parser 0.00 0.00 0.75 0.00
PQAnalysis.io.info_file_reader 0.00 0.00 0.75 0.00
PQAnalysis.io.formats 0.00 0.00 0.75 0.00
PQAnalysis.analysis.momentum.momentum 0.00 0.00 0.75 0.00
PQAnalysis.analysis.vacf.vacf_input_file_reader 0.00 0.00 0.00 6.67
PQAnalysis.analysis.rdf.rdf_input_file_reader 0.00 0.00 0.00 6.67
PQAnalysis.analysis.msd.msd_input_file_reader 0.00 0.00 0.00 6.67

Messages

message id occurrences
too-many-positional-arguments 29
too-many-arguments 29
duplicate-code 19
too-many-locals 15
too-many-instance-attributes 13
invalid-name 12
too-complex 9
inconsistent-return-statements 8
fixme 7
too-many-branches 5
missing-type-doc 4
too-many-return-statements 3
too-many-lines 3
unused-import 2
too-many-statements 2
redefined-builtin 2
missing-kwoa 2
use-set-for-membership 1
unexpected-keyword-arg 1
too-many-public-methods 1
possibly-used-before-assignment 1
no-member 1
missing-param-doc 1
arguments-differ 1

@galjos
galjos merged commit bd55571 into dev Aug 11, 2026
8 checks passed
@galjos
galjos deleted the perf/startup-overhead branch August 11, 2026 20:03
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