Skip to content

chore: add clone support for entityset#837

Open
cdc-as81 wants to merge 1 commit intomainfrom
cdc-as81-entityset-clone
Open

chore: add clone support for entityset#837
cdc-as81 wants to merge 1 commit intomainfrom
cdc-as81-entityset-clone

Conversation

@cdc-as81
Copy link
Copy Markdown
Collaborator

@cdc-as81 cdc-as81 commented Apr 2, 2026

Summary

This PR makes EntitySet<'a, E> cloneable by deep-cloning its lazy expression tree and adding clone support for property-backed source leaves.

Changes

  • implement Clone for EntitySet and EntitySetInner
  • add clone_box() to AbstractPropertySource for cloning boxed property sources
  • implement Clone for ConcretePropertySource and DerivedPropertySource
  • implement Clone for SourceSet, including PropertySet
  • add tests covering:
    • cloned composite set expressions
    • cloned unindexed concrete-property queries
    • cloned unindexed derived-property queries
    • clone independence when one copy is consumed

@cdc-as81 cdc-as81 linked an issue Apr 2, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Benchmark Results

Hyperfine

Command Mean [ms] Min [ms] Max [ms] Relative
large_sir::baseline 2.8 ± 0.1 2.7 3.0 1.00
large_sir::entities 12.6 ± 0.1 12.4 12.8 4.44 ± 0.10

Criterion

Regressions (slower)
Group Bench Param Change CI Lower CI Upper
sample_entity sample_entity_single_property_unindexed 1000 20.133% 18.208% 22.081%
large_dataset bench_match_entity 12.068% 11.628% 12.602%
large_dataset bench_query_population_derived_property_entities 9.566% 8.279% 10.853%
sampling sampling_single_unindexed_entities 3.738% 3.289% 4.165%
sampling sampling_multiple_l_reservoir_entities 3.347% 2.945% 3.634%
sample_entity sample_entity_single_property_unindexed 10000 3.206% 2.510% 4.158%
examples example-basic-infection 3.101% 2.190% 3.930%
sampling sampling_multiple_unindexed_entities 2.817% 2.410% 3.221%
algorithm_benches algorithm_sampling_multiple_known_length 2.709% 2.443% 2.933%
examples example-births-deaths 2.310% 1.918% 2.724%
Improvements (faster)
Group Bench Param Change CI Lower CI Upper
indexing query_people_single_indexed_property_entities -15.238% -16.065% -14.462%
indexing query_people_indexed_multi-property_entities -9.258% -9.867% -8.714%
sampling sampling_single_unindexed_concrete_plus_derived_entities -6.377% -6.745% -5.992%
sample_entity sample_entity_single_property_indexed 1000 -4.892% -5.441% -4.443%
sample_entity sample_entity_single_property_indexed 10000 -4.365% -4.748% -4.067%
indexing query_people_count_multiple_individually_indexed_properties_enti -4.344% -4.540% -4.153%
sample_entity sample_entity_multi_property_indexed 1000 -4.266% -4.534% -4.036%
sample_entity sample_entity_multi_property_indexed 100000 -4.038% -4.596% -3.503%
indexing with_query_results_indexed_multi-property_entities -4.012% -4.608% -3.360%
counts multi_property_indexed_entities -3.625% -4.136% -3.154%
sample_entity sample_entity_single_property_indexed 100000 -3.256% -3.819% -2.883%
sample_entity sample_entity_multi_property_indexed 10000 -3.140% -3.430% -2.886%
sampling count_and_sampling_single_unindexed_concrete_plus_derived_entiti -2.166% -2.342% -1.975%
sampling count_and_sampling_single_known_length_entities -1.982% -2.491% -1.645%
sample_entity sample_entity_single_property_unindexed 100000 -1.876% -2.264% -1.481%
large_dataset bench_query_population_multi_unindexed_entities -1.464% -1.733% -1.210%
Unchanged / inconclusive (CI crosses 0%)
Group Bench Param Change CI Lower CI Upper
indexing query_people_multiple_individually_indexed_properties_entities 1.443% 0.648% 2.004%
large_dataset bench_filter_indexed_entity 1.243% -6.556% 9.111%
large_dataset bench_filter_unindexed_entity 1.175% -1.950% 4.409%
large_dataset bench_query_population_multi_indexed_entities 1.138% 0.778% 1.528%
sample_entity sample_entity_whole_population 10000 1.067% -0.189% 3.675%
indexing query_people_count_indexed_multi-property_entities 1.037% 0.823% 1.283%
sampling sampling_single_known_length_entities -1.006% -1.360% -0.614%
indexing query_people_count_single_indexed_property_entities -0.782% -1.067% -0.514%
counts index_after_adding_entities -0.585% -0.741% -0.439%
algorithm_benches algorithm_sampling_single_known_length -0.584% -1.093% -0.154%
algorithm_benches algorithm_sampling_multiple_l_reservoir 0.562% 0.135% 1.032%
sampling sampling_single_l_reservoir_entities -0.428% -0.497% -0.355%
indexing with_query_results_single_indexed_property_entities 0.383% -0.164% 1.002%
algorithm_benches algorithm_sampling_single_l_reservoir -0.361% -0.937% 0.050%
large_dataset bench_query_population_indexed_property_entities 0.299% 0.042% 0.560%
counts single_property_indexed_entities -0.287% -0.658% 0.014%
sampling sampling_multiple_known_length_entities 0.262% -0.002% 0.536%
counts reindex_after_adding_more_entities -0.256% -0.452% -0.046%
sample_entity sample_entity_whole_population 1000 -0.243% -0.655% 0.291%
indexing with_query_results_multiple_individually_indexed_properties_enti 0.205% -0.608% 0.884%
counts single_property_unindexed_entities -0.187% -0.984% 0.488%
sample_entity sample_entity_whole_population 100000 -0.174% -0.493% 0.280%
counts multi_property_unindexed_entities -0.164% -1.317% 0.791%
large_dataset bench_query_population_property_entities -0.154% -0.741% 0.312%
counts concrete_plus_derived_unindexed_entities 0.090% -0.506% 0.820%
algorithm_benches algorithm_sampling_single_rand_reservoir 0.050% -0.169% 0.335%

github-actions bot added a commit that referenced this pull request Apr 2, 2026
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.

Make EntitySet Clone

2 participants