Every value with a space loads a time zone from disk

Aperta
#24 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
performance

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Go
Stelle
1
Fork
0
Merge medio
1h 43m
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tarantool/go-tupleconv

Tutte le issue di tarantool/go-tupleconv

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.