@@ -2038,9 +2038,6 @@ msp_verify_hulls(msp_t *self)
20382038 io = 0 ;
20392039 }
20402040 }
2041- /* printf("hull %d io=%d insertion_order=%d\n", */
2042- /* (int) hull->id, (int) io, (int) hull->right_insertion_order);
2043- */
20442041 tsk_bug_assert (io == hull -> right_insertion_order );
20452042 pos = hull -> right ;
20462043 }
@@ -3251,6 +3248,19 @@ msp_store_arg_gene_conversion(
32513248 * there was specific logic for this. In an attempt to simplify the logic
32523249 * here we just do the straightforward thing, but this is definitely somewhere
32533250 * we could get some benefit if looking for optimisations.
3251+ *
3252+ * In some profiling on a simulation that takes about a minute, we see
3253+ * the following breakdown:
3254+ * --49.65%--msp_smc_k_common_ancestor_event
3255+ * --40.93%--msp_recombination_event
3256+ * |--17.03%--msp_insert_individual
3257+ * |--16.79%--msp_reset_hull_right
3258+ *
3259+ * So, in this case msp_reset_hull_right represents about 17% of the overall
3260+ * processing time, and I think we could at best expect to halve that if
3261+ * we did things better. A ~5% improvement in performance doesn't seem
3262+ * worth the effort or complexity currently. See the Python implementation
3263+ * of the git history though, for how this used to be done.
32543264 */
32553265static int
32563266msp_reset_hull_right (msp_t * self , lineage_t * lineage )
@@ -3624,7 +3634,9 @@ msp_gene_conversion_event(msp_t *self, label_id_t label)
36243634 * lineage and the SMC(k) state as the code paths are quite convoluted.
36253635 * It seems unlikely the segment iteration will be a bottleneck in
36263636 * practise, but unconditionaly removing and reinserting hulls could
3627- * become significant. */
3637+ * become significant.
3638+ * See https://github.com/tskit-dev/msprime/issues/2386
3639+ */
36283640 lineage_reset_segments (lineage );
36293641 if (is_smc_k ) {
36303642 ret = msp_insert_individual_hull (self , lineage );
@@ -5028,6 +5040,7 @@ msp_gene_conversion_left_event(msp_t *self, label_id_t label)
50285040 msp_set_segment_mass (self , alpha );
50295041 tsk_bug_assert (alpha -> prev == NULL );
50305042
5043+ // This isn't optimal - see https://github.com/tskit-dev/msprime/issues/2386
50315044 lineage_reset_segments (new_lineage );
50325045 lineage_reset_segments (lineage );
50335046
0 commit comments