Skip to content

Mitigating No Ropes #1654

@swankjesse

Description

@swankjesse

I love QuickJS. The latest releases even have ropes, which means that code like this is faster than O(N*N):

var result = ""
for (i in 0 until 1000000) {
  result += "x"
}

Unfortunately, the release we’ve shipped to millions of our customers doesn’t have ropes, and that’s both caused real performance problems, and risks future performance problems.

We’ve worked around this problem elsewhere by avoiding StringBuilder. For example Json.encodeToStringFast uses JSON.stringify() to create its strings.

But there’s some places where it’s super awkward to work around this. For example, Wire’s ByteArrayProtoReader32 calls the stdlib’s ByteArray.decodeToString() function, and that thing uses a StringBuilder that runs super slowly on our QuickJS. Wire’s calling the right API here, and even the stdlib is also not unreasonable by assuming strings’ performance characteristics.

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