Comments (5)
It's QPS is 192K, throughput is 750Mb/s. I'd like to update it into my data sheet.
I'm not an expert here, please correct me if I'm wrong. So typescript is the project name and nodejs is the language? And what is its concurrency modle ? Coroutine ? Async callback ?
from photonlibos.
Sure, Node.js is a runtime which uses Chrome V8 engine to allow JavaScript to execute on server.
It provides API's for interacting with network/filesystem etc.
TypeScript is a type-system for JavaScript -- it gets removed at runtime, and compiled into JavaScript.
TypeScript code (with types) --> transpile --> JavaScript code --> Node.js runs JS code --> executes on V8 C++ engine
- https://github.com/nodejs/node
Node.js is an open-source, cross-platform JavaScript runtime environment.
- https://v8.dev/
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js,
- https://github.com/microsoft/TypeScript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
I mostly use TypeScript as it makes the code easier to read/maintain,
It has no performance impact and disappears after compiling
And what is its concurrency modle ? Coroutine ? Async callback ?
It is async callback, the low-level net
package in Node.js has event-listeners which fire callback functions when operations happen like data received
, socket opened
, connection acquired
etc.
The server code is tiny, it just echos back out what it received:
function server() {
const server = net.createServer()
server.on("connection", (socket) => {
socket.on("data", (data) => {
console.count("server received ops")
socket.write(data)
})
})
server.listen(flags.PORT, flags.IP, () => {
console.log(`server listening on ${flags.IP}:${flags.PORT}`)
})
}
And then the callbacks are registered when the ClientSocket
class is created here:
(I made some notes in comments below, for instance right now a static buffer is allocated, I'm not sure if this is supposed to be re-allocated every time)
class ClientSocket {
// Should this be re-allocated every operation?
// If so, this needs to be removed, see <---- down below
private static buf: Buffer = Buffer.alloc(flags.BUF_SIZE)
constructor() {
this.socket = new net.Socket()
this.sentOpsTotal = 0
this.receivedOpsTotal = 0
this.sentBytesTotal = 0
this.receivedBytesTotal = 0
this.lastOpStartTime = performance.timeOrigin
}
// Handlers for what should happen when data is received are registered as callbacks here
async connect() {
return new Promise((resolve, reject) => {
this.socket.connect(flags.PORT, flags.IP, () => {
resolve(this)
})
this.socket.on("data", (data) => {
this.receivedOpsTotal++
this.receivedBytesTotal += data.length
// this.socket.write(Buffer.alloc(flags.BUF_SIZE)) <------
this.socket.write(ClientSocket.buf)
this.sentOpsTotal++
this.sentBytesTotal += data.length
this.lastOpStartTime = performance.now()
})
this.socket.on("error", (err) => {
reject(err)
})
})
}
}
from photonlibos.
I was using my own client to test against your server, in order to reduce variables.
from photonlibos.
Oh LOL, that makes a more sense doesn't it?
You may want to try commenting out this line
console.count("server received ops")
And see if it makes any difference btw
from photonlibos.
Closed for #97
from photonlibos.
Related Issues (20)
- use jemalloc as memory pool HOT 2
- Macos构建失败 HOT 2
- Compare with seastar ? HOT 2
- update benchmark result(asyncio) HOT 5
- Purpose of asymmetric_spinLock HOT 6
- 协程栈分配优化问题 HOT 2
- photon stack 有支持spdk的blobfs计划吗 HOT 4
- How to implement streaming client that terminates after data transfer completion HOT 3
- Creating and joining a number of threads only known at runtime HOT 22
- IOURING and EchoServer fails : free() Invalid Pointer HOT 18
- Repeated Timer and async_run HOT 5
- IO_Uring send: Broken pipe HOT 7
- More examples / documentation on Photon Filesystem HOT 3
- Phonton Threads NOT working HOT 14
- PhotonLib crashes with other thread models HOT 4
- Photon Threads Affinity HOT 13
- question: Can it be compiled and run on centos7 HOT 8
- About tuple_assitance::callable HOT 2
- Suggestion: Uniform code style HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from photonlibos.