nyarly / sockjs-ruby

WebSocket emulation - Ruby server
http://sockjs.org
MIT License
28 stars 5 forks source link

More efficient FSM #9

Open nyarly opened 10 years ago

nyarly commented 10 years ago

I don't know that there's a simple fix for this but:

As I understand it, the current approach to the Session FSM clobbers the Ruby method cache on every state transition. I'd expect that performance of sockjs servers would therefore be much worse than ideal.

The best solution I can see would be to establish Session as a facade on a pair of objects: a stateless SessionRecord with all instance variables on it, and a SessionState with no internal state, but which acts on the SessionRecord. The result would unavoidably be that the states would be more complicated (since they'd need to be funnelling arguments to the @record object), but the state implementation would be simpler, and the over system would run faster.