Commit graph

4714 Commits

Autor SHA1 Nachricht Datum
Aikar
7e1525ea2d
Many improvements to chunk prioritization and bug fixes
Fixed a few bugs, and made numerous improvements.
Fixed issue where a sync chunk load could have its ticket removed and the
priority ticket could expire...
Still not perfect there but better than before.

Also fixed few other misc issues such as watchdog cpu usage, chunk queue update
had risk of double enqueue due to it no longer being a set.

Added much more information about chunk state to watchdog prints.

I see some more room for improvement even, but this is much better than before.

Fixes #3407
Fixes #3411
Fixes #3395
Fixes #3389
2020-05-20 05:13:01 -04:00
Aikar
c82b292ab0
Fix pooled buffer leak resulting in dynmap black spots - Fixes #3386
Dynmap accessed the raw bytes because it utilized NBT locally, but the
NBTTagcompound was garbage collected while the bytes were still being used.

This will return getBytes() back to being safe, and add a new PoolSafe method
that will prevent the additional allocations for general chunk loading.

Also fixed applyPatches for people with paths in their working directory
if they have mcdev sources built.
2020-05-20 00:55:30 -04:00
stonar96
6327447259
Fix ./paper edit continue for Windows 2020-05-19 23:14:34 -04:00
stonar96
eb5a3058dd
Fix path in CONTRIBUTING.md (#3406) 2020-05-19 23:08:37 -04:00
syeyoung
f6ed326dc1
Fix a small error in CONTRIBUTING.md (#3403) 2020-05-19 23:07:34 -04:00
Aikar
614a664bd3
Implement Chunk Priority / Urgency System for Chunks
Mark chunks that are blocking main thread for world generation as urgent

Implements a general priority system so that chunks that are sorted in
the generator queues can prioritize certain chunks over another.

Urgent chunks will jump to the front of the line, ensuring that a
sync chunk load on an ungenerated chunk does not lag the server for
a long period of time if the servers generator queues are filled with
lots of chunks already.

This massively reduces the lag spikes from sync chunk gens.

Then we further prioritize loading order so nearby chunks have higher
priority than distant chunks, reducing the pressure a high no tick
view distance holds on you.

Chunks in front of the player have higher priority, to help with
fast traveling players keep up with their movement.

This commit also improves single core cpu scenarios in that we will
now automatically disable Async Chunks as well as Minecrafts thread
pool.

It is never recommended to use async chunks on a single CPU as context
switching will be slower than just running it all on main.

This also bumps the number of server worker threads by default too.
Mojang does not utilize the workers in an effecient manner, resulting
in them using barely any sustained CPU.

So give it more workers so more chunks can be processed concurrently

This change also improves urgent chunk loading, so players flying into
unloaded chunks will hurt a little bit less (but still hurt)

Ping #3395 #3363 (Not marking as closed, we need to make prevent moving work)
2020-05-19 04:09:37 -04:00
Mariell
c8028d1c76
Fix data version check for ItemStack serialization (#3394)
The expected version should be equal to or newer than the one stored.

Although Aikar claims he did this on accident (and NOT my ligatures!), I
claim this is all a big conspiracy by followers of the Taco cult.
2020-05-18 12:24:06 -05:00
Aikar
9254a80a1b
Fix race condition reintroduced in Prioritize class loader patch 2020-05-18 01:18:44 -04:00
Mariell Hoversholm
6f196fe701
Add Raw Byte ItemStack Serialization
Serializes using NBT which is safer for server data migrations than bukkits format.
2020-05-17 00:52:24 -04:00
Spottedleaf
df43f82838
Allow server startup for those poor people running <1G Xmx
Clamp logic for poolsize so we dont pass zero
2020-05-17 00:32:37 -04:00
Spottedleaf
3c9b65ef9d
Fix cases where no-tick < tick view distance 2020-05-17 00:24:49 -04:00
MeFisto94
72f89a076a
Workaround for Client Lag Spikes (MC-162253)
When crossing certain chunk boundaries, the client needlessly
calculates light maps for chunk neighbours. In some specific map
configurations, these calculations cause a 500ms+ freeze on the Client.

This patch basically serves as a workaround by sending light maps
to the client, so that it doesn't attempt to calculate them.
This mitigates the frametime impact to a minimum (but it's still there).
2020-05-17 00:21:42 -04:00
Mariell Hoversholm
3f941c0cce
Add option for console having all permissions
Overrides permissions set to default false (which op does not get)
2020-05-16 23:55:54 -04:00
Mariell Hoversholm
d2ae4658ec
Add permission for command blocks 2020-05-16 23:48:54 -04:00
Mariell Hoversholm
9f8ae5cb61
Prioritise own classes where possible
This adds the server property `Paper.DisableClassPrioritization` to disable
prioritization of own classes for plugins' classloaders.

This value is by default not present, and this will therefore break any
plugins which abuse behaviour related to not using their own classes
while still loading their own. This is often an issue with failing to
relocate or shade properly, such as when shading plugin APIs like Vault.

A plugin's classloader will first look in the same jar as it is loading
in for a requested class, then load it. It does not re-use other
plugins' classes if it has the chance to avoid doing so.

If a class is not found in the same jar as it is loading for and it does
find it elsewhere, it will still choose the class elsewhere. This is
intended behaviour, as it will only prioritise classes it has in its own
jar, no other plugins' classes will be prioritised in any other order
than the one they were registered in.

The patch in general terms just loads the class in the plugin's jar
before it starts looking elsewhere for it.
2020-05-16 23:33:47 -04:00
kickash32
74466412ee
Check portal restrictions when entering end gateways 2020-05-16 23:28:59 -04:00
Josh Roy
fc9cf84dc6
Fix NPE when temp ip bans expire (#3373) 2020-05-16 23:26:49 -04:00
Max Lee
16bd420db5
Add missing mob goals for API (#3367) 2020-05-16 23:19:24 -04:00
Mariell Hoversholm
b5c4e2f655
Ensure no-tick view is not smaller than ticking VD
Fixes #3372.
2020-05-16 23:09:06 -04:00
MiniDigger
52564b1f89
Expand Pathfinding API with more options 2020-05-16 23:02:48 -04:00
MiniDigger
dde6548136
Fix usage of vanilla goals 2020-05-16 22:59:20 -04:00
kickash32
7797aebe63
Drop Leads from nether portals - Fixes #3226 2020-05-16 22:58:11 -04:00
Spottedleaf
511b6bc278
Reduce MutableInt and Vec3d allocations, use ArrayDeque 2020-05-16 22:26:45 -04:00
Aikar
84673141a0
Optimize NibbleArray to use pooled buffers
Massively reduces memory allocation of 2048 byte buffers by using
an object pool for these.

Uses lots of advanced new capabilities of the Paper codebase :)

Targets 3072 * 8 buffers per 1GB of heap memory up to a max consideration
of 6GB of heap (any more over 6GB won't give more nibble pool)

You can control the 3072 number by setting -DPaper.nibbleBucketSize=2048

Remember this number is * 8 then * heap memory in GB

That is 98304 objects for 4GB of memory, at 2064 bytes roughly, meaning 194MB

You may also control max number of pooled objects directly instead of any
dynamic calculation using -DPaper.maxNibblePoolSize=1024000

While this will use more old generation by a tad bit, allocation rate will drop
significantly, causing less young generation GC's.

This commit has gone through extensive testing for over a day and confident
it no longer has any issues with light corruption.
2020-05-16 22:24:36 -04:00
Aikar
897dd2c840
Foundational work for Future Memory usage improvements
This commit doesn't do much on its own, but adds a new Java Cleaner API
that lets us hook into Garbage Collector events to reclaim pooled objects and
return them to the pool.

Adds framework for Network Packets to know when a packet has finished dispatching
to get an idea when a packet is done sending to players.

Rewrites PooledObjects impl to properly respect max pool size and remove
almost all risk of contention.

Bumps the Paper Async Task Queue to use 2 threads, and properly shuts it down on shutdown.
2020-05-16 21:38:19 -04:00
Spottedleaf
bb4002d82e
Handle CraftPlayer#setSpectatorTarget better
Use a proper teleport for teleporting to entities in different
worlds.

Validate that the target entity is valid and deny spectate
requests from frozen players.

Also, make sure the entity is spawned to the client before
sending the camera packet. If the entity isn't spawned clientside
when it receives the camera packet, then the client will not
spectate the target entity.
2020-05-14 18:05:00 -05:00
Aikar
4ae089597b
Fix collision checks on spawning hanging entities and null on async chunk loads
getCubes will now always load chunks
getChunk with gen false will now not throw error

Fixes #3368
Fixes #3364
2020-05-14 05:05:13 -04:00
Aikar
c2f8d1ef98
Protect Bedrock and End Portal/Frames from being destroyed
This fixes exploits that let players destroy bedrock by Pistons, explosions
and Mushrooom/Tree generation.

These blocks are designed to not be broken except by creative players/commands.
So protect them from a multitude of methods of destroying them.

A config is provided if you rather let players use these exploits, and let
them destroy the worlds End Portals and get on top of the nether easy.
2020-05-14 03:16:31 -04:00
Aikar
827cc63263
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
ffc8e4ca SPIGOT-5716: Clarify documentation of MultipleFacing

CraftBukkit Changes:
d07a78b1 SPIGOT-5716: Clarify documentation of MultipleFacing
46a13860 SPIGOT-5718: Block.BreakBlockNaturally does not reflect tool used
214ffea9 SPIGOT-5727: GameRule doImmediateRespawn cannot be set per-world

Spigot Changes:
2f5d615f SPIGOT-5730: Modernise inventory patch
a2bdb119 SPIGOT-5679: Add config option for end portal activation sound

Closes #3352
2020-05-12 01:27:07 -04:00
Aikar
92f680ed84
Fix Pathfinding and obscure glitchy buggy 0 tick farms
I swear the crap that stuff will abuse to make stuff happen is insane.

Hash codes apparently changing behavior of stuff based on its value, so
reverting 2d401d2dfb

Fixes #3346
Fixes #3341
2020-05-11 21:18:11 -04:00
Aikar
7a7c429260
Optimize Pathfinder - Remove Streams / Optimized collections
I utilized the IDE to convert streams to non streams code, so shouldn't
be any risk of behavior change. Only did minor optimization of the
generated code set to remove unnecessary things.

I expect us to just drop this patch on next major update and re-apply
it with the IDE again and re-apply the collections optimization.

Optimize collection by creating a list instead of a set of the key and value.

This lets us get faster foreach iteration, as well as avoids map lookups on
the values when needed.
2020-05-11 04:24:38 -04:00
Aikar
fc917d1687
Optimize Hoppers - Major performance improvement
Removed streams from hoppers and also fixed a mistake in the logic.
When this patch was ported to 1.14/1.15, a line of code was put in
the wrong place which disabled a significant portion of the improvement.

Replaced usages of streams in isEmpty and itemstack checks
Replaced usage of streams in pulling loop
Replaced usage of streams in Lootable Inventory isEmpty() check
Only check for refilling Lootable Inventory when accessing first slot, not all

All of these in general were pretty significant hits, so this single commit
is going to cause tacos to magically appear in front of you every day.

🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮

Nom Nom Nom
If you hate taco's, you're not allowed to use this improvement.

Also ignore the renames, pulled a lot of PR's.
2020-05-11 03:42:32 -04:00
Omer Uddin
14ad77c692
Fix PotionEffect API Ignoring Icon bug
Fixes #3142
2020-05-11 00:44:27 -04:00
Omer Uddin
eb3ce8a258
Fix EntityRaider picking up items when they shouldn't be able
Fixes #2205
2020-05-11 00:41:15 -04:00
Aikar
1ea9ada0da
Add a TELEPORT ticket when changing dimensions
This should fix any remaining issues around collision issues on
chunk edges when changing dimensions sending to Y 256
2020-05-11 00:19:40 -04:00
Aikar
8e9459eadc
Fix missing flag pass for isUrgent 2020-05-11 00:19:40 -04:00
Josh Roy
7befec4420
Potential bed api (#3339) 2020-05-11 00:19:04 -04:00
Spottedleaf
27945a6b1f
Optimize WorldBorder collision checks and air
Port part of leafs changes from Tuinity, will worry about rest later with larger changes coming
2020-05-10 22:52:20 -04:00
Aikar
55e17a8599
Wait for Async Tasks during shutdown
Server.reload() had this logic to give time for tasks to shutdown,
however shutdown did not...

Adds a 5 second grace period for any async tasks to finish and warns
if any are still running after that delay just as reload does.

Closes #3337
2020-05-10 22:17:55 -04:00
Aikar
b59052566b
Ensure Entity AABB's are never invalid
If anything used setPositionRaw, it left potential for an AABB
to be left stale at their old location, which could cause massive
AABB boxes if movement ever then got called on the new position.

This guarantees any time we set the entities position, we also
update their AABB.
2020-05-10 22:14:47 -04:00
Aikar
a054aa6f02
Properly remove Entities from current chunk
We store a reference to the chunk the entity is currently in, so use it
to more accurately unregister it in chunkCheck

Should maybe fix some entity loss issues.
2020-05-10 05:52:31 -04:00
Aikar
c894ddfd38
Fix teleporting onto a chunk line
Obscure detail in that if you teleport right on a chunk line, it
adds +1 to your collision check and will check the unloaded neighbor.

but the call to load the chunk then returned null if it was pending unload, such
as the load we did in Player List

However we want gen=true for players here anyways, so use getType
2020-05-10 05:52:26 -04:00
Aikar
57d6cc0158
Send LOGIN protocol packets immediately - Fix disconnect during async prelogin 2020-05-10 03:12:05 -04:00
Aikar
cd93e54df3
Don't use our modified chunk checks for collision in world gen
Fixes issues with errors in logs on generating chunks
2020-05-10 02:27:50 -04:00
Aikar
b4003ef1ca
Allow loading entities current chunk if needed to fix collision checks
Having trouble reproducing this myself, but this should do it.
2020-05-10 01:04:45 -04:00
Aikar
e5f6489602
Add Urgent API for Async Chunks API and use it for Async Teleport
This also cleans up the implementation of Async Chunks to get rid of most
Consumer callbacks and instead return futures.

This lets us propogate errors correctly up the future chain
(barring one isn't lost even deeper in the chain...)

So exceptions can now bubble to plugins using getChunkAtAsync
2020-05-10 00:57:03 -04:00
Aikar
ad8e59dc79
Ensure chunks loaded on respawn for suffocation check 2020-05-09 21:13:30 -04:00
Aikar
b1691e7b69
Remove some Streams usage in Entity Collision
While there is more down the collision system, remove some of the wrapping
Spliterator stuff as even this wrapper stream has shown up in profiling.

With other collision optimizations, we might also even avoid inner streams too.
2020-05-09 19:38:31 -04:00
JellySquid
d454bbd5e1
Implement JellySquid's Entity Collision optimisations patch
This patch replaces the vanilla collision code for both block and entity collisions with faster implementations by JellySquid, used originally in her Lithium mod.

Optimizes Full Block voxel collisions, and removes streams from Entity collisions

Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.15.x/fabric (Yarn mappings)

Ported by
Co-authored-by: Zoutelande <54509836+Zoutelande@users.noreply.github.com>

Touched up by Aikar to keep previous paper optimizations
2020-05-09 19:19:18 -04:00
Aikar
8e85f841d8
Optimize Collision to not load chunks
The collision code takes an AABB and generates a cuboid of checks rather
than a cylinder, so at high velocity this can generate a lot of chunk checks.

Treat an unloaded chunk as a collision for entities, and also for players if
the "prevent moving into unloaded chunks" setting is enabled.

If that setting is not enabled, collisions will be ignored for players, since
movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups.

Fixes #3321
2020-05-09 19:19:08 -04:00