Skip to content

Commit 40e16e0

Browse files
lmeyerovclaude
andcommitted
perf(gfql): route engine=auto to native polars for polars-frame graphs
resolve_engine(AUTO) maps polars frames to PANDAS (it predates Engine.POLARS), so g.gfql(query) on a polars-frame graph silently bridged to the generic pandas path: ~3-13x slower on cypher point queries and pandas frames out. Route AUTO to the native polars engine; an honest NotImplementedError (unsupported shape) falls back to the legacy AUTO path — allowed because the user did not pin an engine. Frames in = frames out: AUTO results on polars graphs are now polars. Repro: 2k-node polars graph, seeded 1-hop cypher — AUTO 25.0ms/pandas out before, 9.3ms/polars out after (engine='polars' = 8.8ms); polars-NIE shapes (shortestPath) still answer via the pandas fallback. Fixes the q5 finding in plans/gfql-benchmark-numbers (inferred-engine 13x penalty). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6dQEcjdazEnzuvuwf73ZL
1 parent 233b64c commit 40e16e0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

graphistry/compute/gfql_unified.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,24 @@ def gfql(self: Plottable,
18081808
:returns: Resulting Plottable
18091809
:rtype: Plottable
18101810
"""
1811+
# engine inference: resolve_engine(AUTO) maps polars frames to PANDAS (polars predates
1812+
# Engine.POLARS there), silently bridging polars-frame graphs onto the generic pandas path
1813+
# (~13x slower on cypher point queries, pandas frames out). Route AUTO to the native polars
1814+
# engine instead; an honest NIE (unsupported shape) falls back to the legacy AUTO path, which
1815+
# is allowed here because the user did not pin an engine.
1816+
if (
1817+
(engine == EngineAbstract.AUTO or engine == EngineAbstract.AUTO.value)
1818+
and is_polars_df(self._edges) and (self._nodes is None or is_polars_df(self._nodes))
1819+
):
1820+
try:
1821+
return gfql(
1822+
self, query, engine=Engine.POLARS.value, output=output, policy=policy,
1823+
where=where, language=language, params=params, validate=validate,
1824+
shortest_path_backend=shortest_path_backend,
1825+
)
1826+
except NotImplementedError:
1827+
logger.debug('AUTO polars-native attempt declined; falling back to generic path')
1828+
18111829
context = ExecutionContext()
18121830

18131831
if policy and context.policy_depth >= 1:

0 commit comments

Comments
 (0)