perf(sidecar): raw-binary readFileSync transfer (skip base64)

Đang mở
#81 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, rust
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Bắt đầu với crates/execution/src/v8_runtime.rs:183, crates/execution/assets/v8-bridge.source.js và crates/v8-runtime/src/host_call.rs để lần theo các đường dẫn phản hồi nhị phân hiện có. Kiểm tra các consumer {__agentOsType:"bytes"} khác, sau đó thêm coverage cho các thao tác đọc nhị phân đồng bộ và đọc qua promise, cùng với tính đối xứng của writeFileBinary; hoàn tất nghĩa là các thao tác đọc nhị phân sử dụng đường dẫn raw-binary mà không qua base64.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Background

Guest binary fs.readFileSync(path) (no encoding) goes
_fs.readFileBinary → _fsReadFileBinary → mapped to fs.readFileSync with the
binary flag (crates/execution/src/v8_runtime.rs:183) → host returns the bytes as
a base64-encoded JSON object (javascript_sync_rpc_bytes_value:
{ "__agentOsType": "bytes", "base64": "..." }), and the guest decodes with
Buffer.from(base64, "base64") (crates/execution/assets/v8-bridge.source.js).

So every binary file read pays base64 encode (host) + decode (guest) plus ~33%
payload inflation. The base64 round-trip is wasted work.

Proposal

Transfer file bytes as raw binary instead of base64. The bridge response
protocol already has a raw-binary path (status = 2 / Uint8Array, see
crates/v8-runtime/src/host_call.rs). Route readFileSync's binary result through
that path and have the guest do Buffer.from(uint8array) directly.

Why it wasn't done in PR #77

The sync-RPC return type is a serde_json::Value, which can't carry raw bytes —
hence the base64 representation. Switching readFileSync to the status=2
raw-binary response is a cross-cutting protocol change that affects every
binary file read, so it was deferred rather than rushed (read was already 6.2×
faster from the pump fix in #77). Needs careful implementation + tests for:
binary readFile (sync + promises), writeFileBinary symmetry, and the
{__agentOsType:"bytes"} consumers elsewhere.

Expected impact

Removes base64 encode/decode + ~33% payload inflation per binary read; helps
read-heavy guests (bundlers, asset pipelines, large node_modules).

Ngôn ngữ chính
TypeScript
Star
1k
Fork
53
Merge trung bình
2 giờ 54 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rivet-dev/dynamic-apps

Tất cả issue của rivet-dev/dynamic-apps

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.