Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(max): Use async_except_on_cache_miss in question suggestions #25803

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2a3e9ef
feat: new mode
skoob13 Oct 23, 2024
1a819d1
feat: ai queries in tasks
skoob13 Oct 23, 2024
7409fb5
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 23, 2024
e6a6c3d
Move `ExecutionMode` to `schema.{ts,py}`
Twixes Oct 24, 2024
faab073
Use `async_except_on_cache_miss` in question suggestions
Twixes Oct 24, 2024
9a0d15d
Revert "Move `ExecutionMode` to `schema.{ts,py}`"
Twixes Oct 24, 2024
21fbbd8
Unify `api.query()`'s `refresh` and `async`
Twixes Oct 24, 2024
47c3f3c
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 24, 2024
62b1273
Merge branch 'master' into async-except-on-cache-miss-suggestions
Twixes Oct 25, 2024
a623c6f
Update query_runner.py
Twixes Oct 25, 2024
6e38dd4
Update query snapshots
github-actions[bot] Oct 25, 2024
7bb5f98
Update query snapshots
github-actions[bot] Oct 25, 2024
8e3768b
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 25, 2024
7453915
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 25, 2024
5d5be04
Update query snapshots
github-actions[bot] Oct 25, 2024
e1e7f85
Update query snapshots
github-actions[bot] Oct 25, 2024
31f34cf
Update query snapshots
github-actions[bot] Oct 25, 2024
f6280ff
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 25, 2024
82f0c25
Update query snapshots
github-actions[bot] Oct 25, 2024
f062da2
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 25, 2024
f853c83
Update query snapshots
github-actions[bot] Oct 25, 2024
a4c79dd
Update query snapshots
github-actions[bot] Oct 25, 2024
244cfef
Merge branch 'master' into async-except-on-cache-miss-suggestions
Twixes Oct 25, 2024
8205d70
Update query snapshots
github-actions[bot] Oct 25, 2024
ae329ab
Update query snapshots
github-actions[bot] Oct 25, 2024
9ee3ad9
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 25, 2024
c0882d8
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 25, 2024
cc88867
Update query snapshots
github-actions[bot] Oct 25, 2024
94fdaee
Merge branch 'master' into async-except-on-cache-miss-suggestions
Twixes Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2449,8 +2449,7 @@ const api = {
query: T,
options?: ApiMethodOptions,
queryId?: string,
refresh?: boolean,
async?: boolean,
refresh?: RefreshType,
filtersOverride?: DashboardFilter | null,
variablesOverride?: Record<string, HogQLVariable> | null
): Promise<
Expand All @@ -2460,13 +2459,12 @@ const api = {
: T['response']
: Record<string, any>
> {
const refreshParam: RefreshType | undefined = refresh && async ? 'force_async' : async ? 'async' : refresh
return await new ApiRequest().query().create({
...options,
data: {
query,
client_query_id: queryId,
refresh: refreshParam,
refresh,
filters_override: filtersOverride,
variables_override: variablesOverride,
},
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
NodeKind,
PersonsNode,
QueryStatus,
RefreshType,
} from './schema'
import {
isAsyncResponse,
Expand Down Expand Up @@ -101,12 +102,13 @@ async function executeQuery<N extends DataNode>(
!!featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.QUERY_ASYNC]

if (!pollOnly) {
const refreshParam: RefreshType | undefined =
refresh && isAsyncQuery ? 'force_async' : isAsyncQuery ? 'async' : refresh
const response = await api.query(
queryNode,
methodOptions,
queryId,
refresh,
isAsyncQuery,
refreshParam,
filtersOverride,
variablesOverride
)
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10478,6 +10478,10 @@
"const": "async",
"type": "string"
},
{
"const": "async_except_on_cache_miss",
"type": "string"
},
{
"const": "blocking",
"type": "string"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ export type LifecycleFilter = {
export type RefreshType =
| boolean
| 'async'
| 'async_except_on_cache_miss'
| 'blocking'
| 'force_async'
| 'force_blocking'
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/scenes/max/maxLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ export const maxLogic = kea<maxLogicType>([
null as string[] | null,
{
loadSuggestions: async () => {
const response = await api.query<SuggestedQuestionsQuery>({
kind: NodeKind.SuggestedQuestionsQuery,
})
const response = await api.query<SuggestedQuestionsQuery>(
{ kind: NodeKind.SuggestedQuestionsQuery },
undefined,
undefined,
'async_except_on_cache_miss'
)
return response.questions
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
FROM events LEFT JOIN (
SELECT person_static_cohort.person_id AS cohort_person_id, 1 AS matched, person_static_cohort.cohort_id AS cohort_id
FROM person_static_cohort
WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [6]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [4]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 420), 1, ifNull(equals(__in_cohort.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0
Expand All @@ -42,7 +42,7 @@
FROM events LEFT JOIN (
SELECT person_id AS cohort_person_id, 1 AS matched, cohort_id
FROM static_cohort_people
WHERE in(cohort_id, [6])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE in(cohort_id, [4])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE and(1, equals(__in_cohort.matched, 1))
LIMIT 100
'''
Expand All @@ -55,7 +55,7 @@
FROM events LEFT JOIN (
SELECT person_static_cohort.person_id AS cohort_person_id, 1 AS matched, person_static_cohort.cohort_id AS cohort_id
FROM person_static_cohort
WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [7]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [5]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 420), 1, ifNull(equals(__in_cohort.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0
Expand All @@ -66,7 +66,7 @@
FROM events LEFT JOIN (
SELECT person_id AS cohort_person_id, 1 AS matched, cohort_id
FROM static_cohort_people
WHERE in(cohort_id, [7])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE in(cohort_id, [5])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE and(1, equals(__in_cohort.matched, 1))
LIMIT 100
'''
Expand Down
Loading
Loading