Every value with a space loads a time zone from disk

オープン
#24 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go
領域
performance

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Go
スター
1
フォーク
0
平均マージ
1時間 43分
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tarantool/go-tupleconv のほかの issue

tarantool/go-tupleconv の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。