mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-07 18:27:52 +02:00
chore: remove benchmark profiling mode from PR
Move --profile flag and Makefile targets (benchmark-profile, benchmark-profile-spy) to a separate patch for a future PR. This PR now contains only runtime performance optimizations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
John Kennedy
co-authored by
Claude Opus 4.6
parent
8fd1103aca
commit
3921da01cf
@@ -1,4 +1,4 @@
|
||||
.PHONY: all format lint type test test_watch integration_tests spell_check spell_fix benchmark benchmark-profile benchmark-profile-spy profile start-dev-server integration_tests
|
||||
.PHONY: all format lint type test test_watch integration_tests spell_check spell_fix benchmark profile start-dev-server integration_tests
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
all: help
|
||||
@@ -24,14 +24,6 @@ benchmark-fast:
|
||||
rm -f $(OUTPUT)
|
||||
uv run python -m bench -o $(OUTPUT) --fast
|
||||
|
||||
benchmark-profile:
|
||||
mkdir -p out
|
||||
uv run python -m bench --profile
|
||||
|
||||
benchmark-profile-spy:
|
||||
mkdir -p out
|
||||
sudo uv run py-spy record -g -o out/benchmark-flamegraph.svg -- python -m bench --fast
|
||||
|
||||
GRAPH ?= bench/fanout_to_subgraph.py
|
||||
|
||||
profile:
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import random
|
||||
import sys
|
||||
from uuid import uuid4
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
from langgraph.checkpoint.memory import InMemorySaver
|
||||
from pyperf._runner import Runner
|
||||
from uvloop import new_event_loop
|
||||
|
||||
from bench.fanout_to_subgraph import fanout_to_subgraph, fanout_to_subgraph_sync
|
||||
from bench.pydantic_state import pydantic_state
|
||||
@@ -463,54 +464,6 @@ benchmarks = (
|
||||
)
|
||||
|
||||
|
||||
if "--profile" in sys.argv:
|
||||
import asyncio
|
||||
import cProfile
|
||||
import pstats
|
||||
from pathlib import Path
|
||||
|
||||
out_dir = Path("out")
|
||||
out_dir.mkdir(exist_ok=True)
|
||||
|
||||
for name, agraph, graph, input_data in benchmarks:
|
||||
# Profile async variant
|
||||
prof = cProfile.Profile()
|
||||
prof.enable()
|
||||
asyncio.run(arun(agraph, input_data))
|
||||
prof.disable()
|
||||
|
||||
prof_path = out_dir / f"{name}.prof"
|
||||
prof.dump_stats(str(prof_path))
|
||||
|
||||
print(f"\n{'=' * 60}")
|
||||
print(f"PROFILE: {name}")
|
||||
print(f"{'=' * 60}")
|
||||
stats = pstats.Stats(prof)
|
||||
stats.sort_stats("cumulative")
|
||||
stats.print_stats(20)
|
||||
|
||||
# Profile sync variant
|
||||
if graph is not None:
|
||||
prof = cProfile.Profile()
|
||||
prof.enable()
|
||||
run(graph, input_data)
|
||||
prof.disable()
|
||||
|
||||
prof_path = out_dir / f"{name}_sync.prof"
|
||||
prof.dump_stats(str(prof_path))
|
||||
|
||||
print(f"\n{'=' * 60}")
|
||||
print(f"PROFILE: {name}_sync")
|
||||
print(f"{'=' * 60}")
|
||||
stats = pstats.Stats(prof)
|
||||
stats.sort_stats("cumulative")
|
||||
stats.print_stats(20)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
from pyperf._runner import Runner
|
||||
from uvloop import new_event_loop
|
||||
|
||||
r = Runner()
|
||||
|
||||
# Full graph run time
|
||||
|
||||
Reference in New Issue
Block a user