Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce user lookups for LuckPerms contexts #4869

Merged
merged 1 commit into from
Mar 27, 2022
Merged

Conversation

lucko
Copy link
Contributor

@lucko lucko commented Mar 23, 2022

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)

Copy link
Member

@JRoy JRoy left a comment

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.

@JRoy JRoy added type: enhancement Features and feature requests. module: main Issues or PRs for the main Essentials module labels Mar 27, 2022
@JRoy JRoy added this to the 2.20.0 milestone Mar 27, 2022
@JRoy JRoy changed the title Resolve performance issues with permission contexts Reduce user lookups for LuckPerms contexts Mar 27, 2022
@JRoy JRoy merged commit 4bd1b3c into EssentialsX:2.x Mar 27, 2022
PureGero pushed a commit to CritterzNFT/Essentials that referenced this pull request Apr 20, 2022
@mdcfe mdcfe modified the milestones: 2.20.0, 2.19.5 Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: main Issues or PRs for the main Essentials module type: enhancement Features and feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants