Skip to content

feat(khifile): partition client and server intern pools into dedicated chunks - #893

Merged
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-sxrrvuwsokrq
Aug 20, 2026
Merged

kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-sxrrvuwsokrq

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Partitions the interning pool data in KHI file format v6 into client-facing and server-only chunks, and updates the frontend parser to skip server-only chunks without decompressing them.

Background & Motivation

With the introduction of the Workbench service, detailed log bodies, manifests, and structured values (InternedStruct, FieldPathSet) are processed on demand on the server rather than on the frontend client. In the previous design, all interned strings and struct schemas were combined in ChunkTypeInternPool (Type 2), forcing the browser to decompress and parse large amounts of server-only structured data during initial loading.

By splitting the pool into:

  • ChunkTypeInternPool (Type 2): Client-facing strings (timeline names, log summaries, revisions, annotations)
  • ChunkTypeServerInternPool (Type 6): Server-only strings, FieldPathSet, and InternedStruct

and updating the frontend BinaryReader and KHIFileParser to skip unhandled chunks without decompressing gzip payloads, we achieve:

  1. Faster initial loading: Skips decompression and Protobuf decoding of server-only chunks.
  2. Reduced memory footprint: The browser maintains a compact string lookup array with dense IDs (1..N).

Key Changes

  • Model / Interning (pkg/model/khifile/v6):
    • Added NewIDGenerator() constructor and NewServerInternPool() helper delegating string lookups to parent pool.
    • Reserved ServerStringIDBase = 0x80000000 for IDServerString to eliminate collision with client string IDs.
    • Builder now outputs client strings to ChunkTypeInternPool (2) and server strings/field path sets/structs to ChunkTypeServerInternPool (6).
    • Workbench reader updated to process both ChunkTypeInternPool and ChunkTypeServerInternPool.
  • Frontend Core Parser (web/src/app/parser/core):
    • BinaryReader: Added readChunkHeader() and skipChunkPayload(size) to allow skipping chunk bodies without gzip decompression.
    • KHIFileParser: Skips unknown/unregistered chunk types (e.g. ChunkTypeServerInternPool) during ingestion.
  • Documentation:
    • Updated docs/en/architecture/khi-file-format.md and docs/ja/architecture/khi-file-format.md.
  • Tests:
    • Added unit tests for server intern pool string resolution and ID isolation in Go.
    • Added unit tests for chunk skipping in BinaryReader and KHIFileParser in Angular/TS.

Verification

  • make test-go passed.
  • make test-web passed.
  • make lint-go / make lint-web passed.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request partitions the interning pool into client-facing and server-only chunks (Type 6) to optimize frontend memory usage and initial load times. The backend now writes these pools separately, and the frontend parser has been updated to skip server-only chunks without performing decompression. A review comment correctly identified an issue in the frontend parser where skipping chunks prevents the chunkIndex from being incremented, which would lead to incorrect chunk indices in decode error reports.

Comment thread web/src/app/parser/core/file-parser.ts Resolved
@kyasbal
kyasbal merged commit 631d3b4 into GoogleCloudPlatform:main Aug 20, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-sxrrvuwsokrq branch August 20, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant