Comments (5)
I've found something that might be causing hi-cpu load.
LibUA/NET/LibUA/NetDispatcherBase.cs
Lines 196 to 199 in df0ff42
The problem is, that when there is no data, it will directly continue the while loop. There is no sleep/wait event here. So it acks like a shortcircuit.
I just added a sleep(1) which brings the cpu usage down dramatically.
Any thoughts?
from libua.
This is my breakage, I didn't notice that it's caused high CPU.
What I should have probably done is do the ReadAsync() and a TimerAsync (driven by the NeedsPulse), await either.. check if the Read is complete, if it is, go and do the read stuff.. otherwise if the NeedsPulse is ready, go and do the timer stuff (then reset timer task.. or just set it as autoresetting) then go back to waiting for them..
But short term... you could just check out the previous revision 990a7ac
I'll try to fix this up in the next week or so.
from libua.
Reverted back to the previous version. Try the latest master and let us know if you still see high CPU usage.
from libua.
I also found some small points in the code, which are not quite nice in terms of code structure.
For example (stream as NetworkStream).DataAvailable
, now you can be sure that stream
is a NetworkStream
, but if this ever changes you will get a NullReferenceException
here. NullReferenceExceptions are generally seen as sloppiness.
It's better to do a hard cast here. ((NetworkStream)stream).DataAvailable
, if the stream is not NetworkStream
, you will get a InvalidCastException
which explains the error better.
Would you mind if I contributed something?
from libua.
Sure, feel free.
from libua.
Related Issues (20)
- How to read an ExtensionObject? HOT 6
- Error DefaultAddressSpace HOT 1
- TranslateBrowsePath does not mark the final BrowsePathTarget correctly HOT 2
- Exception in MemoryBufferExtension.cs with a Prosys OPCUA Server HOT 16
- Nullreference Exception in Client Sample HOT 1
- LingerState: Unhandled Exception - Invalid Argument HOT 1
- Method calls are not executed HOT 5
- EUInformation and Range HOT 4
- Switch to use ArrayPool in memorybuffer to reduce allocation pressure HOT 1
- Browsing S7 OPCUA Server, Outputs not returned (FunctionalGroupType?) HOT 7
- Missing ServiceResult returns of CheckServiceFaultResponse() in Client.cs HOT 1
- BadAttributeIdInvalid when browsing Server HOT 1
- Regarding client connection issues HOT 4
- Chunk messages are not created. HOT 7
- Thoughts on Unit Tests HOT 1
- TIMEOUT: get Server Status HOT 3
- How to subscribe to an ExtensionObject or nested value array HOT 10
- NodeVariables don't currently expose ArrayDimensions HOT 1
- Having trouble with Call method when method has Extension Object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libua.