editor: Improve minimap performance (#33067)
This PR aims to improve the minimap performace. This is primarily achieved by disabling/removing stuff that is not shown in the minimal as well as by assuring the display map is not updated during minimap prepaint. This should already be much better in parts, as the block map as well as the fold map will be less frequently updated due to the minimap prepainting (optimally, they should never be, but I think we're not quite there yet). For this, I had to remove block rendering support for the minimap, which is not as bad as it sounds: Practically, we were currently not rendering most blocks anyway, there were issues due to this (e.g. scrolling any visible block offscreen in the main editor causes scroll jumps currently) and in the long run, the minimap will most likely need its own block map or a different approach anyway. The existing implementation caused resizes to occur very frequently for practically no benefit. Can pull this out into a separate PR if requested, most likely makes the other changes here easier to discuss. This is WIP as we are still hitting some code path here we definitely should not be hitting. E.g. there seems to be a rerender roughly every second if the window is unfocused but visible which does not happen when the minimap is disabled. While this primarily focuses on the minimap, it also touches a few other small parts not related to the minimap where I noticed we were doing too much stuff during prepaint. Happy for any feedback there aswell. Putting this up here already so we have a place to discuss the changes early if needed. Release Notes: - Improved performance with the minimap enabled. - Fixed an issue where interacting with blocks in the editor would sometimes not properly work with the minimap enabled.
This commit is contained in:
parent
363a265051
commit
26ba6e7e00
12 changed files with 207 additions and 184 deletions
|
@ -193,7 +193,6 @@ pub struct CustomBlock {
|
|||
style: BlockStyle,
|
||||
render: Arc<Mutex<RenderBlock>>,
|
||||
priority: usize,
|
||||
pub(crate) render_in_minimap: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -205,7 +204,6 @@ pub struct BlockProperties<P> {
|
|||
pub style: BlockStyle,
|
||||
pub render: RenderBlock,
|
||||
pub priority: usize,
|
||||
pub render_in_minimap: bool,
|
||||
}
|
||||
|
||||
impl<P: Debug> Debug for BlockProperties<P> {
|
||||
|
@ -1044,7 +1042,6 @@ impl BlockMapWriter<'_> {
|
|||
render: Arc::new(Mutex::new(block.render)),
|
||||
style: block.style,
|
||||
priority: block.priority,
|
||||
render_in_minimap: block.render_in_minimap,
|
||||
});
|
||||
self.0.custom_blocks.insert(block_ix, new_block.clone());
|
||||
self.0.custom_blocks_by_id.insert(id, new_block);
|
||||
|
@ -1079,7 +1076,6 @@ impl BlockMapWriter<'_> {
|
|||
style: block.style,
|
||||
render: block.render.clone(),
|
||||
priority: block.priority,
|
||||
render_in_minimap: block.render_in_minimap,
|
||||
};
|
||||
let new_block = Arc::new(new_block);
|
||||
*block = new_block.clone();
|
||||
|
@ -1976,7 +1972,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -1984,7 +1979,6 @@ mod tests {
|
|||
height: Some(2),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -1992,7 +1986,6 @@ mod tests {
|
|||
height: Some(3),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -2217,7 +2210,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2225,7 +2217,6 @@ mod tests {
|
|||
height: Some(2),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2233,7 +2224,6 @@ mod tests {
|
|||
height: Some(3),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -2322,7 +2312,6 @@ mod tests {
|
|||
render: Arc::new(|_| div().into_any()),
|
||||
height: Some(1),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2330,7 +2319,6 @@ mod tests {
|
|||
render: Arc::new(|_| div().into_any()),
|
||||
height: Some(1),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -2370,7 +2358,6 @@ mod tests {
|
|||
height: Some(4),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
}])[0];
|
||||
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
|
||||
|
@ -2424,7 +2411,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2432,7 +2418,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2440,7 +2425,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
|
||||
|
@ -2455,7 +2439,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2463,7 +2446,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2471,7 +2453,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
|
||||
|
@ -2571,7 +2552,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2579,7 +2559,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2587,7 +2566,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
let excerpt_blocks_3 = writer.insert(vec![
|
||||
|
@ -2597,7 +2575,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
|
@ -2605,7 +2582,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -2653,7 +2629,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
}]);
|
||||
let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default());
|
||||
let blocks = blocks_snapshot
|
||||
|
@ -3011,7 +2986,6 @@ mod tests {
|
|||
height: Some(height),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -3032,7 +3006,6 @@ mod tests {
|
|||
style: props.style,
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
}));
|
||||
|
||||
for (block_properties, block_id) in block_properties.iter().zip(block_ids) {
|
||||
|
@ -3557,7 +3530,6 @@ mod tests {
|
|||
height: Some(1),
|
||||
render: Arc::new(|_| div().into_any()),
|
||||
priority: 0,
|
||||
render_in_minimap: true,
|
||||
}])[0];
|
||||
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue