Skip to content

*: remove uses of reflect.MethodByName from all of Delve#3916

Merged
derekparker merged 1 commit intogo-delve:masterfrom
aarzilli:noreflect
Feb 18, 2025
Merged

*: remove uses of reflect.MethodByName from all of Delve#3916
derekparker merged 1 commit intogo-delve:masterfrom
aarzilli:noreflect

Conversation

@aarzilli
Copy link
Member

When reflect.MethodByName is used the linker can not fully perform
deadcode elimination. This commit updates cobra and rewrites the
suitableMethods part of service/rpccommon so that reflect.MethodByName
is not used and the linker can fully execute deadcode elimination.

The executable size on go1.24.0 on linux is reduced from 25468606 bytes
to 22453382 bytes or a reduction of approximately 12%.

See also:

spf13/cobra#1956
https://github.com/aarzilli/whydeadcode

When reflect.MethodByName is used the linker can not fully perform
deadcode elimination. This commit updates cobra and rewrites the
suitableMethods part of service/rpccommon so that reflect.MethodByName
is not used and the linker can fully execute deadcode elimination.

The executable size on go1.24.0 on linux is reduced from 25468606 bytes
to 22453382 bytes or a reduction of approximately 12%.

See also:

spf13/cobra#1956
https://github.com/aarzilli/whydeadcode
Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

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

LGTM

This is really great, thanks for working on this. Glad the change finally landed in cobra too.

@derekparker derekparker merged commit 7ea6d8f into go-delve:master Feb 18, 2025
1 of 2 checks passed
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.

2 participants