Repository navigation
add move semantic like esp-dash - #134
mathieucarbou wants to merge 4 commits into
Conversation
|
This PR is marked as stale because it has been open 45 days with no activity. You can remove stale label or comment if this PR is still valid. |
Point readers who are building a full product at SOFTT's engineering services, with a banner and a free engineering review link (UTM-tagged).
…ring-readme docs: add SOFTT Engineering section to README
|
@mathieucarbou v2 is going to be deprecated in this week. Check v3 branch and see if it holds in your application. |
I've already looked at #137 and checked the code. I won't switch to the new version. I think you missed the whole point of the WSL_HIGH_PERF flag in this PR. ESPAsyncWS already maintains a WS message queue per client. This message queue is ordered and also delivery is done as fast as possible within the client pcb buffer (there is already a lwip buffer per client under the hood). The whole point of WSL_HIGH_PERF was to bypass any application buffering in Webserial in order to deliver messages as fast as possible to the WS layer without any extra memory allocation. The idea behind the WSL_HIGH_PERF flag is obvious: let the user's responsibility to write complete lines.. This gives the user code the responsibility to correctly send whole lines (/n) that the lib can stream. And IMO this is not a big constrain because most of users app are streaming lines anymore to Webserial (commands and answers). And those who cannot or use vprintf or things like that could either buffer on their side or buffer with the little option that was included in WSL_HIGH_PERF to handle the vprintf grouping. Here is an example on how to use So the complexity introduced by the logstream class and its buffering per client is unnecessary complex and slower. I know you are trying to simplify user's life by allowing them to log in WebSerial character by character, by overcoming any bad and wrong use of the lib. And this is partly caused by the fact that WebSerial is implementing Print class. That's where the problem is. With the WSL_HIGH_PERF option, it is like we don't need to extend Print and the contract could even be removed. Only a To join both needs, I don't think the design of the PR is right. I think a cleaner design would have been to remove Then, provide another class that is a wrapper, for users who need that: class WebSerialAdapter: public Print {
explicit WebSerialAdapter(WebSerialClass& delegate);
}This is a breaking API change but only at 1 line: when users construct theit WebSerial, for those who really need the Print api they would do: And use the adapter instead of the direct WebSerial class. The adapter would be responsible to consolidate all the vprintf mess and then send it to WebSerial, eventually doing something else. update: Here are some memory impact examples:
This is huge! Note: I saw also that wsl_stream is also providing other features but like application level ACK, reconnect, etc but these have to be handled IMO elsewhere. WS spec already has a ping/pong facility that can be used and ACK also can be checked by looking at the return of the send methods of AsyncWS. |
|
@mathieucarbou Okay but I won't be continuing to support WSL_HIGH_PERF mechanism from v3, it adds a lot of user friction & confusion. Also I believe the buffering logic should be independent from whatever WebSocket server we implement in WebSerial in the future rather than creating AsyncWebServer a hard dependency. |
That’s not what I asked ;-) You can perfectly move all the buffering logic outside of the WebSerial class in an adapter which extends Print (see proposed design). The new version of the library will impact heavily ALL projects whatever they use which is bad, instead of working in a better design to allow people to have an implementation closer to what they need and use. The memory impact is huge! Web console is mostly an accessory tool for most projects so if the price to integrate it is heavy people will just look at lighter alternatives I think or just spawn their AI tool to create something similar without the memory cost penalty. AI changing how you should think about the value of the project : value is not anymore in the UI but whether you can provide what the user is searching for so that they won’t need to spend tokens replicating the web serial UI. With such high memory cost from a lib, only people using it for small use cases will use it as-is, but for bigger projects pretty sure people will look at crafting their own alternative because they need to save memory and processing for their app. Side-note: esp-dash right now as no console widget but I would definitely drop webserial and create a new esp-dash component to stream server logs instead in one of my project (YaSolR). This would just be a component focused on esp-log streaming though. |
|
I do agree the memory footprint being a bit bigger; though constrained users can optimize that by lowering the ring buffer to 4KB instead of 8KB ( I still think the ring buffer is the right approach for a log streamer, for a few reasons:
Regarding people making something own with AI, that's really about everyone's own opinion about the library, nothing I can do to change that. |
Is
this means some memory is kept on MCU for this history. And some users don't care about the history. Why would you force a behaviour that impacts memory for users that don't care about history ? When you connect your USB cable to the MCU, does your ESP sends you back the whole history or part of it kept in memory ? No...
No: this is happened because you were not checking the return status of the send method. WebSerial was silently discarding. But not AsyncWS ;-) And the asyncws queue is only if the network is heavily used: in theory, if messages are sent at a rate where they can be consumed (at least), then the queue won't grow. If you replace the queue by a ring buffer, what will happen ? Messages will be lost the same way. Whatever the implementation, discarding only happens if the producer produces more than what the "consumer" (lwip client buffer) can send and ack. And if it happens, this is to prevent from a memory crash or a dead-lock. I saw that you are blocking in the code... This is dangerous... Some core arduino operations should never be blocked (WiFi, BLE,etc). The loop should never be blocked, especially on a single core MCU.
That's wrong. If used accordingly as explained in my 1st comment (by sending a whole line) - not chars or vprintf, then there is no unnecessary heap allocation except for the WS buffer that is owned by asyncws lib. I specifically did this flag in order to keep a minimal cpu and memory footprint and directly send the data to the WS layer without any intermediary buffer. The |

No description provided.