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

ofxLibwebsockets::Server::threadedFunction needs to chill (sleep) #84

Open
ofZach opened this issue Mar 25, 2016 · 3 comments
Open

ofxLibwebsockets::Server::threadedFunction needs to chill (sleep) #84

ofZach opened this issue Mar 25, 2016 · 3 comments

Comments

@ofZach
Copy link

ofZach commented Mar 25, 2016

in a multi-threaded context ofxLibwebsockets::Server is pretty aggressive since it doesn't have any sleeping going on (as far as I can see). I don't know the best solution, but in profiling in a project that involves lots of pieces I found I was spending alot of time in this function. adding a tiny sleep helps a ton, but if the sleep is too long you can also get lags on sending.

just thought I'd point out that it seems a bit agressive.

@robotconscience
Copy link
Owner

Hey Zach! Sounds totally reasonable. I was just wrestling with a similar issue (#82 I think?) and it helped to tweak lws' waitMillis as well. (Last PR exposed the ability to do so)

Do you think a sleep or yield() would be better? I'll experiment with both once I'm back on my comp.

@ofZach
Copy link
Author

ofZach commented Mar 26, 2016

I'm not sure what is better! to make things lighter on myself I wound up implementing something using node / socket.io and node osc (via this https://github.com/automata/osc-web but with some mods for https) which seems snappy for what I needed to do but feels a little less rigid than if I am running it in OF (ie, now there's three pieces / OF / node / browser instead of two) but overall feels like it's doing the right thing in terms of being friendly thead wise.

when I have some more time I'll try to do more testing!

@robotconscience
Copy link
Owner

All good! I added yield() to both; that + the waitMillis fix from @natxopedreira make it definitely chill more. Let me know if you end up testing further, will do some more experiments on my end as well.

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

No branches or pull requests

2 participants