question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Asynchronous Tick Loop

See original GitHub issue

What 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Pauancommented, Oct 8, 2022

@Hexcede Truthfully, I’ve never fully understood how the performance benefit of promises is meant to come into play

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.

1reaction
o4kapukcommented, Sep 25, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found