Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Arc instead of Vec for cheaper PlotPoints clone #4562

Closed
wants to merge 1 commit into from

Conversation

trueb2
Copy link

@trueb2 trueb2 commented May 28, 2024

This PR makes it cheaper to create Line Plots. On each pass, I noticed that the PlotPoints::new interface used to copy 10s-100s of MiB, when we could be doing a cheap Arc<[PlotPoint]> clone instead of an expensive Vec<PlotPoint> clone.

It is related to emilk/egui_plot#18, but as discussion has referenced, there are several aspects degrading rendering performance and this is not a silver bullet.

Construction is slightly different

let line_points =  x.zip(y)
    .map(|(x, y)| [x, y].into())
    .collect::<Vec<_>>()
    .into(); // Use the impl From<Vec<T>> for Arc<[T]>
 let points = vec![line_points];

Usage looks identical.

for series in points {
  ui.line(Line::new(PlotPoints::new(series.clone())));
}

If ExplicitGenerator were Clone, then we would be able to have PlotPoints be Clone.

@emilk
Copy link
Owner

emilk commented Jul 15, 2024

egui_plot has recently been moved to its own repository, at https://github.com/emilk/egui_plot

This will hopefully speed up its development by having more reviewers and maintainers.

Please re-open this PR at https://github.com/emilk/egui_plot/pulls

See also:

@emilk emilk closed this Jul 15, 2024
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.

2 participants