Skip to content

Conversation

@fahdfady
Copy link
Contributor

No description provided.

@hulxv
Copy link
Collaborator

hulxv commented Oct 22, 2025

Fix conflicts please

@hulxv
Copy link
Collaborator

hulxv commented Oct 22, 2025

Did you test it to see if it solves the memory leak in dev mode?

@fahdfady
Copy link
Contributor Author

fahdfady commented Oct 23, 2025

Did you test it to see if it solves the memory leak in dev mode?

@hulxv the performance got better. not by much, but it's not ~1GB every refresh. I think deleting cache on my test locally helped too, so I don't have a solid metric i can build upon. Do you have better ideas to measure performance improvemnets for this?

You can see the RES from htop here to see the memory usage.
https://github.com/user-attachments/assets/59aadc48-6988-4558-8502-39384acd33c8

@hulxv hulxv requested a review from Copilot October 23, 2025 14:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors code for improved performance by eliminating unnecessary clone operations and simplifying lifetime parameters. The changes focus on reducing memory allocations and improving efficiency in logging and bundling components.

Key changes:

  • Removed redundant clone() calls in the logger by using remove() instead of get() operations
  • Simplified lifetime parameters in LogFormat struct and changed ownership model from references to owned values
  • Removed unnecessary Clone trait derivation from HtmlOutput struct

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/metassr-watcher/src/utils.rs Added blank line for code formatting
crates/metassr-html/src/builder.rs Removed Clone derive from HtmlOutput to prevent unnecessary cloning
crates/metassr-bundler/src/lib.rs Changed from to_str().unwrap() to display() for better path handling
crates/logger/src/lib.rs Refactored to eliminate redundant clones and simplified lifetime parameters in LogFormat struct

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

level: &'a Level,
target: Option<&'a String>,
message: Option<String>,
level: &'static Level,
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

Using &'static Level assumes the Level reference will always have a static lifetime. While this may work for tracing::Level, it's worth verifying that event.metadata().level() actually returns a &'static Level and not a reference with a shorter lifetime.

Suggested change
level: &'static Level,
level: Level,

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

event_metadata().level() actually returns level with reference &Level which returns a const. so it's safe to predict that it has a static life time https://docs.rs/tracing-core/latest/src/tracing_core/metadata.rs.html#505 https://docs.rs/tracing-core/latest/src/tracing_core/metadata.rs.html#66
but Level implements Copy so it's cheap i guess. we can remove it for better readability.

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