Skip to content

Reduce user lookups for LuckPerms contexts - #4869

Merged
JRoy merged 1 commit into
EssentialsX:2.xfrom
lucko:fix/contexts
Mar 27, 2022
Merged

Reduce user lookups for LuckPerms contexts#4869
JRoy merged 1 commit into
EssentialsX:2.xfrom
lucko:fix/contexts

Conversation

@lucko

Copy link
Copy Markdown
Contributor

Information

Resolves some performance issues with Essentials permission contexts.

Apologies, I have misplaced the profiles, but was prompted to fix these issues by LuckPerms/LuckPerms#3346

The issues stem from the call to ess.getUser() and the usermap.

Firstly, this call is repeated multiple times - once for each context. I have refactored so it is only called once, and the context functions accept a User instead.

Secondly, in some edge cases, it seems that Ess will not have a User object cached in memory, and the call to ess.getUser will result in i/o as the config file has to be queried.

This is a big issue, the calculators are called very frequently and often in hot code paths in the server/game.

Environments tested:

OS: macos

Java version:

openjdk version "17" 2021-09-14
OpenJDK Runtime Environment Temurin-17+35 (build 17+35)
OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode)
  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8
[21:29:52 INFO]: This server is running Paper version git-Paper-225 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 1d7a6a0)

Demonstration:

[21:27:47 INFO]: Done (5.669s)! For help, type "help"
[21:27:47 INFO]: Timings Reset
[21:27:47 INFO]: [Vault] Checking for Updates ...
[21:27:47 INFO]: [Vault] No new version available
[21:27:47 WARN]: [Essentials] You're running an up to date experimental EssentialsX build!
[21:27:47 WARN]: [Essentials] Feature Branch: fix/contexts.
[21:28:15 INFO]: UUID of player Luck is c1d60c50-70b5-4722-8057-87767557e50d
[21:28:16 INFO]: Luck joined the game
[21:28:16 INFO]: Luck[/127.0.0.1:56192] logged in with entity id 21 at ([world]2363.0061320688446, 63.0, 5452.636999732005)
[21:28:16 WARN]: [Essentials] File motd.txt does not exist. Creating one for you.
> lp user Luck info
[21:28:28 INFO]: [LP] > User Info: luck
[21:28:28 INFO]: [LP] - UUID: c1d60c50-70b5-4722-8057-87767557e50d
[21:28:28 INFO]: [LP] (type: official)
[21:28:28 INFO]: [LP] - Status: Online
[21:28:28 INFO]: [LP] - Parent Groups:
[21:28:28 INFO]: [LP] > default
[21:28:28 INFO]: [LP] - Contextual Data: (mode: active player)
[21:28:28 INFO]: [LP] Contexts: (dimension-type=overworld) (essentials:afk=false) (essentials:jailed=false) (essentials:muted=false) (essentials:vanished=false) (gamemode=creative) (world=world)
[21:28:28 INFO]: [LP] Prefix: None
[21:28:28 INFO]: [LP] Suffix: None
[21:28:28 INFO]: [LP] Primary Group: default
[21:28:28 INFO]: [LP] Meta: (primarygroup=default)

@JRoyJRoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, not sure this would be such a performance problem when we merge our new user map but still a good change plus good to avoid the possible i/o for some weird condition.

@JRoyJRoy added type: enhancement Features and feature requests. module: main Issues or PRs for the main Essentials module labels Mar 27, 2022
@JRoyJRoy added this to the 2.20.0 milestone Mar 27, 2022
@JRoyJRoy changed the title Resolve performance issues with permission contextsReduce user lookups for LuckPerms contextsMar 27, 2022
@JRoy
JRoy merged commit 4bd1b3c into EssentialsX:2.xMar 27, 2022
PureGero pushed a commit to CritterzNFT/Essentials that referenced this pull request Apr 20, 2022
@mdcfemdcfe modified the milestones: 2.20.0, 2.19.5Jul 7, 2022
ressidell pushed a commit to ressidell/Essentials that referenced this pull request Apr 27, 2025
rewsdjad1 pushed a commit to rewsdjad1/EssentialsXPlus that referenced this pull request Aug 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: mainIssues or PRs for the main Essentials moduletype: enhancementFeatures and feature requests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@lucko@mdcfe@JRoy