Details
-
Task
-
Resolution: Done
-
P2: Important
-
None
-
1c7c277bf1 (qt/qtdeclarative/dev) 1c7c277bf1 (qt/tqtc-qtdeclarative/dev) e47a6cf215 (qt/qtdeclarative/6.4) e47a6cf215 (qt/tqtc-qtdeclarative/6.4)
Description
StdinReader::run() (qmllanguageservertool.cpp) just uses readSome, which might read nothing (and on several platforms that is what it does), and so we read a single character, and then sends it via signal to another thread.
This is rather expensive, we should read larger chunks to be more efficient, but we should never wait for more data if a full message was already read (to avoid deadlocks).
In the qtlanguageserver module QHttpMessageStreamParser does parse chunks, and calls a callback with the messages, and is set up in the QLanguageServerJsonRpcTransport constructor (see the initialization of m_messageStreamParser).
A stupid but effective solution is to set up a QHttpMessageStreamParser in StdinReader::run(), collect all the read data in a single QByteArray, appending at the end, and in all callbacks of it send the collected data.
This is a bit wasteful because the QHttpMessageStreamParser keeps a. copy of the sent message.
It can be improved in two ways (in qtlanguageserver):
- allow the FSM in QHttpMessageStreamParser to be used without keeping any buffers
- change QLanguageServerJsonRpcTransport (or create another class), so that it receives directly the errors/headers/fullMessages, and connect those via signals to the QHttpMessageStreamParser in StdinReader::run.