mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
The scheduler workflow keeps a cache of a sequence of calls to getNextTime to reduce overhead. The cache was serialized as json, this changes it to serialize as proto. This is made forwards and backwards compatible by trying to deserialize into both types. The json decoding of this cache showed up as a significant cost in a cpu profile of a worker that was doing a lot of schedule workflow replays. In a simple benchmark of decoding only on my laptop, decoding the proto was about 20 times faster with no jitter (14 with jitter), and the encoded proto was 8 times smaller (5 with jitter). Encoding was about 4 times faster (but that's less important). ``` no jitter: BenchmarkDecodeJson-12 178678 33114 ns/op 1848 B/op 13 allocs/op BenchmarkDecodeProto-12 2249361 1571 ns/op 288 B/op 3 allocs/op with jitter: BenchmarkDecodeJson-12 110619 32657 ns/op 1848 B/op 13 allocs/op BenchmarkDecodeProto-12 1565641 2336 ns/op 400 B/op 4 allocs/op ``` existing tests (especially replay test for backwards + forwards compatibility) The code is a little more complicated and there could be bugs in the conversion. Note that both json and proto support nanosecond resolution for timestamps.
475 lines
13 KiB
Go
475 lines
13 KiB
Go
// The MIT License
|
|
//
|
|
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
|
|
//
|
|
// Copyright (c) 2020 Uber Technologies, Inc.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
// Code generated by protoc-gen-go-helpers. DO NOT EDIT.
|
|
package schedule
|
|
|
|
import (
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// Marshal an object of type BufferedStart to the protobuf v3 wire format
|
|
func (val *BufferedStart) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type BufferedStart from the protobuf v3 wire format
|
|
func (val *BufferedStart) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *BufferedStart) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two BufferedStart values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *BufferedStart) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *BufferedStart
|
|
switch t := that.(type) {
|
|
case *BufferedStart:
|
|
that1 = t
|
|
case BufferedStart:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type InternalState to the protobuf v3 wire format
|
|
func (val *InternalState) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type InternalState from the protobuf v3 wire format
|
|
func (val *InternalState) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *InternalState) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two InternalState values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *InternalState) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *InternalState
|
|
switch t := that.(type) {
|
|
case *InternalState:
|
|
that1 = t
|
|
case InternalState:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type StartScheduleArgs to the protobuf v3 wire format
|
|
func (val *StartScheduleArgs) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type StartScheduleArgs from the protobuf v3 wire format
|
|
func (val *StartScheduleArgs) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *StartScheduleArgs) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two StartScheduleArgs values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *StartScheduleArgs) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *StartScheduleArgs
|
|
switch t := that.(type) {
|
|
case *StartScheduleArgs:
|
|
that1 = t
|
|
case StartScheduleArgs:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type FullUpdateRequest to the protobuf v3 wire format
|
|
func (val *FullUpdateRequest) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type FullUpdateRequest from the protobuf v3 wire format
|
|
func (val *FullUpdateRequest) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *FullUpdateRequest) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two FullUpdateRequest values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *FullUpdateRequest) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *FullUpdateRequest
|
|
switch t := that.(type) {
|
|
case *FullUpdateRequest:
|
|
that1 = t
|
|
case FullUpdateRequest:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type DescribeResponse to the protobuf v3 wire format
|
|
func (val *DescribeResponse) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type DescribeResponse from the protobuf v3 wire format
|
|
func (val *DescribeResponse) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *DescribeResponse) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two DescribeResponse values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *DescribeResponse) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *DescribeResponse
|
|
switch t := that.(type) {
|
|
case *DescribeResponse:
|
|
that1 = t
|
|
case DescribeResponse:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type WatchWorkflowRequest to the protobuf v3 wire format
|
|
func (val *WatchWorkflowRequest) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type WatchWorkflowRequest from the protobuf v3 wire format
|
|
func (val *WatchWorkflowRequest) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *WatchWorkflowRequest) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two WatchWorkflowRequest values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *WatchWorkflowRequest) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *WatchWorkflowRequest
|
|
switch t := that.(type) {
|
|
case *WatchWorkflowRequest:
|
|
that1 = t
|
|
case WatchWorkflowRequest:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type WatchWorkflowResponse to the protobuf v3 wire format
|
|
func (val *WatchWorkflowResponse) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type WatchWorkflowResponse from the protobuf v3 wire format
|
|
func (val *WatchWorkflowResponse) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *WatchWorkflowResponse) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two WatchWorkflowResponse values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *WatchWorkflowResponse) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *WatchWorkflowResponse
|
|
switch t := that.(type) {
|
|
case *WatchWorkflowResponse:
|
|
that1 = t
|
|
case WatchWorkflowResponse:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type StartWorkflowRequest to the protobuf v3 wire format
|
|
func (val *StartWorkflowRequest) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type StartWorkflowRequest from the protobuf v3 wire format
|
|
func (val *StartWorkflowRequest) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *StartWorkflowRequest) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two StartWorkflowRequest values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *StartWorkflowRequest) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *StartWorkflowRequest
|
|
switch t := that.(type) {
|
|
case *StartWorkflowRequest:
|
|
that1 = t
|
|
case StartWorkflowRequest:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type StartWorkflowResponse to the protobuf v3 wire format
|
|
func (val *StartWorkflowResponse) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type StartWorkflowResponse from the protobuf v3 wire format
|
|
func (val *StartWorkflowResponse) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *StartWorkflowResponse) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two StartWorkflowResponse values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *StartWorkflowResponse) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *StartWorkflowResponse
|
|
switch t := that.(type) {
|
|
case *StartWorkflowResponse:
|
|
that1 = t
|
|
case StartWorkflowResponse:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type CancelWorkflowRequest to the protobuf v3 wire format
|
|
func (val *CancelWorkflowRequest) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type CancelWorkflowRequest from the protobuf v3 wire format
|
|
func (val *CancelWorkflowRequest) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *CancelWorkflowRequest) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two CancelWorkflowRequest values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *CancelWorkflowRequest) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *CancelWorkflowRequest
|
|
switch t := that.(type) {
|
|
case *CancelWorkflowRequest:
|
|
that1 = t
|
|
case CancelWorkflowRequest:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type TerminateWorkflowRequest to the protobuf v3 wire format
|
|
func (val *TerminateWorkflowRequest) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type TerminateWorkflowRequest from the protobuf v3 wire format
|
|
func (val *TerminateWorkflowRequest) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *TerminateWorkflowRequest) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two TerminateWorkflowRequest values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *TerminateWorkflowRequest) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *TerminateWorkflowRequest
|
|
switch t := that.(type) {
|
|
case *TerminateWorkflowRequest:
|
|
that1 = t
|
|
case TerminateWorkflowRequest:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|
|
|
|
// Marshal an object of type NextTimeCache to the protobuf v3 wire format
|
|
func (val *NextTimeCache) Marshal() ([]byte, error) {
|
|
return proto.Marshal(val)
|
|
}
|
|
|
|
// Unmarshal an object of type NextTimeCache from the protobuf v3 wire format
|
|
func (val *NextTimeCache) Unmarshal(buf []byte) error {
|
|
return proto.Unmarshal(buf, val)
|
|
}
|
|
|
|
// Size returns the size of the object, in bytes, once serialized
|
|
func (val *NextTimeCache) Size() int {
|
|
return proto.Size(val)
|
|
}
|
|
|
|
// Equal returns whether two NextTimeCache values are equivalent by recursively
|
|
// comparing the message's fields.
|
|
// For more information see the documentation for
|
|
// https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
|
|
func (this *NextTimeCache) Equal(that interface{}) bool {
|
|
if that == nil {
|
|
return this == nil
|
|
}
|
|
|
|
var that1 *NextTimeCache
|
|
switch t := that.(type) {
|
|
case *NextTimeCache:
|
|
that1 = t
|
|
case NextTimeCache:
|
|
that1 = &t
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return proto.Equal(this, that1)
|
|
}
|