alphacep / alphacep/vosk-api

VoskJS HTTPServer crash (v8::internal::GlobalBackingStoreRegistry::Register)

Abierto
#516 16 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
15.1k
Forks
1.8k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi Nicolay!

I'm working on VoskJs, a simple wrapper of nodejs Vosk binding, and I'm now released an HTTP server using last multi-threading features part of Vosk API. See: https://github.com/solyarisoftware/voskJs/blob/master/voskjs.js#L121

The draft HTTP server I implemented is very simple: it just takes HTTP POST /transcript requests, processing the speech file specified in the request body: https://github.com/solyarisoftware/voskJs/tree/master/examples#transcript-http-server

I want to stress test httpServer.js to monitor throughput and latencies, using an Apache Bench (ab) script:
https://github.com/solyarisoftware/voskJs/blob/master/tests/abtest.sh

Running the ab stress test, with by example 2 concurrent requests (for 500 times), the server run smoothly for a while (100/200 requests), consuming almost 2 cores (see pidstat logs here listed), but the server crashes after a while. See here below the stderr messages. BTW, rising the number of concurrent requests, the server crashes in a minor time.

Reading error:
```
3: 0x100c201 v8::internal::GlobalBackingStoreRegistry::Register(std::shared_ptr) [node]
```

It seems to me that the issue could maybe related to some memory node binding problem.

Any idea?
Please let me know if you need more info.

Thanks
Giorgio

---

**httpServer stderr**

```bash
$ pidstat 1 -u -e node httpServer > httpServer.log

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0x7ffcaa9487e0
1: 0xb7db41 [node]
2: 0x1c15474 V8_Fatal(char const*, ...) [node]
3: 0x100c201 v8::internal::GlobalBackingStoreRegistry::Register(std::shared_ptr) [node]
4: 0xd23818 v8::ArrayBuffer::GetBackingStore() [node]
5: 0xacb640 napi_get_typedarray_info [node]
6: 0x7fb14c3a10ff [/home/giorgio/voskjs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
7: 0x7fb14c3a18a8 [/home/giorgio/voskjs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
8: 0x7fb14c3a3591 [/home/giorgio/voskjs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
9: 0x7fb14c3a9d6b Napi::details::CallbackData::Wrapper(napi_env__*, napi_callback_info__*) [/home/giorgio/voskjs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
10: 0xac220f [node]
11: 0xd5f70b [node]
12: 0xd60bac [node]
13: 0xd61226 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
14: 0x160c579 [node]
```

**Apache Bench test**

```bash
$ com/abtest.sh

test httpServer using apache bench
2 concurrent clients
500 requests to run

full ab command
ab -p /home/giorgio/voskjs/examples/com/body.json -T application/json -H 'Content-Type: application/json' -c 2 -n 500 -l -k -r http://localhost:3000/transcript

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests

Server Software:
Server Hostname: localhost
Server Port: 3000

Document Path: /transcript
Document Length: Variable

Concurrency Level: 2
Time taken for tests: 27.141 seconds
Complete requests: 500
Failed requests: 660
(Connect: 0, Receive: 440, Length: 0, Exceptions: 220)
Keep-Alive requests: 0
Total transferred: 24973 bytes
Total body sent: 17080
HTML transferred: 18660 bytes
Requests per second: 18.42 [#/sec] (mean)
Time per request: 108.563 [ms] (mean)
Time per request: 54.282 [ms] (mean, across all concurrent requests)
Transfer rate: 0.90 [Kbytes/sec] received
0.61 kb/s sent
1.51 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 107 296.6 0 1214
Waiting: 0 103 288.8 0 1213
Total: 0 107 296.6 0 1214

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 739
95% 981
98% 1094
99% 1174
100% 1214 (longest request)
```

**httpServer.log** (excerpt)

```bash

Linux 5.8.0-50-generic (giorgio-HP-Laptop-17-by1xxx) 30/04/2021 _x86_64_ (8 CPU)
1619767436135 Press Ctrl-C to shutdown
1619767436136 Model directory: ../models/vosk-model-small-en-us-0.15
1619767436413 load model latency: 275ms
1619767436415 Server httpServer.js running at http://localhost:3000
1619767436415 Endpoint http://localhost:3000/transcript

09:23:55 UID PID %usr %system %guest %wait %CPU CPU Command
09:23:56 1000 45074 46,00 10,00 0,00 0,00 56,00 7 node
09:23:57 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:23:58 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:23:59 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:24:00 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:24:01 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:24:02 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:24:03 1000 45074 0,00 0,00 0,00 0,00 0,00 7 node
09:24:04 1000 45074 2,00 0,00 0,00 0,00 2,00 7 node
1619767445908 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

09:24:05 1000 45074 8,00 0,00 0,00 0,00 8,00 7 node
1619767446466 id 1619767445908 transcript latency 558ms
1619767446466 response id 1619767445908 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767445908,"latency":558,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767446470 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

1619767446526 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

09:24:06 1000 45074 139,00 2,00 0,00 0,00 141,00 7 node
1619767447189 id 1619767446470 transcript latency 719ms
1619767447189 response id 1619767446470 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767446470,"latency":719,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767447232 id 1619767446526 transcript latency 706ms
1619767447232 response id 1619767446526 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767446526,"latency":706,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767447233 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

1619767447288 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

1619767447954 id 1619767447288 transcript latency 666ms
1619767447954 response id 1619767447288 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767447288,"latency":666,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
09:24:07 1000 45074 176,00 0,00 0,00 0,00 176,00 7 node

1619767469520 id 1619767468466 transcript latency 1054ms
1619767469520 response id 1619767468466 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767468466,"latency":1054,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767469522 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

09:24:29 1000 45074 171,00 1,00 0,00 0,00 172,00 7 node
1619767470485 id 1619767469373 transcript latency 1111ms
1619767470485 response id 1619767469373 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767469373,"latency":1111,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767470546 id 1619767469522 transcript latency 1024ms
1619767470546 response id 1619767469522 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767469522,"latency":1024,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767470548 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

1619767470635 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

09:24:30 1000 45074 174,00 0,00 0,00 0,00 174,00 7 node
1619767471542 id 1619767470635 transcript latency 906ms
1619767471542 response id 1619767470635 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767470635,"latency":906,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767471601 id 1619767470548 transcript latency 1053ms
1619767471601 response id 1619767470548 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767470548,"latency":1053,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767471604 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

1619767471694 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

09:24:31 1000 45074 173,00 0,00 0,00 0,00 173,00 7 node
1619767472611 id 1619767471604 transcript latency 1007ms
1619767472611 response id 1619767471604 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767471604,"latency":1007,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767472672 id 1619767471694 transcript latency 978ms
1619767472672 response id 1619767471694 {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2","requestId":1619767471694,"latency":978,"result":[{"conf":1,"end":1.02,"start":0.36,"word":"experience"},{"conf":1,"end":1.35,"start":1.02,"word":"proves"},{"conf":1,"end":1.74,"start":1.35,"word":"this"}],"text":"experience proves this"}
1619767472674 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

1619767472764 request {"speech":"../audio/2830-3980-0043.wav","model":"vosk-model-en-us-aspire-0.2"}

09:24:32 1000 45074 149,00 1,00 0,00 0,00 150,00 0 node

Average: 1000 45074 127,76 0,73 0,00 0,00 128,49 - node

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.