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

connect flecs to tracing ecosystem #200

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Georgiy-Tugai
Copy link
Contributor

No description provided.

@Georgiy-Tugai Georgiy-Tugai marked this pull request as draft November 8, 2024 08:45
@Georgiy-Tugai Georgiy-Tugai marked this pull request as ready for review November 8, 2024 12:42
Copy link
Contributor

@waywardmonkeys waywardmonkeys left a comment

Choose a reason for hiding this comment

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

Will have more questions later, but this is a start.

flecs_ecs_tracing/Cargo.toml Outdated Show resolved Hide resolved
flecs_ecs_tracing/Cargo.toml Outdated Show resolved Hide resolved
}

#[derive(Clone, Debug)]
pub(crate) struct MetadataRequest<'a> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Going by code below, filename and line are only valid when kind == MetadataKind::Event, so it seems like MetadataKind::Event should be holding that data.

In that case, then the PartialEq and Hash would be derived and not have a manual implementation.

If there is a reason for not doing the expected thing (what I just described), then that should be documented with a comment somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filename and line are valid for both Event and Span, but for Span they are not part of the hash key, since the push and pop events will come from different line numbers (& possibly different file names).

It's a moot point at the moment, though, since metadata for spans is currently not cached in the metadata registry, only in the span registry which uses the span name as the key. This may change in the future; an alternative design would have one metadata per ecs_os_perf_trace_push callsite and put the span names into values (like log messages).

line: usize,
name: Cow<'_, str>,
) -> (span::Id, &'static Metadata<'static>, bool) {
if let Some((existing, metadata)) = REGISTRY.read().unwrap().spans.get(name.as_ref()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This and another instance of a similar code pattern feel like they should be chained functions rather than an if / early return. But maybe not?

struct Registry {
spans: HashMap<
String,
(tracing_core::span::Id, &'static Metadata<'static>),
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels odd. Why's the Id separate from the Metadata? Or why's this a tuple and not some type?

And why can't someone legitimately own this metadata, like the registry? Is it because it is owned by the dynamic callsite, which you're leaking? If so, why not store that somewhere around here? But you're the one that decided to store it in the callsite, so ... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tracing_core borrows Callsite for 'static and demands that Callsite can provide a reference to the Metadata (fn metadata(&self) -> &Metadata<'_>).

I guess I could store the MetadataRequest inside DynamicCallsite and do lookups in REGISTRY every time but I'm not seeing any advantages to doing that...

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