runtime: timer.seq field seems unnecessary #46457
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What's the purpose of
seq
field in runtimeTimer?According to runtime/time.go implementation, runtime/time.go define
timer
struct, including seq field. This seq field will not be modified by runtime and always keep the value when timer struct was created. The only place to use seq field is the callback of timer.f in runOneTimer.However, in time/sleep.go, this seq field isn't set when initializing
And the callback runtimeTImer.f doesn't use this field too:
At first I guess this is for some compatible reason. But even when go1.0.1 this seq field is not used: https://github.com/golang/go/blob/go1.0.1/src/pkg/time/sleep.go
The comment
each time calling f(arg, now) in the timer goroutine
in https://github.com/golang/go/blob/go1.16.4/src/runtime/time.go#L24 is inconsistent with the behavior.It seems to me the seq field should be removed to help understand source code of timer more easily without confusion, and maybe improve the performance (very very slightly).
Should this seq field be remove? Please let me known if I miss something other!
The text was updated successfully, but these errors were encountered: