Skip to content

Avoids creating a new ErrorStream instance for each request#245

Merged
wch merged 1 commit into
rstudio:masterfrom
atheriel:static-errorstream
Oct 1, 2019
Merged

Avoids creating a new ErrorStream instance for each request#245
wch merged 1 commit into
rstudio:masterfrom
atheriel:static-errorstream

Conversation

@atheriel

@atheriel atheriel commented Sep 21, 2019

Copy link
Copy Markdown
Contributor

My apologies if I've misinterpreted something here, I don't really know how to "test" Rook-related functionality.

The Rook specification for the Error Stream seems to indicate only that it must have cat() and flush() methods. I noticed that the current R6 class implementation has no internal state to mutate, and yet a new instance is created for each request. This struck me as avoidable.

This PR simply creates a single instance that can be reused by all requests. The change should improve performance; my "hello, world" example is showing a 20% increase in throughput.

I did not add a note to the NEWS.md file, but my suggestion would be

> Avoid creating a new Rook error stream object for each request.

@wch

wch commented Sep 30, 2019

Copy link
Copy Markdown
Collaborator

Looks good! Can you add a NEWS item, in a new section for 1.5.2.9000?

The Rook specification indicates only that the `rook.errors` object must
have cat() and flush() methods, and since the current R6 class
implementation has no internal state to mutate, we can just use a single
shared instance for all requests.
@atheriel

Copy link
Copy Markdown
Contributor Author

I have added a NEWS item.

@wch wch merged commit 57e1d71 into rstudio:master Oct 1, 2019
@atheriel atheriel deleted the static-errorstream branch April 6, 2020 17:22
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.

2 participants