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

2023 Performance #3525

Merged
merged 7 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions sql/2023/performance/bfcache_cachecontrol_nostore.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE TEMP FUNCTION HAS_NO_STORE_DIRECTIVE(cache_control STRING) RETURNS BOOL AS (
REGEXP_CONTAINS(cache_control, r'(?i)\bno-store\b')
);

WITH requests AS (
SELECT
client,
LOGICAL_OR(HAS_NO_STORE_DIRECTIVE(JSON_VALUE(payload, '$._cacheControl'))) AS includes_ccns
FROM
`httparchive.all.requests`
WHERE
date = '2023-10-01' AND
is_main_document
GROUP BY
client,
page
)

SELECT
client,
COUNTIF(includes_ccns) AS pages,
COUNT(0) AS total,
COUNTIF(includes_ccns) / COUNT(0) AS pct
FROM
requests
GROUP BY
client
ORDER BY
client
31 changes: 31 additions & 0 deletions sql/2023/performance/bfcache_unload.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
WITH lh AS (
SELECT
client,
page,
rank,
JSON_VALUE(lighthouse, '$.audits.no-unload-listeners.score') = '0' AS has_unload
FROM
`httparchive.all.pages`
WHERE
date = '2023-10-01' AND
is_root_page
)


SELECT
client,
_rank AS rank,
COUNTIF(has_unload) AS pages,
COUNT(0) AS total,
COUNTIF(has_unload) / COUNT(0) AS pct
FROM
lh,
UNNEST([1000, 10000, 100000, 1000000, 10000000, 100000000]) AS _rank
WHERE
rank <= _rank
GROUP BY
client,
rank
ORDER BY
rank,
client
28 changes: 28 additions & 0 deletions sql/2023/performance/cls_animations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
WITH lh AS (
SELECT
client,
ARRAY_LENGTH(JSON_QUERY_ARRAY(lighthouse, '$.audits.non-composited-animations.details.items')) AS num_animations
FROM
`httparchive.all.pages`
WHERE
date = '2023-10-01' AND
is_root_page
)


SELECT
percentile,
client,
APPROX_QUANTILES(num_animations, 1000)[OFFSET(percentile * 10)] AS num_animations,
COUNTIF(num_animations > 0) AS pages,
COUNT(0) AS total,
COUNTIF(num_animations > 0) / COUNT(0) AS pct
FROM
lh,
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
GROUP BY
percentile,
client
ORDER BY
percentile,
client
27 changes: 27 additions & 0 deletions sql/2023/performance/cls_unsized_image_height.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
WITH lh AS (
SELECT
client,
CAST(JSON_VALUE(unsized_image, '$.node.boundingRect.height') AS INT64) AS height
FROM
`httparchive.all.pages`,
UNNEST(JSON_QUERY_ARRAY(lighthouse, '$.audits.unsized-images.details.items')) AS unsized_image
WHERE
date = '2023-10-01' AND
is_root_page
)


SELECT
percentile,
client,
APPROX_QUANTILES(height, 1000)[OFFSET(percentile * 10)] AS height,
COUNT(0) AS unsized_images
FROM
lh,
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
GROUP BY
percentile,
client
ORDER BY
percentile,
client
28 changes: 28 additions & 0 deletions sql/2023/performance/cls_unsized_images.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
WITH lh AS (
SELECT
client,
ARRAY_LENGTH(JSON_QUERY_ARRAY(lighthouse, '$.audits.unsized-images.details.items')) AS num_unsized_images
FROM
`httparchive.all.pages`
WHERE
date = '2023-10-01' AND
is_root_page
)


SELECT
percentile,
client,
APPROX_QUANTILES(num_unsized_images, 1000)[OFFSET(percentile * 10)] AS num_unsized_images,
COUNTIF(num_unsized_images > 0) AS pages,
COUNT(0) AS total,
COUNTIF(num_unsized_images > 0) / COUNT(0) AS pct
FROM
lh,
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
GROUP BY
percentile,
client
ORDER BY
percentile,
client
36 changes: 36 additions & 0 deletions sql/2023/performance/inp_long_tasks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
WITH long_tasks AS (
SELECT
client,
page,
ANY_VALUE(httparchive.core_web_vitals.GET_CRUX_INP(payload)) AS inp,
SUM(CAST(JSON_QUERY(item, '$.duration') AS FLOAT64)) AS long_tasks
FROM
`httparchive.all.pages`,
UNNEST(JSON_QUERY_ARRAY(lighthouse, '$.audits.long-tasks.details.items')) AS item
WHERE
date = '2023-10-01' AND
is_root_page
GROUP BY
client,
page
),

meta AS (
SELECT
*,
COUNT(0) OVER (PARTITION BY client) AS n,
ROW_NUMBER() OVER (PARTITION BY client ORDER BY inp) AS row
FROM
long_tasks
WHERE
inp IS NOT NULL
)

SELECT
client,
long_tasks,
inp
FROM
meta
WHERE
MOD(row, CAST(FLOOR(n / 1000) AS INT64)) = 0
16 changes: 16 additions & 0 deletions sql/2023/performance/inp_tbt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SELECT
percentile,
client,
APPROX_QUANTILES(CAST(JSON_QUERY(lighthouse, '$.audits.total-blocking-time.numericValue') AS FLOAT64), 1000)[OFFSET(percentile * 10)] AS tbt
FROM
`httparchive.all.pages`,
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
WHERE
date = '2023-10-01' AND
is_root_page
GROUP BY
percentile,
client
ORDER BY
percentile,
client
17 changes: 17 additions & 0 deletions sql/2023/performance/js_bytes_rank.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SELECT
IF(_rank < 100000000, CAST(_rank AS STRING), 'all') AS rank,
client,
APPROX_QUANTILES(CAST(JSON_VALUE(summary, '$.bytesJS') AS INT64), 1000)[OFFSET(500)] / 1024 AS js_kbytes
FROM
`httparchive.all.pages`,
UNNEST([1000, 10000, 100000, 1000000, 10000000, 100000000]) AS _rank
WHERE
date = '2023-10-01' AND
is_root_page AND
rank <= _rank
GROUP BY
rank,
client
ORDER BY
rank,
client
42 changes: 42 additions & 0 deletions sql/2023/performance/lcp_bytes_distribution.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
WITH pages AS (
SELECT
client,
page,
JSON_VALUE(custom_metrics, '$.performance.lcp_elem_stats.url') AS url
FROM
`httparchive.all.pages`
WHERE
date = '2023-10-01' AND
is_root_page
),

requests AS (
SELECT
client,
page,
url,
CAST(JSON_VALUE(summary, '$.respSize') AS INT64) / 1024 AS kbytes
FROM
`httparchive.all.requests`
WHERE
date = '2023-10-01' AND
is_root_page
)

SELECT
percentile,
client,
APPROX_QUANTILES(kbytes, 1000)[OFFSET(percentile * 10)] AS kbytes
FROM
pages
JOIN
requests
USING
(client, page, url),
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
GROUP BY
percentile,
client
ORDER BY
percentile,
client
43 changes: 43 additions & 0 deletions sql/2023/performance/lcp_bytes_histogram.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
WITH pages AS (
SELECT
client,
page,
JSON_VALUE(custom_metrics, '$.performance.lcp_elem_stats.url') AS url
FROM
`httparchive.all.pages`
WHERE
date = '2023-10-01' AND
is_root_page
),

requests AS (
SELECT
client,
page,
url,
CAST(JSON_VALUE(summary, '$.respSize') AS INT64) / 1024 AS kbytes
FROM
`httparchive.all.requests`
WHERE
date = '2023-10-01' AND
is_root_page
)

SELECT
client,
IF(CEILING(kbytes / 100) * 100 < 1000, CAST(CEILING(kbytes / 100) * 100 AS STRING), '1000+') AS kbytes,
COUNT(0) AS freq,
SUM(COUNT(0)) OVER (PARTITION BY client) AS total,
COUNT(0) / SUM(COUNT(0)) OVER (PARTITION BY client) AS pct
FROM
pages
JOIN
requests
USING
(client, page, url)
GROUP BY
client,
kbytes
ORDER BY
client,
kbytes
Loading