Skip to content

DWG read repeatedly copies object memory stream, causing severe slowdown on larger files #2

Description

@Michaelliv

DwgObjectReader currently wraps _memoryStream with new Uint8Array(this._memoryStream) in the object-type/read path. Because _memoryStream is already a Uint8Array, this creates a full copy of the object stream each time.

On a 4.6MB AC1032 DWG, this made DwgReader.readFromStream() fail to complete after 180s and spend most sampled time in allocation/GC. Reusing the existing _memoryStream view made the same file parse in ~2.6s.

Measured locally:

readFileHeader: ~8ms
readHeader: ~5ms
readSummaryInfo: ~4ms
readPreview: ~2ms
read(): timed out after 180s before patch
read(): ~2661ms after patch

The fix is to pass this._memoryStream directly into DwgStreamReaderBase.getStreamHandler(...) instead of allocating a new Uint8Array copy for each reader.

I opened a PR with that change.

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