Skip to content

pkg/proc: optimize range body lookup cost by trie searching and use moduledata cache to reduce LoadModuleData cost - #4113

Merged
derekparker merged 1 commit into
go-delve:masterfrom
jayantxie:perf/optimize_load_value
Sep 1, 2025
Merged

derekparker merged 1 commit into
go-delve:masterfrom
jayantxie:perf/optimize_load_value

Conversation

@jayantxie

Copy link
Copy Markdown
Contributor

Fixes #4112

@jayantxie
jayantxie force-pushed the perf/optimize_load_value branch 3 times, most recently from 56bc82d to 872a7cd Compare August 29, 2025 08:00

@aarzilli aarzilli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this change conflicts with the updated of the derekparker/trie dependency we did today.

Comment thread pkg/proc/bininfo.go
}

func (bi *BinaryInfo) LookupRangeBodyFunc() *trie.Trie {
if bi.lookupRangeBodyFunc == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs to be cleared when we load plugins.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it will be cleared by loadDebugInfoMaps when loading plugins, just like lookupFunc and lookupGenericFunc.

@derekparker

Copy link
Copy Markdown
Member

Hey @jayantxie thanks for the patch!

As @aarzilli mentioned we just updated trie internally to v3 which adds support for generics amongst some other changes & optimizations. It should simplify your changes once you rebase because you won't need the type cast anymore.

…oduledata cache to reduce LoadModuleData cost

Fixes go-delve#4112
@jayantxie
jayantxie force-pushed the perf/optimize_load_value branch from 872a7cd to fc3342d Compare September 1, 2025 09:59

@derekparker derekparker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread pkg/proc/bininfo.go
if strings.HasPrefix(fn2.Name, fn.Name) && fn2.rangeParentName() == fn.Name {
fn.extraCache.rangeBodies = append(fn.extraCache.rangeBodies, fn2)
lookupFunc := bi.LookupRangeBodyFunc()
for _, key := range lookupFunc.PrefixSearch(fn.Name) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could probably improve this by introducing a PrefixSearchIter func which returns keys & values (this is more of a note for myself to fix and refactor this in the future).

@derekparker
derekparker merged commit 0b74953 into go-delve:master Sep 1, 2025
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.

Performance: optimize the overhead of loadValue

3 participants