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

interpreters, reporter: refactor towards statelessness #171

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

Conversation

fabled
Copy link
Contributor

@fabled fabled commented Sep 30, 2024

Due to legacy reasons, each interpreter kept their own state of which dynamic metadata should be sent to the reporter. Several of these caches would never expire, causing caching issues in the otlp reporter module.

This removes the caching state from all interpreters and pushes it to the reporter module. A new reporter API call FrameNeeded is added to query if a specific Frame is in the cache or not. Not all interpreter modules use the call as all the information might be available with little overhead. FrameMetadata is also updated to use the FrameID type for symmetry.

Improved are:

  • reduced memory overhead as per-interpreter caches are removed
  • reporter module can now control which frames need resolving
  • fixes otlp to get the frames re-symbolized if its internal lru already forgot about the earlier symbolization information

ref #121

@fabled fabled changed the title interprers, reporter: refactor towards statelessness interpreters, reporter: refactor towards statelessness Sep 30, 2024
@fabled fabled marked this pull request as ready for review September 30, 2024 15:10
@fabled fabled requested review from a team as code owners September 30, 2024 15:10
Due to legacy reasons, each interpreter kept their own state of
which dynamic metadata should be sent to the reporter. Several
of these caches would never expire, causing caching issues in
the otlp reporter module.

This removes the caching state from all interpreters and pushes
it to the reporter module. A new reporter API call FrameNeeded
is added to query if a specific Frame is in the cache or not.
Not all interpreter modules use the call as all the information
might be available with little overhead. FrameMetadata is also
updated to use the FrameID type for symmetry.

Improved are:
 - reduced memory overhead as per-interpreter caches are removed
 - reporter module can now control which frames need resolving
 - fixes otlp to get the frames re-symbolized if its internal
   lru already forgot about the earlier symbolization information

ref open-telemetry#121
Copy link
Contributor

@florianl florianl left a comment

Choose a reason for hiding this comment

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

just a minor nit 👍

reporter/iface.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rockdaboot rockdaboot left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

Reminder (also to myself):
We need to adapt reporting executable metadata and kernel frames in a similar way (moving caches into the reporter).

Copy link
Contributor

@rockdaboot rockdaboot left a comment

Choose a reason for hiding this comment

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

Some nits...

@@ -764,19 +756,16 @@ func (i *dotnetInstance) Symbolize(symbolReporter reporter.SymbolReporter,
if err != nil {
return err
}
fileID := module.fileID
// The Line ID is the Relative Virtual Address (RVA) within into the PE file
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The Line ID is the Relative Virtual Address (RVA) within into the PE file
// The Line ID is the Relative Virtual Address (RVA) within the PE file

interpreter/dotnet/instance.go Outdated Show resolved Hide resolved
interpreter/nodev8/v8.go Outdated Show resolved Hide resolved
reporter/iface.go Outdated Show resolved Hide resolved
Comment on lines +169 to +172
h := fnv.New128a()
_, _ = h.Write([]byte(name))
nameHash := h.Sum(nil)
lineID = libpf.AddressOrLineno(npsr.Uint64(nameHash, 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to have an extra function for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same pattern is written out in several interpreter modules. It might make sense to make a helper for this in the interpreter or libpf module. But I'd make it a separate / follow up PR instead since its logically a separate thing.

Copy link
Member

@christos68k christos68k left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

reporter/otlp_reporter.go Outdated Show resolved Hide resolved
@fabled
Copy link
Contributor Author

fabled commented Oct 4, 2024

Addressed feedback: comments updated and the FrameMetadata arguments converted to a struct. Please take look again.

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.

4 participants