Skip to content

Commit

Permalink
Improved performance by not cleaning pool every frame
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Oct 10, 2022
1 parent 0d9e81b commit 94d2d62
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ ImmediatelyFast is an open source Fabric mod which improves the immediate mode r

## Installation

The mod is requires the Fabric loader and is compatible with Minecraft 1.19 and higher.\
The mod is requires the Fabric loader and is compatible with Minecraft 1.19 and higher.

You can download the mod from [Modrinth](https://modrinth.com/mod/immediatelyfast)
or [Github Releases](https://github.com/RaphiMC/ImmediatelyFast/releases/latest).
or [Curseforge](https://www.curseforge.com/minecraft/mc-mods/immediatelyfast) or [Github Releases](https://github.com/RaphiMC/ImmediatelyFast/releases/latest).

## Optimizations

Expand All @@ -21,10 +22,10 @@ The following parts of the immediate mode rendering code are optimized:
### Performance

Generally FPS should be 2x higher on busy servers and might also be up to 4x higher in cases where there are many
entities.\
\
The following table shows the performance improvements of the mod.\
Tested on a server with 1000 entities in the visible view distance.\
entities.

The following table shows the performance improvements of the mod.
Tested on a server with 1000 entities in the visible view distance.
Test Hardware: Ryzen 5 1600, 32GB DDR4, GTX 1060

| Other mods | Without ImmediatelyFast | With ImmediatelyFast |
Expand All @@ -34,12 +35,13 @@ Test Hardware: Ryzen 5 1600, 32GB DDR4, GTX 1060

## Compatibility

The mod should work fine with almost all mods.\
The mod should work fine with almost all mods.
Known incompatibilities:

- Optifabric

Iris is supported but defeats some of the mods optimizations, as it replaces the Entity rendering engine with its own one.\
Iris is supported but defeats some of the mods optimizations, as it replaces the Entity rendering engine with its own one.

If you encounter any issues, please report them on
the [issue tracker](https://github.com/RaphiMC/ImmediatelyFast/issues) or feel free to join
my [Discord](https://discord.gg/dCzT9XHEWu).
my [Discord](https://discord.gg/dCzT9XHEWu).
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties | check these on https://fabricmc.net/versions.html
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.18
yarn_mappings=1.19.2+build.20
loader_version=0.14.9

# Mod Properties
mod_version = 1.0.1
mod_version = 1.0.2
maven_group = net.raphimc
archives_base_name = ImmediatelyFast
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@
public class BufferBuilderPool {

public static final int MAX_SIZE = 4096;

private static final Set<Pair<BufferBuilder, Long>> POOL = new HashSet<>();

private static long lastCleanup = 0;

private BufferBuilderPool() {
}

public static BufferBuilder get() {
cleanup();
if (lastCleanup < System.currentTimeMillis() - 5_000) {
lastCleanup = System.currentTimeMillis();
cleanup();
}

for (Pair<BufferBuilder, Long> entry : POOL) {
final BufferBuilder bufferBuilder = entry.getKey();
if (!bufferBuilder.isBuilding()) {
if (!bufferBuilder.isBuilding() && !((IBufferBuilder) bufferBuilder).isReleased()) {
entry.setValue(System.currentTimeMillis());
return bufferBuilder;
}
Expand Down

0 comments on commit 94d2d62

Please sign in to comment.