facebookarchive / webscalesql-5.6

WebScaleSQL, Version 5.6, based upon the MySQL-5.6 community releases.
GNU General Public License v2.0
2.94k stars 356 forks source link

Binary MySQL protocol #9

Closed infusion closed 9 years ago

infusion commented 10 years ago

Hi,

when Ulf Wendel implemented mysqlnd in PHP 5.3, he published a simple patch for MySQL to make the server send the data typed. This experiment - unfortunately, he took it offline - resulted in a few % of bandwidth reduction, but more importantly in a lot of freed CPU cycles on both sides.

Wouldn't it be a good idea to bring this low hanging fruit into HHVM and MySQL/WebscaleSQL? It would be nice, if this thing would land in Percona Server and maybe the official MySQL tree as well.

Robert

P.S.: I posted this suggestion on the HHVM bug tracker already and was asked to file it here. https://github.com/facebook/hhvm/issues/3487

steaphan-fb-com commented 10 years ago

Interesting. @chipturner - what do you think about this notion?

chipturner commented 10 years ago

Without the patch to see for sure, I can only guess what it does, but I suspect it involved a protocol change. That kind of thing is a little tricky. We've explored the option and may pursue it in the future but we're generally hesitant to change the wire protocol for fear of diverging from upstream in incompatible ways. To us it is more interesting in the bandwidth reduction and a few other aspects rather than just the time parsing the data, but that can benefit as well. Prepared statements can also deliver a similar perf speedup in some cases but there are a few issues with using them reliably and we've avoided it in our production environments.

We hope to open source our async MySQL HHVM library soon, though, which uses native C++ code for most of the type handling and conversion, which doesn't show up in our profiles as a bottleneck.

infusion commented 10 years ago

As far as i remember, it didn't involve a protocol change, but the client sent a flag to be able to handle binary data. After all, it was quite hacky and more a proof of concept. Prepared statements can save bandwidth for the statements sent, but not for the received data. I'm really looking forward to see your async libmysqlclient coming out (more for the async part than the type handling)

Robert

chipturner commented 9 years ago

This is a relatively low priority project for us. Patches would be welcome, and we may revisit it someday, but as a task, this is too wishlist and not aligned to our roadmap to act on immediately.