Repository navigation
Conversation
lqiu96
force-pushed
the
perf/bigquery-unwrap-cell-json
branch
from
October 12, 2026 19:15
1c644ac to
2bcaaa0
Compare
lqiu96
force-pushed
the
perf/bigquery-unwrap-cell-json
branch
3 times, most recently
from
October 12, 2026 20:52
3cbf444 to
97478f4
Compare
lqiu96
force-pushed
the
perf/bigquery-unwrap-cell-json
branch
from
October 12, 2026 20:58
97478f4 to
2945be9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Streams and unwraps BigQuery REST v2
TableCell{"v": ...}envelopes directly inHttpBigQueryRpcfor row-returning RPCs (listTableData,getQueryResults, andqueryRpc), avoiding reflectiveGenericJson/TableCell/ArrayMap/EnumSetallocations per cell and bringinggoogle-cloud-javato parity with the other official BigQuery client libraries.Cross-Language Parity
Among the official Google Cloud BigQuery client libraries, Java was the only SDK instantiating a reflective Discovery model class (
TableCell extends GenericJson extends GenericData, which invokesClass.getDeclaredConstructor(), allocates anunknownFieldsArrayMap, and allocates anEnumSetof flags) for every cell in every row. Because the BigQuery REST v2 row wire format ("rows": [{"f": [{"v": ...}]}]) is strictly fixed by the protocol, all other official SDKs avoid reflective model instantiation on therowshot path and unwrap"f"and"v"directly:google-cloud-bigquery):json.loadswithout Discovery model classes, then walksrow["f"]and unwrapscell["v"]directly in_row_tuple_from_jsonandCellDataParser.record_to_py(google/cloud/bigquery/_helpers.py).@google-cloud/bigquery):JSON.parseinto plain objects without wrapper classes or reflection, then mapsrow.fand unwrapsfield.v(andval.vforREPEATEDelements) inBigQuery.mergeSchemaWithRows_(src/bigquery.js).cloud.google.com/go/bigquery+google.golang.org/api/bigquery/v2):TableCellas a 1-field struct (type TableCell struct { V interface{} }) with no unknown-fields map or reflection (bigquery/v2/bigquery-gen.go), decodes nestedRECORDandREPEATEDvalues insideVas plainmap[string]interface{}and[]interface{}viaencoding/json, and indexes["v"]and["f"]directly inconvertValues(bigquery/value.go).google-cloud-bigquery/google-cloud-bigquery-v2):rowsasVec<wkt::Struct>(serde_json::Map) without reflective Discovery models and immediately removes"f"and"v"inconvert_row,get_field_list, andget_field_value(src/query/row.rs).google-cloud-swift):"rows"/"f"/"v"UTF-8 JSON tokens in a single pass and unwraps"v"on the fly inRowJSONScanner(Sources/GoogleCloudBigQuery/Row.swift).Details
HttpBigQueryRpc(java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java):"rows"array viaparseTableRows/parseRowCells/parseCellValuewhile delegating all top-level response metadata (schema,pageToken,totalRows,jobReference,errors, etc.) togoogle-http-client'sClassInfo/JsonParser.ArrayListusing the column count observed on the first row of the page.{"v": ...}cell envelopes in place and represents single-key{"f": [...]}RECORD(STRUCT) values withCollections.singletonMap.FieldValue.fromPb(java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/FieldValue.java):TableCell/Mapwrappers.Performance Benchmark (
16columns per row)1. Deterministic Client-Side HTTP Stream Benchmark (
300,000rows /4,800,000cells)Parsing an in-memory
TableDataListJSON stream throughBigQuery.listTableData->HttpBigQueryRpc->FieldValueList.fromPb(isolating client deserialization from BigQuery server and network variance):16cols)2.71.0)300,0002.704 s110,950 rows/s1,296.5 MB283.2 bytes/cellperf/bigquery-unwrap-cell-json)300,0000.699 s(-74.1%)429,424 rows/s(3.87x)701.4 MB(-45.9%)153.2 bytes/cell(-130.0 B/cell)2. Live BigQuery End-to-End Benchmark (
tpch_10T.lineitem,1kto10Mrows)Measured against
lawrence-test-project-2:tpch_10T.lineitem(16columns per row) in fresh JVM processes. Live REST pagination is~96%network-bound (~40 sof client CPU time out of~1,000-1,150 stotal wall time across10Mrows). Note thatjobs.querybelow was run withsetUseQueryCache(false)(forcing a cold server scan oftpch_10T.lineitem, e.g.,29.93 sinitial server execution at10Mrows before returning page 1, followed by989.64 sfor row iteration).N)2.71.0) Wall Timebytes/cell)tabledata.list1,00016,0007.18 s(139 rows/s)7.10 s + 0.004 s = 7.11 s(141 rows/s)413.9/413.9 MB258.1/258.1 MB-37.6%0.654 s155.2 MBtabledata.list100,0001,600,00013.44 s(7,438 rows/s)6.85 s + 6.52 s = 13.36 s(7,483 rows/s)642.8/642.8 MB431.8/431.8 MB-32.8%1.027 s(-43.2%)297.2 MB(194.8 B/cell,-46.9%)tabledata.list1,000,00016,000,000114.86 s(8,707 rows/s)6.34 s + 107.80 s = 114.14 s(8,761 rows/s)1,683.6/1,683.6 MB1,117.8/1,117.8 MB-33.6%4.680 s2,421.2 MB(158.7 B/cell)tabledata.list10,000,000160,000,0001,144.72 s(8,736 rows/s)6.61 s + 1,146.55 s = 1,153.16 s(8,672 rows/s)1,891.1/2,095.4 MB1,479.4/1,565.0 MB-25.3%(-21.8%Final)39.401 s23,892.9 MB(156.6 B/cell)jobs.query1,00016,0001.69 s(cached)2.03 s(cached) /3.93 s(cold,0.004 siter)145.4/145.4 MB139.7/139.7 MB-3.9%0.389 s16.9 MBjobs.query100,0001,600,00012.69 s(cached) /16.94 s(cold)14.16 s(cached) /18.03 s(cold)587.3/587.3 MB366.9/366.9 MB-37.5%0.953 s(-48.7%)263.4 MB(172.6 B/cell,-46.1%)jobs.query1,000,00016,000,000147.83 s(cold)13.30 s + 104.24 s = 117.55 s(8,507 rows/s)787.1/787.1 MB514.8/514.8 MB-34.6%4.638 s2,440.7 MB(160.0 B/cell)jobs.query10,000,000160,000,000997.37 s(cached)29.93 s(cold)+ 989.64 siter= 1,019.57 s1,619.0/2,063.9 MB1,178.4/1,548.7 MB-25.0%(-27.2%Final)40.671 s24,099.6 MB(157.9 B/cell)