getappmap / getappmap/appmap-java
Reduce allocations required to enter a hook
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 88
- Forks
- 17
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 1
Description
When a method is called, an "event template" is cloned and passed into the hook to be mutated. The template serves as cache for all the static properties (src path, defined class, method id, etc). It prevents us from needing to perform costly run-time reflection in nearly all cases.
This means we're cloning a new event from and event template for every hook called. We can drop these allocations by implementing a custom serializer that writes properties directly from the event template.
Not in scope for this issue, but worth keeping top of mind, is that we can cut Event allocations almost entirely by reusing events. We only need enough events to fill the buffer in the file stream. Once they're written, we can place them back in the pool to be picked up by another thread.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the hook path that clones an event template and the serializer that writes events. Trace how static properties move from the template into each cloned event. Done means the custom serializer writes those properties directly from the template and avoids the per-hook clone allocations; the issue provides no specific file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100