Skip to content

Conversation

@dachengx
Copy link
Collaborator

@dachengx dachengx commented Aug 14, 2025

What is the problem / what does the code in this PR do

import straxen  # e9fe5dd7fb61fb537d35732730b41639ebc39980
import saltax  # e100810ad106351ef1180499889257d59c97ed90

st = saltax.contexts.sxenonnt(
    saltax_mode="salt",
    generator_name="ybe",
    recoil=0,
    rate=10,
    simu_mode="all",
    simulation_config="sr2_dev",
    corrections_version="global_v18",
    output_folder="strax_data",
)

run_id = "047967"
st.is_stored(run_id, "peaklets", chunk_number={"raw_records": [0, 1, 2]})

First get the efficiency of the above codes:

python -m cProfile -o output.prof test_chunks.py
gprof2dot -f pstats output.prof | dot -Tsvg -o profile.svg

The most significant part is

image

This is because when chunk_number is not None, strax before this PR will not cache plugins, so every time building the lineage of a higher plugin, the __get_plugin will be called.

Can you briefly describe how it works?

This PR makes sure that whenever chunk_number is None or not, the plugin (whose lineage does not include chunk_number) is cached. Then I designed a dedicated function to assign the chunk_number in lineage afterwards.

Can you give a minimal working example (or illustrate with a figure)?

Please include the following if applicable:

  • Update the docstring(s)
  • Update the documentation
  • Tests to check the (new) code is working as desired.
  • Does it solve one of the open issues on github?

Please make sure that all automated tests have passed before asking for a review (you can save the PR as a draft otherwise).

plugin_copy.__setattr__(attribute, copy(source_value))
return plugin_copy

def __deepcopy__(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is essentially a bug. __deepcopy__ never works because deepcopy(plugin.deps) will also call __deepcopy__. plugin.deps is a dictionary of plugins.

@dachengx dachengx force-pushed the faster_add_lineage_to_plugin branch 3 times, most recently from d18855f to cc95e64 Compare August 14, 2025 19:56
@coveralls
Copy link

coveralls commented Aug 14, 2025

Coverage Status

coverage: 88.915% (-0.04%) from 88.958%
when pulling ecaab74 on faster_add_lineage_to_plugin
into cd79adc on master.

@dachengx dachengx force-pushed the faster_add_lineage_to_plugin branch from cc95e64 to efc64bf Compare August 14, 2025 20:52
@dachengx dachengx marked this pull request as ready for review August 14, 2025 21:10
@dachengx dachengx force-pushed the faster_add_lineage_to_plugin branch from efc64bf to ecaab74 Compare August 14, 2025 23:00
@dachengx dachengx merged commit 49559c1 into master Aug 15, 2025
7 checks passed
@dachengx dachengx deleted the faster_add_lineage_to_plugin branch August 15, 2025 17:34
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