Skip to content

chore: Refactor global_properties to use the registry pattern#873

Merged
RobertJacobsonCDC merged 3 commits into
mainfrom
RobertJacobsonCDC_862_global_properties_registry
May 7, 2026
Merged

chore: Refactor global_properties to use the registry pattern#873
RobertJacobsonCDC merged 3 commits into
mainfrom
RobertJacobsonCDC_862_global_properties_registry

Conversation

@RobertJacobsonCDC
Copy link
Copy Markdown
Collaborator

@RobertJacobsonCDC RobertJacobsonCDC commented May 4, 2026

This PR refactors global property storage out of the data plugin system and into Context directly. The original hash map based storage is replaced with the "registry pattern" we use for data plugins, entities, and other things elsewhere: set_global_property_value and get_global_property_value now index directly into Context::global_properties using T::id().

I also removed the unused string-based getter mechanism.

Unfortunately, the name-based registration and loading machinery is otherwise left intact, so load_global_properties, add_global_property, and the serialized lookup path continue to work through the existing accessors. The reason is that the load_global_properties uses a string name-based lookup, and it's not clear how to refactor this while also retaining source compatibility with existing code.

On the other hand, if we are willing to break source compatibility, we might as well wait until we have a better idea of the alternative design for global parameters in order to do so, so we don't give client code whiplash.

Client code should remain source compatible for this PR.

@github-actions

This comment was marked as outdated.

github-actions Bot added a commit that referenced this pull request May 4, 2026
github-actions Bot added a commit that referenced this pull request May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Benchmark Results

Hyperfine

Command Mean [ms] Min [ms] Max [ms] Relative
large_sir::baseline 3.0 ± 0.1 2.9 3.8 1.00
large_sir::entities 6.6 ± 0.1 6.5 6.8 2.20 ± 0.11

Criterion

Regressions (slower)
Group Bench Param Change CI Lower CI Upper
sampling sampling_single_known_length_entities 25.543% 24.393% 26.773%
large_dataset bench_query_population_indexed_property_entities 21.255% 18.639% 24.043%
sampling count_and_sampling_single_known_length_entities 17.456% 16.939% 17.796%
indexing query_people_single_indexed_property_entities 9.118% 8.951% 9.256%
large_dataset bench_filter_unindexed_entity 9.087% 2.904% 15.515%
sample_entity sample_entity_single_property_indexed 100000 9.014% 7.967% 10.284%
indexing query_people_multiple_individually_indexed_properties_entities 7.082% 5.388% 8.729%
algorithm_benches algorithm_sampling_single_known_length 6.138% 5.592% 6.704%
sample_entity sample_entity_single_property_indexed 10000 5.075% 4.756% 5.387%
sampling sampling_multiple_unindexed_entities 4.735% 4.683% 4.793%
sampling sampling_single_unindexed_entities 4.642% 4.411% 4.993%
large_dataset bench_match_entity 4.535% 2.444% 6.726%
sample_entity sample_entity_single_property_indexed 1000 3.715% 3.463% 3.962%
indexing with_query_results_single_indexed_property_entities 2.820% 2.406% 3.197%
sample_entity sample_entity_single_property_unindexed 100000 2.479% 2.159% 2.805%
sampling sampling_multiple_known_length_entities 2.456% 2.017% 3.061%
counts multi_property_indexed_entities 2.055% 1.902% 2.205%
sample_entity sample_entity_multi_property_indexed 1000 1.651% 1.075% 2.592%
Improvements (faster)
Group Bench Param Change CI Lower CI Upper
indexing query_people_count_single_indexed_property_entities -5.297% -5.736% -4.756%
algorithm_benches algorithm_sampling_multiple_l_reservoir -5.190% -5.714% -4.570%
sample_entity sample_entity_whole_population 1000 -4.228% -4.796% -3.613%
algorithm_benches algorithm_sampling_multiple_known_length -4.155% -4.605% -3.797%
large_dataset bench_query_population_derived_property_entities -3.966% -5.994% -1.960%
sample_entity sample_entity_whole_population 100000 -3.936% -4.492% -3.200%
sample_entity sample_entity_whole_population 10000 -3.932% -4.163% -3.666%
counts single_property_indexed_entities -3.861% -4.554% -3.192%
indexing query_people_indexed_multi-property_entities -3.582% -4.980% -2.057%
sampling count_and_sampling_single_unindexed_concrete_plus_derived_entiti -2.246% -2.294% -2.158%
indexing query_people_count_indexed_multi-property_entities -2.078% -2.484% -1.608%
sampling sampling_single_unindexed_concrete_plus_derived_entities -1.577% -1.838% -1.316%
sampling sampling_multiple_l_reservoir_entities -1.480% -1.658% -1.310%
Unchanged / inconclusive (CI crosses 0%)
Group Bench Param Change CI Lower CI Upper
large_dataset bench_filter_indexed_entity -2.163% -12.642% 10.177%
examples example-births-deaths 1.079% 0.555% 1.629%
indexing query_people_count_multiple_individually_indexed_properties_enti -0.961% -1.545% -0.402%
sample_entity sample_entity_multi_property_indexed 10000 0.857% 0.432% 1.151%
counts multi_property_unindexed_entities -0.790% -1.079% -0.404%
sample_entity sample_entity_multi_property_indexed 100000 0.765% 0.269% 1.142%
algorithm_benches algorithm_sampling_single_l_reservoir -0.570% -0.869% -0.266%
sample_entity sample_entity_single_property_unindexed 10000 -0.529% -1.034% 0.052%
counts reindex_after_adding_more_entities 0.444% 0.203% 0.679%
sample_entity sample_entity_single_property_unindexed 1000 -0.364% -0.925% 0.166%
algorithm_benches algorithm_sampling_single_rand_reservoir -0.314% -1.015% 0.167%
large_dataset bench_query_population_multi_indexed_entities 0.239% -0.167% 0.595%
examples example-basic-infection 0.223% -0.284% 0.706%
large_dataset bench_query_population_property_entities -0.194% -0.829% 0.348%
sampling sampling_single_l_reservoir_entities 0.148% -0.071% 0.371%
counts concrete_plus_derived_unindexed_entities -0.120% -0.633% 0.357%
counts index_after_adding_entities 0.119% -0.094% 0.323%
large_dataset bench_query_population_multi_unindexed_entities 0.114% -0.160% 0.508%
indexing with_query_results_indexed_multi-property_entities -0.088% -0.621% 0.600%
indexing with_query_results_multiple_individually_indexed_properties_enti -0.074% -0.362% 0.406%
counts single_property_unindexed_entities 0.005% -0.603% 0.540%

@RobertJacobsonCDC RobertJacobsonCDC linked an issue May 5, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@k88hudson-cfa k88hudson-cfa left a comment

Choose a reason for hiding this comment

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

This looks good with a couple of small cleanup things. For the record I don't believe the which/that change is justified, but I wouldn't block on it

Comment thread src/global_properties.rs Outdated
Comment thread src/macros/define_global_property.rs
@RobertJacobsonCDC
Copy link
Copy Markdown
Collaborator Author

For the record I don't believe the which/that change is justified, but I wouldn't block on it

Alright, alright! Reverted!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Benchmark Results

Hyperfine

Command Mean [ms] Min [ms] Max [ms] Relative
large_sir::baseline 2.8 ± 0.0 2.7 2.9 1.00
large_sir::entities 5.6 ± 0.2 5.4 7.0 2.01 ± 0.09

Criterion

Regressions (slower)
Group Bench Param Change CI Lower CI Upper
sample_entity sample_entity_single_property_unindexed 1000 27.404% 26.874% 28.108%
examples example-basic-infection 17.103% 16.334% 17.850%
sample_entity sample_entity_single_property_unindexed 10000 9.651% 8.994% 10.463%
algorithm_benches algorithm_sampling_single_known_length 5.245% 4.666% 5.691%
algorithm_benches algorithm_sampling_multiple_known_length 3.572% 3.251% 3.943%
sample_entity sample_entity_single_property_unindexed 100000 3.278% 2.643% 4.045%
sample_entity sample_entity_multi_property_indexed 10000 3.043% 2.512% 3.460%
counts reindex_after_adding_more_entities 3.013% 2.608% 3.569%
sample_entity sample_entity_multi_property_indexed 100000 2.912% 2.714% 3.113%
sample_entity sample_entity_multi_property_indexed 1000 2.666% 2.315% 3.270%
counts single_property_indexed_entities 2.609% 2.370% 2.839%
large_dataset bench_query_population_derived_property_entities 2.315% 2.121% 2.504%
indexing query_people_count_indexed_multi-property_entities 1.699% 1.486% 1.954%
sampling sampling_single_unindexed_entities 1.590% 1.341% 1.819%
Improvements (faster)
Group Bench Param Change CI Lower CI Upper
counts multi_property_unindexed_entities -16.303% -16.843% -15.615%
large_dataset bench_query_population_indexed_property_entities -12.845% -15.015% -10.731%
sample_entity sample_entity_single_property_indexed 10000 -12.172% -12.378% -11.976%
sample_entity sample_entity_single_property_indexed 1000 -11.933% -12.475% -11.412%
sample_entity sample_entity_single_property_indexed 100000 -11.647% -12.119% -11.232%
sampling sampling_multiple_l_reservoir_entities -5.758% -6.689% -4.906%
sampling sampling_single_known_length_entities -3.871% -4.482% -3.315%
examples example-births-deaths -2.315% -2.598% -2.012%
Unchanged / inconclusive (CI crosses 0%)
Group Bench Param Change CI Lower CI Upper
sample_entity sample_entity_whole_population 1000 -2.334% -4.936% -0.475%
large_dataset bench_filter_unindexed_entity -1.950% -6.347% 2.487%
large_dataset bench_match_entity -1.723% -4.644% 1.390%
indexing with_query_results_single_indexed_property_entities -1.462% -2.079% -0.941%
counts single_property_unindexed_entities 1.355% 0.384% 2.854%
indexing with_query_results_multiple_individually_indexed_properties_enti -1.107% -1.862% -0.157%
counts concrete_plus_derived_unindexed_entities 1.063% -0.347% 3.674%
indexing query_people_single_indexed_property_entities -0.829% -1.473% -0.205%
sample_entity sample_entity_whole_population 10000 -0.751% -1.324% -0.368%
indexing with_query_results_indexed_multi-property_entities 0.738% 0.443% 1.157%
indexing query_people_indexed_multi-property_entities 0.729% 0.324% 1.100%
sampling count_and_sampling_single_known_length_entities -0.701% -1.405% 0.005%
indexing query_people_multiple_individually_indexed_properties_entities 0.695% -0.076% 1.377%
counts multi_property_indexed_entities 0.667% 0.477% 0.856%
large_dataset bench_query_population_multi_unindexed_entities -0.639% -1.334% -0.039%
large_dataset bench_filter_indexed_entity 0.589% -10.415% 13.282%
sample_entity sample_entity_whole_population 100000 -0.586% -0.934% -0.170%
indexing query_people_count_multiple_individually_indexed_properties_enti 0.579% 0.034% 1.012%
counts index_after_adding_entities 0.577% 0.332% 0.864%
large_dataset bench_query_population_multi_indexed_entities 0.424% 0.172% 0.752%
sampling sampling_single_unindexed_concrete_plus_derived_entities 0.422% 0.050% 0.791%
sampling sampling_single_l_reservoir_entities 0.419% -0.371% 1.244%
algorithm_benches algorithm_sampling_single_l_reservoir -0.332% -0.497% -0.181%
sampling count_and_sampling_single_unindexed_concrete_plus_derived_entiti -0.313% -0.644% 0.050%
sampling sampling_multiple_unindexed_entities 0.297% 0.006% 0.727%
indexing query_people_count_single_indexed_property_entities -0.265% -0.890% 0.268%
algorithm_benches algorithm_sampling_single_rand_reservoir 0.256% 0.059% 0.486%
algorithm_benches algorithm_sampling_multiple_l_reservoir 0.148% -0.219% 0.481%
sampling sampling_multiple_known_length_entities -0.082% -0.478% 0.302%
large_dataset bench_query_population_property_entities 0.069% -0.370% 0.653%

github-actions Bot added a commit that referenced this pull request May 6, 2026
@RobertJacobsonCDC RobertJacobsonCDC merged commit 439d515 into main May 7, 2026
22 checks passed
@RobertJacobsonCDC RobertJacobsonCDC deleted the RobertJacobsonCDC_862_global_properties_registry branch May 7, 2026 16:10
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.

Refactor global properties to use the "registry pattern"

3 participants