Skip to content

write(io, ::Int) allocates #39041

@Seelengrab

Description

@Seelengrab
julia> p, io = mktemp()
("/tmp/jl_ry8Ly0", IOStream(<fd 21>))

julia> @time write(io, 1234)
  0.000006 seconds (1 allocation: 16 bytes)
8

julia> versioninfo()
Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_PKG_SERVER =
  JULIA_NUM_THREADS = 4

Called in a tight loop, this quickly racks up allocations, overwhelming GC. This seems to be caused by the Int getting wrapped in a Ref further down the call chain, forcing it to be moved to the heap because of a @no_inline even further down the call chain.

Feels like primitve types in write shouldn't allocate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ioInvolving the I/O subsystem: libuv, read, write, etc.performanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions