Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Evaluation: Removing Reflection from go-micro

  • Analyze current reflection usage in go-micro
  • Research livekit/psrpc approach
  • Compare architectural approaches
  • Create detailed feasibility analysis document
  • Create user-facing performance documentation
  • Address code review feedback on consistency
  • Add evaluation summary
  • Make final recommendation

Summary

After comprehensive analysis, we recommend AGAINST removing reflection from go-micro.

Key Findings

  1. Reflection is fundamental - Enables go-micro's "register any struct" design
  2. psrpc uses code generation - Completely different architecture requiring proto files
  3. Performance impact is negligible - ~50μs overhead, <5% of typical RPC latency
  4. Removal would be breaking - Would require complete rewrite and break all existing code
  5. Alternatives exist - Users needing max performance can use gRPC or psrpc

Documents Added

  • docs/reflection-removal-analysis.md - 519-line technical deep-dive
  • docs/performance.md - 228-line user-facing performance guide
  • docs/REFLECTION-EVALUATION-SUMMARY.md - Executive summary and recommendation
  • Updated README.md with link to performance documentation

Recommendation

Close the original issue with explanation that reflection is a deliberate architectural choice. For performance-critical applications, document alternatives like gRPC and psrpc.

Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE] Remove reflect</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
I'm always frustrated when working with code that heavily relies on reflect because of its significant performance overhead. Operations like type assertions, object field access, and method invocation through reflect are much slower compared to direct, statically-typed counterparts.

Describe the solution you'd like
I would like to rewrite the relevant parts of the codebase to use generics instead of reflect. Similar to how the livekit/psrpc project uses generics to avoid reflect in its Protobuf.

</issue_description>

<agent_instructions>Evaluate whether we can easily remove Go reflection from the codebase. Heavily used in the rpc server in the server package and likely in the grpc package. And then as part of the protoc-gen-micro generator. If it's possible to do via generics and we'll see a performance improvement along with simplification of code then we should do it but otherwise if it is not worth the tradeoff in complexity or risk or breakages then we should document that in the docs and in this issue and then abandon it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@asim You are welcome to make the contribution if you think it will improve the project. Thank you for taking the time to do it.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 3, 2026 15:29
Co-authored-by: asim <17530+asim@users.noreply.github.com>
Co-authored-by: asim <17530+asim@users.noreply.github.com>
Co-authored-by: asim <17530+asim@users.noreply.github.com>
@asim asim marked this pull request as ready for review February 3, 2026 15:34
@asim asim merged commit 3094947 into master Feb 3, 2026
Copilot AI requested a review from asim February 3, 2026 15:35
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.

[FEATURE] Remove reflect

2 participants