Skip to content

Parser performance regression #6355

Closed
Closed
@dotdash

Description

@dotdash

I noticed that compiling libcore now takes about 26s instead of the 20s it used to take. perf revealed that a large amount of time is spent in the bump() method of the lexer. The offending line is:

        let next = str::char_range_at(*rdr.src, current_byte_offset);

With rdr being of type &mut StringReader and rdr.src being @~str. str::char_range_at expects a &str as its first argument.

What happens now is that the compiler generates code that copies the whole src string, which is obviously bad.

The copy is triggered by the rdr being mutable. Without the mut, the compiler doesn't generate a copy. A benchmark to demonstrate that behaviour can be found here: https://gist.github.com/dotdash/5546866

@nikomatsakis said he wants to look into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions