runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 128 forks source link

[WIP] TCP sockets implementation #41

Closed iefserge closed 9 years ago

iefserge commented 9 years ago

Pure javascript TCP protocol implementation for runtime.js. Work in progress.

Interface should be similar to Firefox OS's (full compatibility would be ideal, but might be hard to achieve while maintaining the best performance) : https://developer.mozilla.org/en-US/docs/Web/API/TCPSocket https://developer.mozilla.org/en-US/docs/Web/API/TCPServerSocket

Design goals:

Edit:

kesla commented 9 years ago

BOOM!

heapwolf commented 9 years ago

Very awesome!!!

iefserge commented 9 years ago

HTTP server built on this passes AB

$ ab -c 1 -n 100 http://127.0.0.1:9000/
Server Software:
Server Hostname:        127.0.0.1
Server Port:            9000

Document Path:          /
Document Length:        38 bytes

Concurrency Level:      1
Time taken for tests:   0.604 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      12100 bytes
HTML transferred:       3800 bytes
Requests per second:    165.66 [#/sec] (mean)
Time per request:       6.036 [ms] (mean)
Time per request:       6.036 [ms] (mean, across all concurrent requests)
Transfer rate:          19.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     3    6  13.3      4     113
Waiting:        2    5  13.3      3     113
Total:          3    6  13.3      4     113

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      4
  80%      5
  90%      6
  95%      8
  98%     80
  99%    113
 100%    113 (longest request)
iefserge commented 9 years ago

Got a ton of deopts though, not sure how to optimize https://gist.github.com/iefserge/8eaf108e51cc46f59d94

kesla commented 9 years ago

@iefserge Would be really cool if you could listen to the port 0 and get an unused port - as you can do i node.js - right now that just doesn't work you get an E_INVALID_PORT

iefserge commented 9 years ago

Merging this into libos, will continue work there or in separate PRs.