Skip to content

perf: expand Encode() type switch with more common types #60

@xe-nvdk

Description

@xe-nvdk

Problem

Every type not in the Encode() type switch hits reflect.ValueOf(v) which boxes on the heap + getEncoder() sync.Map lookup. Currently covered: nil, string, []byte, int, int64, uint, uint64, bool, float32, float64, time.Duration, time.Time, map[string]string, map[string]interface{}, []interface{}.

Proposal

Add more common types to the switch:

  • int8, int16, int32
  • uint8, uint16, uint32
  • []string
  • map[string]bool
  • []byte fast path (if not already optimal)

Each addition eliminates reflect.ValueOf boxing + sync.Map lookup for that type.

Files

  • encode.goEncode() method type switch

Expected Impact

MEDIUM — depends on Arc's type distribution. Each added type eliminates 1 reflect.ValueOf + 1 sync.Map load per encode call of that type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions