BotStudio9
Game Optimizer
Featured

Game Boost Pro - Entity Tick Optimizer

70% fewer entity updates, 61% CPU saved. C++20 tick scheduler for FiveM, RedM, alt:V servers

Latency
sub-frame
Throughput
-61% CPU
Price
$1,200

About this bot

GameBoost Pro is a C++20 tick optimizer for entity-heavy game servers like FiveM, RedM, alt:V or any server with main loop and too many entities. It replaces update everything every frame with interest-managed tiering, per-frame budgeting and a closed-loop governor that holds your frame time under target as the map fills. Benchmark on 20k entities, 32 players saves 61 percent CPU time and avoids 70 percent entity updates. Includes scheduler.hpp for tiers and budgeting, governor.hpp for closed-loop controller, frame_clock.hpp for rolling times and percentiles, affinity.hpp for core pinning and priority, workload.hpp for reproducible world generator plus benchmark harness. Src is one cpp per header plus main.cpp, tests with 11 suites run by CTest. Builds as build/bs9_gameopt binary or libbs9_gameopt.so with -DBS9_SHARED=ON. Zero dependencies beyond C++20 compiler. Licensed to purchaser.

Code preview

first 100 lines of src/scheduler.cpp · C++20 · 14 files · 1,528 lines in the archive
src/scheduler.cppC++20
1#include "bs9/scheduler.hpp"
2
3#include <algorithm>
4#include <cmath>
5#include <limits>
6
7namespace bs9 {
8
9float distance_sq(const Vec3& a, const Vec3& b) noexcept {
10 const float dx = a.x - b.x;
11 const float dy = a.y - b.y;
12 const float dz = a.z - b.z;
13 return dx * dx + dy * dy + dz * dz;
14}
15
16const char* tier_name(Tier t) noexcept {
17 switch (t) {
18 case Tier::Hot:
19 return "hot";
20 case Tier::Warm:
21 return "warm";
22 case Tier::Cool:
23 return "cool";
24 case Tier::Cold:
25 return "cold";
26 case Tier::Frozen:
27 return "frozen";
28 default:
29 return "?";
30 }
31}
32
33void EntityScheduler::set_entities(std::vector<Entity> entities) {
34 entities_ = std::move(entities);
35
36 tiers_.assign(entities_.size(), Tier::Frozen);
37 next_due_.assign(entities_.size(), 0);
38 phase_.resize(entities_.size());
39
40 // A fixed per-entity phase offset is what keeps a 30-frame tier from
41 // updating all of its entities on the same frame.
42 for (std::size_t i = 0; i < entities_.size(); ++i) {
43 phase_[i] = static_cast<std::uint32_t>(entities_[i].id * 2654435761u >> 16);
44 }
45
46 deferred_.clear();
47 queued_.assign(entities_.size(), 0);
48 retier();
49
50 // Stagger the first update of every entity across its interval, otherwise
51 // the whole world comes due on frame 0 and again every `interval` frames.
52 for (std::size_t i = 0; i < entities_.size(); ++i) {
53 const std::uint32_t interval =
54 cfg_.intervals[static_cast<std::size_t>(tiers_[i])];
55 next_due_[i] = interval > 1 ? phase_[i] % interval : 0;
56 }
57}
58
59void EntityScheduler::set_players(std::vector<Vec3> players) {
60 players_ = std::move(players);
61}
62
63Tier EntityScheduler::classify(const Entity& e) const {
64 if (e.pinned || e.activity >= cfg_.activity_promote) return Tier::Hot;
65 if (players_.empty()) return Tier::Frozen;
66
67 float best = std::numeric_limits<float>::max();
68 for (const auto& p : players_) {
69 best = std::min(best, distance_sq(e.position, p));
70 }
71
72 // Activity shrinks the effective distance: a moving vehicle is treated as
73 // if it were closer than it is, so it does not go dormant mid-manoeuvre.
74 const float scale = 1.0f - 0.5f * std::clamp(e.activity, 0.f, 1.f);
75 const float d = std::sqrt(best) * scale;
76
77 if (d <= cfg_.hot_radius) return Tier::Hot;
78 if (d <= cfg_.warm_radius) return Tier::Warm;
79 if (d <= cfg_.cool_radius) return Tier::Cool;
80 if (d <= cfg_.cold_radius) return Tier::Cold;
81 return Tier::Frozen;
82}
83
84void EntityScheduler::retier() {
85 for (std::size_t i = 0; i < entities_.size(); ++i) {
86 const Tier before = tiers_[i];
87 const Tier now = classify(entities_[i]);
88 if (now == before) continue;
89 tiers_[i] = now;
90
91 if (now < before) {
92 // Promotion takes effect immediately — an entity that just became
93 // relevant must not wait out the rest of a 30-frame interval.
94 next_due_[i] = static_cast<std::uint32_t>(frame_);
95 } else {
96 // Demotion re-phases the entity so a whole cohort dropping to a slow
97 // tier together does not then come due together.
98 const std::uint32_t interval =
99 cfg_.intervals[static_cast<std::size_t>(now)];
100 next_due_[i] = static_cast<std::uint32_t>(

This is the real file from the archive you receive, with your listing's metadata already substituted.

What is in the archive

C++20 project — Game Optimizer

  • .gitignore
  • CMakeLists.txt
  • README.md
  • include/bs9/affinity.hpp
  • include/bs9/frame_clock.hpp
  • include/bs9/governor.hpp
  • include/bs9/scheduler.hpp
  • include/bs9/workload.hpp
  • src/affinity.cpp
  • src/governor.cpp
  • src/main.cpp
  • src/scheduler.cpp
  • src/workload.cpp
  • tests/test_opt.cpp
  • LICENSE.txt
  • bs9-manifest.json