Skip to content

Use buffers in filesystem read APIs #2707

@TheBlueMatt

Description

@TheBlueMatt

After handling #2706 locally, 44% of my allocations locally are from path building when using the MonitorUpdatingPersister! That's obviously nuts, and luckily we can cut this down with careful buffer management:

  • MonitorName has an obvious maximum size, so should be a fixed length buffer with a length field.
  • Similarly, we realloc a ton when building paths with the PathBuf abstraction. Because they're super short, we should be storing them on the stack in constant-size buffers, though sadly its a bit more involved because on Unix its all bytes and on Windows its all u16s. IMO we should just use with_capacity on Windows, but on Unix we should use fixed-length buffers and make it a path with https://doc.rust-lang.org/std/os/unix/ffi/trait.OsStrExt.html#tymethod.from_bytes (internet claims max path len is only 4096 bytes, so this should be easy).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions