Skip to content

Commit

Permalink
Update README.md --skip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dueris authored Dec 27, 2024
1 parent 4114e49 commit 0189a7b
Showing 1 changed file with 26 additions and 103 deletions.
129 changes: 26 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,35 @@
<img src="readme_top.png">

<center><b style="font-size:29px">Fork of <a href="https://github.com/PurpurMC/Purpur">PurpurMC</a> adding multithreaded dimensions and more</b></center>
---

## Significant Optimizations
Canvas adds a ton of new optimizations to the game, including AI optimizations, farm optimizations, and large-scale threading optimizations
<center><b style="font-size:29px">Fork of <a href="https://github.com/PurpurMC/Purpur">PurpurMC</a> adding experimental, but heavy performance optimizations.</b></center>
<p></p>

### Multithreaded Dimension Ticking
Canvas' most significant optimization is Multithreaded
Dimension Ticking(MDT), which turns each world into its
own mini-server. NMS has a `BlockableEventLoop` class,
which acts as a scheduler for ticking repeated tasks on
a single thread. The main performance drawback of normal
servers are the fact that it ticks almost entirely on a
single thread. Folia attempts to fix this bottleneck by
threading the server in `regions`, which has caused
numerous issues like breaking plugin compatibility,
disabling numerous features and commands, and tons of
bugs and crashes. To fix this, Canvas attempts at making
the server combine work using multiple threads for
ticking 1 single server.

#### Threading Logic
The main thread tick loop has been stripped of most
logic having to do with World ticking, since each world
now is an extension of a `TickLoopThread`, which is an
abstract implementation of the NMS `BlockableEventLoop`
that handles most of the logic for ticking each world.

After startup, each world(including ones added by plugins
and datapacks) gets booted into its own thread to begin
ticking, and at that point each world ticks
independently and is completely split off from the main
thread, similar to Folias region logic, but instead of a
thread pool executing the ticks, it processes their own
tick on their own.
> [!IMPORTANT]
> CANVAS REQUIRES JAVA VERSION 22 TO RUN.
Upon a player joining the server, the main thread will
handle the joining logic like creating the player,
building the playerdata, etc. Once its ready for
"gameplay" stages(or the player is now in runtime), the
packet handler is sent to its currently owned world to
be processed, meaning each world will handle its own
players connections/disconnections. If the world is
crashing/lagging, the main thread will be used as
fallback until the world thread is stable again.
**Canvas is a project created by Dueris in an attempt to create a more powerful and original servertype, unlike most servertypes out there.**

In the end, this essentially makes each world its own
server, interacting with each other and working
concurrently to provide a huge boost in performance.
Some users have seen immense improvements in MSPT, and
even with hundreds of players, it can maintain 20TPS.
---

## Optimizations
### Multithreaded Dimension Ticking
Canvas' most significant optimization is Multithreaded Dimension Ticking(MDT). Made in a way to be more of an in-between of Paper and Folia, offering
insane levels of performance while still maintaining plugin compatiblity more(however not guarenteed), and making each world essentially its own
server with its own tick loop, making the main thread practically useless. This evenly distributes resources on the CPU to their respective worlds, offering
immense performance improvements. This also comes with a new `threadedtps` command, showing all the TPS of each world. Plugin-Made worlds also work with
MDT.
Alongside this, ServerPlayer Connection handling has been reworked to be threaded on the players respective world, meaning any players in the overworld are
handled and ticked on that thread, and same thing for each world and its players.
### Chunk Gen Optimizations
Canvas incorporates many optimizations from mods like C2ME to further improve the chunk generation performance of Canvas. Chunk performance has been
improved GREATLY, often doubling the CPS(Chunks Per Second) in comparison to Paper.
### Command Optimizations
Canvas also runs a few commands off-main, specifically ones that take up a ton of resources on the main thread, often pausing the server for seconds
at a time until they complete. These commands are the `locate` command, and the `spreadplayers` command.
### Entity Optimizations
There are numerous optimizations added by Canvas in
relation to entities, like the following:
- Async Pathfinding
- Experience Orb optimizations
- Entity Goal optimizations
- Entity Pathfinding optimizations

#### Entity Goal / Pathfinding optimizations
An odd part of Minecraft pathfinding is its nature to
continue attempting to pathfinding despite the entity
being in an enclosed space or crammed with other
entities, making it unable to move, despite the
pathfinder still trying to. This causes unnecessary
processing that takes up a lot of server resources fast
for mob farms like Enderman farms. To fix this, Canvas
pre-calculates the entities currently intersecting with
its bounding box, meaning if its crammed with a
configurable amount of entities(default 2, which means
its crammed with a lot of entities since normally
entities shouldnt be intersecting with each others
bounding boxes), the pathfinder will be turned off for
that tick, saving a lot of unneeded resources on mob farms.

Entity goals have also been optimized, reducing the
rates of strolling and extremely expensive mob goals by
a configurable amount to allow for less time spent on
goal ticking, while also making it still look natural.

#### Experience Orb optimizations
With giant XP farms, a lot of XP orbs are created and
get "merged" by spigots XP orb optimization. This
optimization works, but only to a specific degree. It
does "merge" the orbs, but it mostly just moves the orbs
to the same location and thats it, which doesnt do as
much in the long run. There is now a configuration that
allows for better merging of these orbs, allowing for
making the entity truly into a single entity with the
combined XP count of all the orbs. This reduces the
amount of entities processed on the server and client,
often times improving framerates in heavy mob farm
situations.

## FAQ

#### What kind of hardware is needed to run Canvas?
Generally, at least 3-4 more threads than you normally
would to account for the new WorldTicker threads.
Canvas implements a ton of more optimizations for entities, most notable async pathfinding, spawning improvements, threaded entity tracking, brain optimizations, and more.

#### Why not just use Folia?
Folia is more experimental software, and has a ton of
bugs. Canvas is more of an in-between of Paper and Folia,
bringing Folia-like optimizations but to a less severe
degree and reworked to be more plugin-compatible and
more performant. Plugin compatibility is a lot better
than Folia, just because of the nature of how the both
of them work. However, the plugin does have to be
thread-safe in most situations to be considered
compatible with Canvas.
---
These are just the more notable optimziations Canvas provides, but there are a TON more behind the scenes improving performance even more.
Please consider <a href="https://ko-fi.com/dueris">donating</a>! I(Dueris) have put tons of hours into this project to make it as stable and performant as possible.

0 comments on commit 0189a7b

Please sign in to comment.