Skip to content

Commit

Permalink
chore(proctree): del Process interpreter FileInfo
Browse files Browse the repository at this point in the history
Remove the interpreter FileInfo fields from the Process struct.
This reduces the memory footprint of the Proctree by 8MB at average.
  • Loading branch information
geyslan committed Dec 13, 2024
1 parent b44959b commit 740bbbf
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
4 changes: 0 additions & 4 deletions pkg/proctree/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ func (ptds *DataSource) exportProcessInfo(
// Pick the objects related to the process from the process tree.
info := process.GetInfo()
executable := process.GetExecutable()
interpreter := process.GetInterpreter()
interp := process.GetInterp()

// Walk children hashes and discover the ones alive at the query time.
aliveChildren := make(map[int]uint32)
Expand Down Expand Up @@ -135,8 +133,6 @@ func (ptds *DataSource) exportProcessInfo(
ContainerId: "", // TODO: Add
Cmd: []string{}, // TODO: Add
ExecutionBinary: exportFileInfo(executable, queryTime),
Interpreter: exportFileInfo(interpreter, queryTime),
Interp: exportFileInfo(interp, queryTime),
StartTime: info.GetStartTime(),
ExecTime: time.Unix(0, 0), // TODO: Add
ExitTime: info.GetExitTime(),
Expand Down
20 changes: 0 additions & 20 deletions pkg/proctree/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ type Process struct {
parentHash uint32 // hash of parent
info *TaskInfo // task info
executable *FileInfo // executable info
interpreter *FileInfo // interpreter info (binary format interpreter/loader)
interp *FileInfo // interpreter (scripting language interpreter)
children map[uint32]struct{} // hash of childrens
threads map[uint32]struct{} // hash of threads
// Control fields
Expand All @@ -29,8 +27,6 @@ func NewProcess(hash uint32) *Process {
parentHash: 0,
info: NewTaskInfo(),
executable: NewFileInfo(),
interpreter: NewFileInfo(),
interp: NewFileInfo(),
children: make(map[uint32]struct{}),
threads: make(map[uint32]struct{}),
mutex: &sync.RWMutex{},
Expand All @@ -44,8 +40,6 @@ func NewProcessWithInfo(hash uint32, info *TaskInfo) *Process {
parentHash: 0,
info: info,
executable: NewFileInfo(),
interpreter: NewFileInfo(),
interp: NewFileInfo(),
children: make(map[uint32]struct{}),
threads: make(map[uint32]struct{}),
mutex: &sync.RWMutex{},
Expand Down Expand Up @@ -82,20 +76,6 @@ func (p *Process) GetExecutable() *FileInfo {
return p.executable
}

// GetInterpreter returns a instanced interpreter info.
func (p *Process) GetInterpreter() *FileInfo {
p.mutex.RLock()
defer p.mutex.RUnlock()
return p.interpreter
}

// GetInterp returns a instanced interpreter.
func (p *Process) GetInterp() *FileInfo {
p.mutex.RLock()
defer p.mutex.RUnlock()
return p.interp
}

// Setters

// SetParentHash sets the hash of the parent.
Expand Down
4 changes: 0 additions & 4 deletions pkg/proctree/proctree_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ func (pt *ProcessTree) FeedFromFork(feed ForkFeed) error {
parent.GetExecutable().GetFeed(),
feedTimeStamp,
)
leader.GetInterpreter().SetFeedAt(
parent.GetInterpreter().GetFeed(),
feedTimeStamp,
)
}

// In all cases (task is a process, or a thread) there is a thread entry.
Expand Down

0 comments on commit 740bbbf

Please sign in to comment.