GC-301d · Module 2

Performance Profiling

3 min read

MCP server performance directly impacts Gemini CLI's response time. Every tool call is a round-trip: Gemini sends a JSON-RPC request, the server processes it, and the response flows back. Slow servers create noticeable pauses in the conversation. The performance profile of your MCP setup matters at three levels: startup time (how long until all servers are ready), tool call latency (how long each individual operation takes), and memory footprint (how much RAM the server fleet consumes).

Profiling starts with measurement. Time your Gemini CLI startup with and without MCP servers to isolate the server initialization overhead. Use the debug log to measure individual tool call durations. Monitor memory usage across all server processes during a typical session. The benchmarks to target: startup under 5 seconds total, individual tool calls under 2 seconds for local operations and under 10 seconds for network operations, total server memory under 500MB.

# Measure startup time with MCP servers
time gemini -p "What tools are available?" --output-format json > /dev/null

# Measure startup time without MCP servers (baseline)
GEMINI_DISABLE_MCP=1 time gemini -p "hello" > /dev/null

# Profile memory usage of MCP server processes
ps -eo pid,rss,command | grep -E "server-|mcp" | sort -k2 -rn
# RSS is in KB — convert to MB by dividing by 1024

# Profile tool call latency from debug log
GEMINI_DEBUG=1 gemini 2>debug.log
# After session, extract timing:
grep "tool_call\|tool_result" debug.log | head -20

# MCP Inspector for detailed profiling
npx @modelcontextprotocol/inspector \
  --timing \
  npx -y @modelcontextprotocol/server-postgres