Asynchronous Tick Loop
See original GitHub issueWhat Something that I think would be greatly appreciated would be an asynchronous version of the tick loop function.
How Instead of the loop function being synchronous we could define it as async loop()
. We could have events, promises, etc and we can simply use await Promise.all(promises)
at the end of our code to allow for efficient multitasking in our code.
Why I think that this would greatly improve the performance capabilities of some scripts if implemented properly and would reduce server strain.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
The Node.js Event Loop, Timers, and process.nextTick()
You may have noticed that process.nextTick() was not displayed in the diagram, even though it's a part of the asynchronous API. This is...
Read more >Synchronously asynchronous | Kikobeats
By synchronous we mean a function that calls its callback on the same tick in the javascript event loop and asynchronous is called...
Read more >The Tick Loop | spark docs
The Tick Loop · Process incoming packets from players (e.g. movement, place/break blocks, attacking other entities) · Updating the position of players and...
Read more >What exactly is a Node.js event loop tick? - Stack Overflow
This is a tick: the synchronous invocation of zero or more callback functions associated with any external events. Once the queue is emptied ......
Read more >How JavaScript works: Event loop and the rise of Async ...
Such an iteration is called a tick in the Event Loop. Each event is just a function callback. Let's “execute” this code and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The performance benefits of Promises is that they allow you to handle thousands of I/O connections efficiently. For example, a web server might have millions of sockets running at the same time. Or you might be reading from thousands of files simultaneously. Promises can handle that very well, because the I/O operations are happening in the background.
But if you’re not doing I/O things… if it’s just synchronously updating some game state, then Promises will make your code slower, because Promises are slower than synchronous functions.
As said above, using async in code can not provide any benefit due to synchronous game API, and, more importantly, because server runs game scripts on a single dedicated core.