Every value with a space loads a time zone from disk

Đang mở
#24 0 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
performance

Hướng nghiên cứu

Start with StringToDatetimeConverter.Convert in converter.go around line 211, then find the tests and benchmarks for string-to-datetime conversion. Check that ordinary strings containing spaces avoid unnecessary location loads, while valid named time zones still convert and failed loads are not cached. Done means the relevant tests and benchmarks pass and the host tzdata requirement is documented.

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

Mô tả

Reproduction snippets assume:

fac := tupleconv.MakeStringToTTConvFactory()

Where: StringToDatetimeConverter.Convert (converter.go:211).

The converter splits the input on the first space and calls time.LoadLocation with the rest. Go doesn't cache locations, so every call reads tzdata from disk. In any/scalar, every string containing a space goes through this path before it falls back to string.

Benchmarks (linux/amd64, Go 1.26):

BenchmarkScalarNoSpace       1374 ns/op     573 B/op   23 allocs/op   // "hello"
BenchmarkScalarWithSpace    31102 ns/op   41916 B/op   34 allocs/op   // "hello world"
BenchmarkDatetimeOffset       319 ns/op      24 B/op    1 allocs/op   // "2023-08-30T12:06:05+0200"
BenchmarkDatetimeTZName     10782 ns/op    6876 B/op   21 allocs/op   // "2023-08-30T12:06:05 Europe/Paris"

Suggested fix: check that the date part has the expected shape before loading the location, and cache loaded locations by name (only successful loads, so arbitrary input can't grow the cache). Also document that named zones need tzdata on the host, or import _ "time/tzdata" in the binary (e.g. for scratch or distroless images).

Ngôn ngữ chính
Go
Star
1
Fork
0
Merge trung bình
1 giờ 43 phút
Pull request đã merge (30 ngày)
2

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 tarantool/go-tupleconv

Tất cả issue của tarantool/go-tupleconv

Issue tương tự

Thêm issue về Go

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.