5 ms·
And now to get ranty: Boltdb was being handled badly: https://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/ch
by Vendan 9y ago
And now to get ranty:
Boltdb was being handled badly: https://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/chat_log_store.go#L49 https://github.com/maxpert/raspchat/blob/79315d861968c126670... You should be using bolt's helper funcs, so you don't forget to close the transaction
https://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/chat_log_store.go#L74 https://github.com/maxpert/raspchat/blob/79315d861968c126670...
At least this is actually deferred, but still.
https://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/messages.go https://github.com/maxpert/raspchat/blob/79315d861968c126670... These messages are horrifying, would be much better switching back to json and implementing a strategy like http://eagain.net/articles/go-dynamic-json/ http://eagain.net/articles/go-dynamic-json/
It copies in an unlicensed "snowflake generation" thing? https://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/snowflake.go https://github.com/maxpert/raspchat/blob/79315d861968c126670... and then essentially relicenses it? That's illegal...?
They do have a better json pattern for some stuff: https://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/transport_json_decoder.go https://github.com/maxpert/raspchat/blob/79315d861968c126670... but I'd still steer away from reflection based, there's so much better ways of doing this stuff, like so: http://eagain.net/articles/go-json-kind/ http://eagain.net/articles/go-json-kind/
- dullgiulio 9y agohttps://github.com/maxpert/raspchat/blob/79315d861968c1266701d07cb11d1db2fb95f47c/src/sibte.so/rascore/snowflake.go#L83 https://github.com/maxpert/raspchat/blob/79315d861968c126670... This is a spinner?! No wonders the code is slow. The general use of inheritance and very non-idiomatic code makes me think this is another person who ditched Go before understanding any of it. It seems a very popular sport.
- jimsmart 9y agoAs the time-old adage goes "a bad workman blames his tools".
- koffiezet 9y agoAnd if you look where that code is called from - wrapped inside a mutex... And then people wonder why it eats up 100% CPU and are completely maxed out before reaching 1000 requests/sec... Yup... Bad slow language!
- KirinDave 9y agoIllegal relicensing aside, this entire kerfuffle still makes anbad case for Golang. If it's THAT much easier to make a more efficient server with a fully dynamic language using just coroutines then why should anyone ever use Go in this case? Saying, "this implementation is bad" might work in another comparison, but given how much of Golang's implementation and engineering philosophy has been driven by an argument of "simplicity" it seems like we keep seeing precious few returns.
- Vendan 9y agoNo. There was a lot of effort put into things that make no sense in the go version, including using a concurrent, lockfree, snapshot iterating hash array, where they'd most likely have better performance in this case with a map and a mutex. This was NOT simple. The node.js version is simple. The Go version is overblown in complexity and abusing the language. Rewrite the go version using just as simple of structures, and using a sqlite, and I'm extremely confident that it'd be more performant.
- KirinDave 9y agoOn the data structure: arguing for locked mutation is pretty an tricky because at low volumes it'll be faster and at higher traffic volumes it will be slower. And since it's a library, who cares? Golang isn't a language that's old enough to have accumulated a ton dissonance about the "right" way to do things. Golang encourages that kind of code and you see it all over GitHub. Too bad it's something of a trap.