Skip to content

Avoid copying DWG object memory stream#3

Open
Michaelliv wants to merge 1 commit into
node-projects:masterfrom
Michaelliv:avoid-dwg-object-buffer-copies
Open

Avoid copying DWG object memory stream#3
Michaelliv wants to merge 1 commit into
node-projects:masterfrom
Michaelliv:avoid-dwg-object-buffer-copies

Conversation

@Michaelliv
Copy link
Copy Markdown

This avoids repeated full-buffer copies while reading DWG objects.

DwgObjectReader stores _memoryStream as a Uint8Array, but several hot-path calls passed new Uint8Array(this._memoryStream) to DwgStreamReaderBase.getStreamHandler(...). That creates a copy of the full object stream every time object metadata is read.

On a 4.6MB AC1032 DWG, this caused DwgReader.readFromStream() to time out after 180s locally with heavy allocation/GC. Passing the existing _memoryStream view directly reduced the same read to ~2.6s.

Validation:

npm run build
npm test

Fixes #2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant