Follow your suggestion, I write the "C" native Mask library for websocket module on Espruino.
On Esp32 module, I test the library for some times.
Without Mask-lib, It takes about 64 seconds to transfer 23KB data to a websocket server.
By using Mask-lib, It takes about 1.68 second to do the same work.
Mask-lib can improve the performance of 'ws' about 40 times.