-
-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatch has been refactored to be centralized in just one thread. Previously, each task was sent to the threads that were free, which could cause bottlenecks because they were stuck with mutexes, causing queues depending on how many threads the cpu had. small illustration of a possible problem: ![image](https://github.com/opentibiabr/canary/assets/2267386/9cfba304-c8aa-4590-9538-48edb95a972a) Apart from what was mentioned above,, the scheduling class has been removed and we now have new methods in dispatch, addEvent_async, scheduleEvent and cycleEvent. **Note** - addEvent_async(func, context_id) - With this method it is now possible to create an asynchronous event that will be executed before all synchronous events. **Questions** - Why Scoped Object - there is a big cost in allocating(new) and deallocating(delete) an object from memory and since we don't need to manage the lifetime of the object or share it, it doesn't make sense to use smart pointer. **Benchmark** - Scoped Object vs Smart Pointer ![image](https://github.com/opentibiabr/canary/assets/2267386/7c514967-2087-4d46-ad0b-19820a31e46a) <details> ```c++ struct Teste { int i; }; Benchmark bm; for (uint_fast32_t i = 0; i < 999; ++i) { std::vector<Teste> list; for (uint_fast32_t d = 0; d < 99999; ++d) { list.emplace_back(d); } list.clear(); } g_logger().info("Scoped Object {}ms", bm.duration()); bm.reset(); bm.start(); for (uint_fast32_t i = 0; i < 999; ++i) { std::vector<std::unique_ptr<Teste>> list; for (uint_fast32_t d = 0; d < 99999; ++d) { list.emplace_back(std::make_unique<Teste>(d)); } list.clear(); } g_logger().info("Smart Pointer {}ms", bm.duration()); ```</details> --------- Co-authored-by: Luan Santos <[email protected]> Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7ce2982
commit fb5f3ca
Showing
42 changed files
with
680 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.