Skip to content

chore: Index multi-properties by default - #951

Open
cdc-as81 wants to merge 8 commits into
mainfrom
cdc-as81-multi-properties-should-be-indexed-by-default
Open

chore: Index multi-properties by default#951
cdc-as81 wants to merge 8 commits into
mainfrom
cdc-as81-multi-properties-should-be-indexed-by-default

Conversation

@cdc-as81

@cdc-as81 cdc-as81 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make define_multi_property! create a FullIndex by default via
    Property::default_index_type.
  • Allow a multi-property definition to opt into ValueCountIndex or opt out
    with PropertyIndexType::Unindexed.
  • Preserve feat: Replace universal Property: Eq + Hash constraint with IndexableProperty #937’s no-shared-storage design: equivalent multi-properties remain
    distinct, while the first registered representative handles query routing and
    is the only one eligible for a default index.
  • Keep explicit Context::index_property calls compatible with populated
    multi-properties, including default-indexed and unindexed definitions.
  • Update documentation and regression coverage for defaults, overrides,
    equivalent property ordering, and explicit indexing.

@cdc-as81 cdc-as81 linked an issue Jun 10, 2026 that may be closed by this pull request
github-actions Bot added a commit that referenced this pull request Jun 10, 2026
@RobertJacobsonCDC

Copy link
Copy Markdown
Collaborator

I think this needs to be blocked by #937. Also, it's not clear which kind of index should be created. We should discuss how this interacts with these issues, too:

@RobertJacobsonCDC RobertJacobsonCDC added blocked Currently blocked by another issue needs discussion Needs discussion before implementation labels Jun 11, 2026
@github-actions

This comment was marked as outdated.

github-actions Bot added a commit that referenced this pull request Jun 25, 2026
@CDCgov CDCgov deleted a comment from github-actions Bot Jun 29, 2026
@cdc-as81

Copy link
Copy Markdown
Collaborator Author

lets add an option to the macro to set the index type.
property_store.set_property_indexed::

(PropertyIndexType::FullIndex);

@github-actions

This comment was marked as outdated.

github-actions Bot added a commit that referenced this pull request Jun 29, 2026

@RobertJacobsonCDC RobertJacobsonCDC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PR #937 removed sharing indexes between properties. This PR appears to reintroduce shared properties. I don't think we want to do this. Instead, let's retain the warning and error behavior explicitly introduced in #937. I think this will simplify this PR quite a bit.

There's also the philosophical question of whether we want to expose Property::default_index_type as public API. So for example, we could add a parameter to define_*_property! / impl_*_property that lets client code set the return value of Property::default_index_type. But let's defer that question to another issue / PR. (I don't think we have a use case for it, so let's not pay the cost of added code complexity.)

Comment thread docs/book/src/topics/properties.md Outdated
Comment thread docs/book/src/topics/indexing.md Outdated
Comment thread src/entity/query/mod.rs
Comment thread src/entity/context_extension.rs Outdated
Comment thread src/entity/property_store.rs Outdated
Comment thread src/entity/property_value_store_core.rs Outdated
Comment thread src/entity/property_value_store_core.rs Outdated
@cdc-as81

Copy link
Copy Markdown
Collaborator Author

Fixed. Equivalent multi-properties now use distinct storage; only the registered representative receives the default index.

@github-actions

This comment was marked as outdated.

github-actions Bot added a commit that referenced this pull request Jul 10, 2026
@github-actions

This comment was marked as outdated.

github-actions Bot added a commit that referenced this pull request Jul 10, 2026
github-actions Bot added a commit that referenced this pull request Jul 21, 2026
@github-actions

Copy link
Copy Markdown

Benchmark Results

Hyperfine

Command Mean [ms] Min [ms] Max [ms] Relative
large_sir::baseline 3.3 ± 0.2 3.2 4.1 1.01 ± 0.07
large_sir::baseline_households 3.3 ± 0.1 3.2 3.8 1.00
large_sir::entities 6.8 ± 0.1 6.6 7.2 2.09 ± 0.06
large_sir::households 6.7 ± 0.2 6.6 7.7 2.06 ± 0.07

Criterion

Regressions (slower)
Group Bench Param Change CI Lower CI Upper
counts reindex_after_adding_more_entities 106.944% 104.144% 109.654%
counts single_property_unindexed_entities 88.449% 85.879% 91.241%
counts concrete_plus_derived_unindexed_entities 79.153% 77.898% 80.473%
large_dataset bench_filter_indexed_entity 73.882% 71.210% 76.647%
counts multi_property_unindexed_entities 52.587% 51.541% 53.603%
counts index_after_adding_entities 34.896% 33.865% 35.969%
sample_entity sample_entity_single_property_unindexed 100000 31.209% 30.618% 31.711%
sampling sampling_single_unindexed_concrete_plus_derived_entities 18.833% 14.473% 23.570%
sample_entity sample_entity_whole_population 1000 9.646% 7.097% 12.142%
indexing with_query_results_single_indexed_property_entities 9.548% 7.854% 11.345%
sampling sampling_single_known_length_entities 8.258% 6.011% 10.705%
sample_entity sample_entity_whole_population 100000 8.205% 5.189% 11.092%
indexing query_people_indexed_multi-property_entities 5.295% 4.894% 5.744%
examples example-basic-infection 4.606% 3.764% 5.504%
sample_entity sample_entity_single_property_unindexed 10000 4.226% 3.881% 4.497%
indexing query_people_multiple_individually_indexed_properties_entities 2.843% 2.452% 3.263%
sampling sampling_multiple_l_reservoir_entities 2.631% 2.209% 3.267%
indexing query_people_count_multiple_individually_indexed_properties_enti 1.906% 1.799% 2.013%
Improvements (faster)
Group Bench Param Change CI Lower CI Upper
large_dataset bench_query_population_multi_unindexed_entities -99.262% -99.281% -99.247%
large_dataset bench_match_entity -25.058% -25.259% -24.858%
sample_entity sample_entity_whole_population 10000 -23.076% -24.616% -21.430%
large_dataset bench_query_population_indexed_property_entities -13.469% -14.039% -13.055%
sample_entity sample_entity_single_property_indexed 100000 -7.888% -10.116% -5.687%
sample_entity sample_entity_multi_property_indexed 100000 -7.030% -8.256% -5.921%
sampling sampling_single_unindexed_entities -6.068% -6.297% -5.793%
sample_entity sample_entity_multi_property_indexed 10000 -5.963% -7.676% -4.310%
sample_entity sample_entity_multi_property_indexed 1000 -5.147% -6.692% -3.612%
sampling sampling_multiple_unindexed_entities -3.850% -4.225% -3.488%
sample_entity sample_entity_single_property_indexed 1000 -3.203% -5.345% -1.053%
large_dataset bench_query_population_derived_property_entities -2.637% -3.001% -2.306%
sampling count_and_sampling_single_unindexed_concrete_plus_derived_entiti -2.030% -2.202% -1.869%
sampling sampling_multiple_known_length_entities -1.695% -1.797% -1.581%
sampling sampling_single_l_reservoir_entities -1.693% -2.263% -1.030%
large_dataset bench_query_population_multi_indexed_entities -1.621% -1.995% -1.150%
indexing query_people_single_indexed_property_entities -1.501% -1.621% -1.364%
Unchanged / inconclusive (CI crosses 0%)
Group Bench Param Change CI Lower CI Upper
algorithm_benches algorithm_sampling_single_rand_reservoir 1.737% 0.595% 2.976%
indexing with_query_results_indexed_multi-property_entities -1.693% -2.859% -0.691%
examples example-births-deaths -1.663% -4.343% 0.593%
sample_entity sample_entity_single_property_indexed 10000 1.489% 0.315% 2.694%
sample_entity sample_entity_single_property_unindexed 1000 1.100% 0.855% 1.321%
counts single_property_indexed_entities -1.097% -1.698% -0.460%
indexing with_query_results_multiple_individually_indexed_properties_enti 0.971% -0.151% 2.047%
algorithm_benches algorithm_sampling_multiple_l_reservoir 0.889% 0.098% 1.886%
large_dataset bench_filter_unindexed_entity 0.851% -2.346% 4.257%
counts multi_property_indexed_entities -0.834% -1.610% -0.096%
indexing query_people_count_indexed_multi-property_entities 0.786% 0.435% 1.044%
sampling count_and_sampling_single_known_length_entities -0.740% -1.604% 0.126%
indexing query_people_count_single_indexed_property_entities 0.726% 0.405% 1.133%
algorithm_benches algorithm_sampling_single_known_length -0.632% -1.162% -0.148%
algorithm_benches algorithm_sampling_multiple_known_length -0.201% -0.352% -0.042%
algorithm_benches algorithm_sampling_single_l_reservoir 0.193% -0.079% 0.539%
large_dataset bench_query_population_property_entities -0.144% -0.857% 0.553%
Not Compared (no baseline yet)
Group Bench Reason
(none)

@RobertJacobsonCDC RobertJacobsonCDC removed the blocked Currently blocked by another issue label Jul 29, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Benchmark Results

Hyperfine

Command Mean [ms] Min [ms] Max [ms] Relative
large_sir::baseline 2.7 ± 0.1 2.6 3.0 1.00
large_sir::baseline_households 2.7 ± 0.1 2.6 2.9 1.02 ± 0.03
large_sir::entities 6.0 ± 0.1 5.8 6.3 2.24 ± 0.06
large_sir::households 5.8 ± 0.1 5.7 6.0 2.16 ± 0.06

Criterion

Regressions (slower)
Group Bench Param Change CI Lower CI Upper
counts reindex_after_adding_more_entities 133.574% 132.901% 134.209%
indexing query_people_count_indexed_multi-property_entities 40.525% 39.536% 41.431%
large_dataset bench_match_entity 32.601% 31.216% 33.934%
counts index_after_adding_entities 30.862% 30.477% 31.254%
indexing with_query_results_indexed_multi-property_entities 17.511% 16.589% 18.495%
indexing query_people_count_single_indexed_property_entities 12.478% 11.671% 13.234%
large_dataset bench_query_population_indexed_property_entities 11.044% 10.693% 11.373%
large_dataset bench_query_population_derived_property_entities 9.123% 8.206% 10.036%
sample_entity sample_entity_single_property_indexed 1000 8.715% 7.125% 10.382%
sample_entity sample_entity_single_property_indexed 10000 8.312% 6.709% 10.001%
counts single_property_indexed_entities 8.204% 7.403% 8.870%
indexing with_query_results_multiple_individually_indexed_properties_enti 3.466% 3.120% 3.843%
large_dataset bench_query_population_property_entities 2.519% 1.675% 3.456%
sampling sampling_multiple_l_reservoir_entities 2.171% 1.468% 2.672%
sampling count_and_sampling_single_known_length_entities 2.132% 1.458% 2.753%
large_dataset bench_query_population_multi_indexed_entities 1.938% 1.595% 2.269%
Improvements (faster)
Group Bench Param Change CI Lower CI Upper
large_dataset bench_query_population_multi_unindexed_entities -99.159% -99.168% -99.150%
indexing query_people_single_indexed_property_entities -24.689% -25.887% -23.267%
sample_entity sample_entity_multi_property_indexed 10000 -19.972% -21.752% -17.883%
sample_entity sample_entity_multi_property_indexed 1000 -19.635% -21.550% -17.788%
sample_entity sample_entity_multi_property_indexed 100000 -16.714% -18.363% -14.934%
counts multi_property_unindexed_entities -8.979% -10.913% -7.216%
counts multi_property_indexed_entities -8.894% -9.850% -8.071%
large_dataset bench_filter_indexed_entity -7.791% -9.910% -5.574%
sample_entity sample_entity_whole_population 100000 -7.714% -11.867% -3.784%
sample_entity sample_entity_whole_population 10000 -7.186% -9.469% -5.132%
sampling sampling_single_l_reservoir_entities -5.832% -6.671% -5.100%
indexing query_people_indexed_multi-property_entities -5.023% -5.338% -4.617%
sample_entity sample_entity_single_property_unindexed 10000 -3.829% -3.979% -3.688%
indexing query_people_multiple_individually_indexed_properties_entities -3.138% -3.285% -2.980%
examples example-basic-infection -2.738% -3.756% -1.662%
Unchanged / inconclusive (CI crosses 0%)
Group Bench Param Change CI Lower CI Upper
sample_entity sample_entity_whole_population 1000 4.623% 0.147% 9.521%
algorithm_benches algorithm_sampling_single_known_length -2.677% -5.885% 0.018%
large_dataset bench_filter_unindexed_entity -2.625% -5.411% 0.346%
examples example-births-deaths -1.150% -2.053% -0.360%
sampling sampling_single_known_length_entities 0.944% 0.636% 1.218%
sampling count_and_sampling_single_unindexed_concrete_plus_derived_entiti -0.876% -1.028% -0.741%
sampling sampling_multiple_unindexed_entities -0.643% -0.802% -0.506%
indexing with_query_results_single_indexed_property_entities 0.641% -0.961% 1.880%
sampling sampling_single_unindexed_entities -0.593% -0.868% -0.288%
sample_entity sample_entity_single_property_unindexed 100000 -0.570% -1.266% 0.324%
indexing query_people_count_multiple_individually_indexed_properties_enti 0.545% 0.075% 1.098%
sample_entity sample_entity_single_property_indexed 100000 0.545% -0.916% 2.060%
counts single_property_unindexed_entities -0.509% -0.807% -0.222%
counts concrete_plus_derived_unindexed_entities -0.493% -1.403% 0.261%
sample_entity sample_entity_single_property_unindexed 1000 0.461% 0.158% 0.815%
algorithm_benches algorithm_sampling_multiple_known_length 0.412% 0.064% 0.748%
sampling sampling_multiple_known_length_entities -0.366% -1.069% 0.160%
algorithm_benches algorithm_sampling_single_l_reservoir -0.206% -0.640% 0.212%
algorithm_benches algorithm_sampling_single_rand_reservoir -0.168% -0.416% 0.014%
sampling sampling_single_unindexed_concrete_plus_derived_entities -0.149% -0.327% 0.049%
algorithm_benches algorithm_sampling_multiple_l_reservoir -0.045% -0.563% 0.434%
Not Compared (no baseline yet)
Group Bench Reason
(none)

github-actions Bot added a commit that referenced this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs discussion Needs discussion before implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-properties should be indexed by default.

3 participants