Opened 20 months ago

Closed 6 months ago

#14644 closed defect (fixed)

Faster DICOM map registration

Reported by: Eric Pettersen Owned by: Zach Pearson
Priority: moderate Milestone:
Component: Performance Version:
Keywords: Cc: Tom Goddard
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Because add_map_format() is done from a custom initialization, many DICOM modules are imported at startup, which IIRC slows startup on my home Mac by 0.5 seconds.

Looks awkward to fix without switching to a manager/provider protocol for adding map formats, because the public chimerax.dicom API would have to change significantly to avoid imports in the __init__.py file.

Change History (4)

comment:1 by Tom Goddard, 20 months ago

There are 32 bundles that use customInit. It would be worth seeing how much all of these are impacting startup time by commenting out the customInit code in bundle_builder.py. I tried it and it made no discernible difference on my 2023 Mac Studio probably because everything was in memory cache. I tried purging the disk memory cache (sudo purge) and it got very slightly slower, about 3 dock bounces instead of 2 before the gui appears (about 1.5 seconds instead of 1 second without purge). I know it is much slower on a cold start, like 20-30 seconds, and I'd like to see the impact of all those customInits on a cold start. Apparently purge does not allow that test, probably because the SSD drive has its on flash-cache that is not cleared.

Eric, when you report slower startup by 0.5 seconds due to DICOM is that from a cold start (ie after a computer restart so nothing is in memory or ssd cache)?

comment:2 by Zach Pearson, 20 months ago

I'll get some flamegraph data on customInits for this ticket.

I like giving people the option to import things from the top-level init, but it's not a strict requirement (and AFAICT no one uses the bundle but me). Shouldn't be hard to remove all the unncessary imports and move the others inline if profiling data proves it to be much faster.

comment:3 by Eric Pettersen, 20 months ago

On my admittedly slow 2015 desktop iMac, chimerax.dicom's init takes between 0.44 and 0.64 seconds -- that is just using it normally, no cold boot. To measure that, I put time.time() calls at the start and the end of the init.

comment:4 by Zach Pearson, 6 months ago

Resolution: fixed
Status: assignedclosed

I think this ticket was probably addressed as part of the performance tuning in #16959, but feel free to reopen if you feel DICOM initialization is still too slow.

Note: See TracTickets for help on using tickets.