PaperMC / PaperMC/Paper

Optimize MapItemSavedData#tickCarriedBy

Open
#9,597 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

scope: performance status: accepted
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Description of issue

MapItemSavedData#tickCarriedBy is currently used by both a map itemstack ticked inside an ItemFrame as well as the items in the player inventory.

Given that maps can be duplicated, MapItemSavedData#tickCarriedBy is potentially called multiple times per tick, for each instance of the map around (either in player inventories or item frames). #tickCarriedBy however is terribly designed in regards to the duplicate existence of the same map and should be thoroughly investigated for potential performance improvements:

Examples

carriedByPlayers is used to track which players currently carry the map. However, the itemframe calls this method for each player tracking the itemframe entity, meaning that in a single tick, a player may be added to said list just to be removed later by the iteration through the carried list.

The tickCarriedBy additionally loads Decorations from the compound tag of the item stack over and over.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at MapItemSavedData#tickCarriedBy and trace how it is called for map items in player inventories and item frames. Investigate the repeated carried-player updates and repeated loading of Decorations from item-stack compound data. Done means reducing unnecessary per-tick duplicate work without changing map behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.