Skip to content

Conversation

@mgyoo86
Copy link
Contributor

@mgyoo86 mgyoo86 commented Oct 27, 2025

Summary

Adds comprehensive @compile_workload to significantly reduce TTFX (time to first execution) for common IMASdd operations. While this increases initial precompile (one-time cost) and load time (costs per session), it delivers dramatic improvements in runtime performance for frequently used functions.

Performance Impact

One-Time (& per-session) Costs

Metric Before After Impact
Precompile time ~80s ~180s +100s (installation only)
Package load time (using IMASdd) ~1s ~4s +3s (per session)

Runtime Performance Gains

Operation Before After Speedup
hdf2imas() 33s 0.1s 330×
json2imas() 16s 0.07s 228×
imas2hdf() 15s 0.2s 75×
imas2json() 7.5s 0.02s 375×
deepcopy(dd) 17s 0.01s 1700×
dd1==dd2 3.6s 0.03s 120×
REPL display slow instant significant

Trade-off Analysis

Cost: +3 seconds per IMASdd loading
Benefit: Save 10~30 seconds on every file I/O operation

For typical workflows with I/O operations, the net time savings are substantial after the first operation.

Changes

  • Created src/precompile_workload.jl with comprehensive workload
  • Precompiles: file I/O (HDF5, JSON), equality, deepcopy, REPL display
  • Uses mktempdir() for safe temporary file cleanup
  • Uses devnull output to avoid precompile clutter

Developer Notes

Most developers/users rarely modify IMASdd, making the +100s precompile increase a true one-time installation cost. For active development, the workload can be disabled by PrecompileTools.jl with Preferences.jl

- Move precompile workload to dedicated precompile_workload.jl
- Add file I/O precompilation with safe mktempdir cleanup
- Precompile REPL display methods using devnull output
- Include equality, deepcopy operations in workload
@mgyoo86 mgyoo86 requested review from bclyons12 and orso82 October 27, 2025 23:26
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.72%. Comparing base (7056800) to head (2982449).

Files with missing lines Patch % Lines
src/precompile_workload.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   43.73%   43.72%   -0.01%     
==========================================
  Files          13       14       +1     
  Lines       31230    31230              
==========================================
- Hits        13657    13655       -2     
- Misses      17573    17575       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bclyons12
Copy link
Member

Thanks @mgyoo86! This has been on my radar for a while. As you say, there are trade-offs, which for the average user is probably worthwhile, but it's not clear to me how many users vs developers we have. On top of that, we do release a new version of IMASdd every few weeks, so that precompile price gets paid for users when they upgrade as well. Maybe the paces of our releases will decrease

@fredrikekre is working on some improvements to IMASdd that would hopefully help with precompilation and compilation time. I think we should put this on hold for a bit and have it be part of a more comprehensive improvement to compilation. An alternative might be to have the default maintain precompilation off and have users opt in with Preferences.jl for now.

@bclyons12
Copy link
Member

It looks like this shouldn't apply, but we should be careful that we don't invalidate any of this precompilation in IMAS.jl, like we used to in the expressions (see ProjectTorreyPines/IMAS.jl#276 and #77)

@mgyoo86 After precompilation, please import IMASdd, run timings for these functions, then in the same session import IMAS and run the same functions with IMAS. to make sure they don't recompile.

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.

3 participants