cloudwego / cloudwego/goref

proposal: scan and record memory partially

Open
#71 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1k
Forks
48
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

When the memory footprint is large, we may only consider some part of objects, which can reduce the size of generated profile.
Although pprof provides `show_from` and `focus` options to hide other parts of objects, there may be cases we need to consider two isolated parts of memory at the same time.

**Describe the solution you'd like**

Intrusively add a `stub` pointer field to the struct types of interest within the program under test. Then goref can trace objects reachable from struct objects which holds the stub address provided by goref.

**Describe alternatives you've considered**

Write goref profile parser and consider interested objects only. But it seems not convenient as this approach.
But `stub` field in the proposal causes more memory consumption for objects which contain the field.

**Additional context**

I've implemented the idea in [markStub](https://github.com/Lslightly/goref/tree/markStub) branch. It supports adding a stub pointer in objects of struct type. Then goref will only trace objects reachable from those objects that contain the stub address.

[test/testdata/stubaddr/main.go](https://github.com/Lslightly/goref/blob/markStub/test/testdata/stubaddr/main.go) is a demo program to show how `markStub` can be used to trace certain objects.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the markStub branch and its demo at test/testdata/stubaddr/main.go. Determine how the proposed stub pointer should be added to selected struct types and how goref should identify reachable objects from the supplied address. Done means the feature supports partial scanning of isolated memory regions, with coverage for the demonstrated use case and its memory-cost tradeoff considered.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.