Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: replace isValueType with faster alternative #1617

Merged
merged 1 commit into from
Mar 28, 2020
Merged

Conversation

paulpach
Copy link
Contributor

According to vis benchmark in #1614
isValueType is an expensive operation.

This micro-optimization replaces isValueType for a faster (not so readable) alternative

@sonarcloud
Copy link

sonarcloud bot commented Mar 28, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@miwarnec
Copy link
Collaborator

@paulpach why do we still need the check?
aren't all messages value types now?

@paulpach
Copy link
Contributor Author

paulpach commented Mar 28, 2020

All our messages are value type, but there is no guarantee/requirement that messages are value types. In fact our documentation teaches people to use classes because they happen to be more convenient. With classes you don't have to add an empty Serialize and Deserialize method.

This PR should fix the problem though

@miwarnec
Copy link
Collaborator

did you profile it already?

According to vis benchmark here #1614 (comment)
isValueType is an expensive operation.

This microoptimization replaces isValueType for a faster (not so readable) alternative
@paulpach
Copy link
Contributor Author

profiling, hang in there...

@paulpach
Copy link
Contributor Author

Before:
Screen Shot 2020-03-28 at 12 20 59 PM

After:
Screen Shot 2020-03-28 at 12 25 21 PM

@paulpach paulpach merged commit 61163ca into master Mar 28, 2020
@paulpach paulpach deleted the valuetype branch March 28, 2020 17:28
github-actions bot referenced this pull request in MirageNet/Mirage Mar 28, 2020
## [29.0.3](29.0.2-master...29.0.3-master) (2020-03-28)

### Performance Improvements

* faster NetworkWriter pooling ([#1616](https://github.com/MirrorNG/MirrorNG/issues/1616)) ([5128b12](5128b12)), closes [#1614](https://github.com/MirrorNG/MirrorNG/issues/1614)
* replace isValueType with faster alternative ([#1617](https://github.com/MirrorNG/MirrorNG/issues/1617)) ([61163ca](61163ca)), closes [/github.com/MirrorNetworking/Mirror/issues/1614#issuecomment-605443808](https://github.com//github.com/vis2k/Mirror/issues/1614/issues/issuecomment-605443808)
* use byte[] directly instead of MemoryStream ([#1618](https://github.com/MirrorNG/MirrorNG/issues/1618)) ([166b8c9](166b8c9))
github-actions bot referenced this pull request in MirageNet/Mirage Mar 28, 2020
According to vis benchmark here MirrorNetworking/Mirror#1614 (comment)
isValueType is an expensive operation.

This microoptimization replaces isValueType for a faster (not so readable) alternative
github-actions bot referenced this pull request in MirageNet/Mirage Mar 28, 2020
## [29.0.3](29.0.2-master...29.0.3-master) (2020-03-28)

### Performance Improvements

* faster NetworkWriter pooling ([#1616](https://github.com/MirrorNG/MirrorNG/issues/1616)) ([5128b12](5128b12)), closes [#1614](https://github.com/MirrorNG/MirrorNG/issues/1614)
* replace isValueType with faster alternative ([#1617](https://github.com/MirrorNG/MirrorNG/issues/1617)) ([61163ca](61163ca)), closes [/github.com/MirrorNetworking/Mirror/issues/1614#issuecomment-605443808](https://github.com//github.com/vis2k/Mirror/issues/1614/issues/issuecomment-605443808)
* use byte[] directly instead of MemoryStream ([#1618](https://github.com/MirrorNG/MirrorNG/issues/1618)) ([166b8c9](166b8c9))
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.

None yet

2 participants