Skip to content

Optimize writes to Array such that they don't read and drop existing values if this isn't necessary #928

@yorickpeterse

Description

@yorickpeterse

Description

When writing to an Array using methods such as Array.set, we read the existing value and drop it before the write. For types that are copy (e.g. Int) this is redundant and a waste of CPU time.

We should optimize this such that for copy types we don't perform a read, instead just overwriting the data as-is. Ideally this is implemented in a generic way that works for other types as well. This probably means we need to look for reads of Pointer[T] values where T: copy, then remove such reads if their result isn't passed around. This in turn may depend on some form of lifetime/escape analysis that we'd likely also need for #776

Related work

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerChanges related to the compilerperformanceChanges related to improving performance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions