Paper: Optimize Block Actions (doSound)

Created on 23 May 2020  路  5Comments  路  Source: PaperMC/Paper

Timings or Profile link:

Q1ACcrn

Description of issue:

Fundamental issue. We have a world with many pistons. When they expand, each time the block action is queued. In the world tick, these are then sent in order for each block action to the nearby players.
Maybe we can change that the block actions are stored more efficiently. So that the distance does not have to be checked for each packet.

    private void an() {
        while (!this.d.isEmpty()) {
            BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst();

            if (this.a(blockactiondata)) {
                // CraftBukkit - this.worldProvider.dimension -> this.dimension, // Paper - dimension -> world
                this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
            }
        }

    }

Paper build number:

This server is running Paper version git-Paper-309 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)

Most helpful comment

Yeah I found it, just was confused when ticket said 1.15.2 yet wasn't 1.15.2 code.....

I do see a nice even more general optimization here working on now that will handle more than just sounds.

All 5 comments

You pasted not 1.15.2 code....

    private void ad() {
        while (!this.I.isEmpty()) {
            BlockActionData blockactiondata = (BlockActionData) this.I.removeFirst();

            if (this.a(blockactiondata)) {
                this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
            }
        }

    }

is the current code

Yeah I found it, just was confused when ticket said 1.15.2 yet wasn't 1.15.2 code.....

I do see a nice even more general optimization here working on now that will handle more than just sounds.

this method in older versions does lighting, which is why it hurts
so stop using outdated versions

git-Paper-309

Was this page helpful?
0 / 5 - 0 ratings