Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Avoid revalidating the entire remaining UTF-8 source for every lexer character

Đang mở Phù hợp với người mới
#935 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
83/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu với front/lexer/src/cursor.rs tại các phương thức advance và peek, sau đó đọc các bài kiểm tra con trỏ UTF-8 hiện có được thêm cho #392. Kiểm tra cách theo dõi độ lệch của con trỏ và cột chẩn đoán, rồi chạy các bài kiểm tra lexer trước và sau khi bổ sung phạm vi kiểm thử tập trung vào đầu vào dài. Mục tiêu là các thao tác trên từng ký tự không còn xác thực toàn bộ hậu tố còn lại, trong khi cách xử lý UTF-8 và các span vẫn chính xác; ghi lại các phép đo khả năng mở rộng mà không dùng khẳng định về thời gian.

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

Mô tả

good first issue performance

Problem

Lexer already stores its input as &str, but advance and peek repeatedly call std::str::from_utf8 on the entire remaining suffix. A long comment performs this linear suffix validation for each character, giving quadratic scanning work even though only the next character is needed.

Starting points: front/lexer/src/cursor.rs:25 and front/lexer/src/cursor.rs:47. Preserve the UTF-8 byte-offset and diagnostic-column contract; this is a cursor hot-path fix, not a lexer redesign. #392 added UTF-8 correctness tests but does not cover repeated suffix validation.

Reproduction

Audited canonical master d59bdab376bdc04edacdc8029b256cb8d55b5adf on Linux amd64 with a checkout-built Wave 0.0.1-alpha-dev, Rust 1.89.0 and LLVM 21.1.8.

With the debug compiler, checked files containing /* + N ASCII a characters + */\nfun main() {}\n, three executions per size:

Comment bytes Elapsed seconds
30,000 0.0707, 0.0633, 0.0665
60,000 0.2024, 0.2087, 0.1956
120,000 0.7333, 0.7140, 0.7221

All checks succeed. Doubling the long comment approaches four times the scanning cost. These are debug-build observations, not release benchmark claims. The repeated full-suffix validation is also directly visible in the source.

Reproduce with target/debug/wavec check long-comment.wave; use time.perf_counter() around repeated subprocess invocations and keep the number of tokens constant.

Scope

Decode/look ahead within the already-valid string without scanning its full suffix again. Difficulty: easy; the existing UTF-8 cursor tests provide a starting point.

Completion criteria

  • Preserve multibyte identifiers, comments, strings, CR/LF tracking and diagnostic spans.
  • Remove full-suffix UTF-8 validation from per-character cursor operations.
  • Add focused long-input correctness coverage and record scaling measurements; avoid a flaky wall-clock assertion in unit tests.
Ngôn ngữ chính
Rust
Star
56
Fork
21
Merge trung bình
4 giờ 58 phút
Pull request đã merge (30 ngày)
54

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

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 wavefnd/Wave

Tất cả issue của wavefnd/Wave

Issue tương tự

Thêm issue về Rust

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.