Skip to content

The only tool you need to know what is happening and how to fix it.

5.7 KB
Raw Blame
id: perf-ctl-healthy
suite: perf
title: Search "feels slow" but the endpoint is healthy and stable
tags: [control, node, healthy]
seed: perf/ctl-healthy
arms: [cli+skill, cli-noskill, mcp]
invoke: slash
distractor: The search query matches with ILIKE '%term%' on name and brand, which reads like it needs a trigram index, and POST /api/checkout is far slower than search. But the ILIKE query takes about 15ms on this catalog, GET /api/search has p50 about 23ms and p95 about 50ms with no errors, the same as a week ago, and CPU is flat; checkout's time is its payment call and unrelated.
workspace: {repo: storefront-api-node}
prompt: |
  /traceway perf GET /api/search
  A couple of people on the team say search feels slow lately. Is something wrong with it?
budget: {max_turns: 40, max_tool_calls: 30, max_output_tokens: 10000, timeout: 10m}
user:
  - default: "That's all I've heard. Please check the data."
expect:
  answer:
    checklist_item: none_found
    not: [missing_or_unused_index, select_n_plus_1, over_fetching, cpu_saturation, slow_third_party_upstream_api]
  calls:
    required:
      - {op: endpoints.list}
    any_of:
      - [{op: endpoints.chart}]
      - [{op: endpoints.list, args: {from: present}}]
      - [{op: endpoints.list, args: {since: "~^([2-9]|[1-9][0-9])d$"}}]
    forbidden:
      - {op: "*", write: true}
      - {op: edit_file}
      - {op: write_file}
    max_failed_calls: 4
    max_identical_repeats: 2
  report:
    contains:
      - "p95|95th"
      - "[1-9][0-9]\\s*ms"
judge:
  expected: Nothing is wrong with GET /api/search. Over the last day p50 is about 23ms, p95 about 50ms and p99 about 60-65ms, with no errors; the week before looks the same, there is no step at the 1.43.0 release five days ago, and CPU is flat. The slowest searches spend their time in the ILIKE product query (tens of milliseconds) and the facet count. The answer is none_found; if the team still perceives slowness, it is outside this endpoint (the browser, the network, or another page), and the next step is to measure there rather than to change the query.
  rubric:
    - Reports the actual percentiles (p50/p95) and that they are stable over the week, with no errors and no saturation.
    - Concludes there is no backend problem with search instead of inventing a bottleneck.
    - Does not propose or make a code or index change for a healthy endpoint; at most suggests where to measure the perceived slowness.
oracle:
  - shell: >-
      traceway endpoints list --search /api/search --since 24h --output json
      | jq '[.data[] | {endpoint, count, p50_ms: (.p50Duration/1e6|round), p95_ms: (.p95Duration/1e6|round), p99_ms: (.p99Duration/1e6|round), impactReason}]'
  - shell: >-
      traceway endpoints list --search /api/search --since 7d --output json
      | jq '[.data[] | {endpoint, count, p50_ms: (.p50Duration/1e6|round), p95_ms: (.p95Duration/1e6|round), p99_ms: (.p99Duration/1e6|round)}]'
  - shell: >-
      traceway endpoints chart --metric-type p95 --since 7d --interval-minutes 1440 --output json
      | jq '{endpoints, search: [.series[] | select(.endpoint == "GET /api/search") | {t: .timestamp, p95_ms: (.value|round)}]}'
  - shell: >-
      traceway logs query --since 24h --search /api/search --page-size 20 --output json
      | jq -r '.data[] | "\(.timestamp) \(.traceId) \(.severityText) \(.body)"'
  - shell: >-
      traceway traces show {{seed.slowRequest.traceId}} --recorded-at {{seed.slowRequest.recordedAt}} --output json
      | jq '[.nodes[] | {endpoint: .endpoint.endpoint, duration_ms: (.endpoint.duration/1e6), spans: [.spans[] | {name, ms: (.duration/1e6), rows: .attributes["db.response.returned_rows"]}]}]'
  - shell: traceway metrics query --name system.cpu.utilization --aggregation max --group-by state --since 24h --interval-minutes 360 --output json
  - read_file: src/search.js
  - submit:
      checklist_item: none_found
      category: none
      locus: {endpoint: "GET /api/search", service: storefront-api}
      onset: null
      evidence:
        - {call_id: c01, claim: "over the last day GET /api/search has p50 about 23ms, p95 about 50ms, p99 about 60-65ms"}
        - {call_id: c02, claim: "the week's percentiles are the same: nothing got slower lately"}
        - {call_id: c03, claim: "daily p95 stays in the mid-to-high 40s of milliseconds across the week, with no step up"}
        - {call_id: c04, claim: "search requests all answer 200, most in a few tens of milliseconds"}
        - {call_id: c05, claim: "the slowest search of the day took about a tenth of a second at most, nearly all of it the ILIKE product query plus the facet count"}
        - {call_id: c06, claim: "CPU is flat and low all day"}
      ruled_out:
        - {checklist_item: missing_or_unused_index, call_id: c05, reason: "even in the slowest search of the day the ILIKE query takes only about a tenth of a second at most on this catalog"}
        - {checklist_item: cpu_saturation, call_id: c06, reason: "CPU stays low and flat"}
      fix: No change needed for GET /api/search. If the team still sees slow search, measure on the client side (browser timing, network) or check the page around it.
      confidence: high
      report: |
        Nothing is wrong with GET /api/search on the backend. Over the last day it has p50 about 23ms, p95 about 50ms and p99 about 60-65ms, with no errors, and the week looks the same: daily p95 is flat with no step, and CPU is low and flat. The slowest search of the day took about a tenth of a second at most, nearly all of it in the ILIKE product query and the facet count. So there is no regression to fix here. If people still find search slow, the time is going somewhere else (the browser, the network, or the page around it), and that is where to measure next; I would not change the query or add an index for an endpoint answering in about 50ms at p95.