Performance and thread-safety improvements#100
Conversation
// Before
public HashMap<UUID, CMISkin> skinCacheByUUID;
// After
public ConcurrentHashMap<UUID, CMISkin> skinCacheByUUID;Although this looks like a compatible implementation improvement, Java bytecode identifies a field using all three of: The two public fields and protected preFetchNames are affected. Simply declaring them as Map would also be binary-incompatible. and.. The permission cache now has a concurrent outer map, but non-concurrent inner maps: HashMap<String, PermissionInfo> playerCache = cache.get(uuid);
if (playerCache == null) {
playerCache = new HashMap<>();
}
playerCache.put(permission, result);
cache.put(uuid, playerCache);and.. The PR converts three maps to ConcurrentHashMap, but preFetchUUIDs remains a HashMap. The lookup uses a compound sequence: if (!preFetchUUIDS().containsKey(name)) {
UUID uuid = getUUID(name); // remote request
preFetchUUIDS().put(name, uuid);
}The usual fix is one canonical concurrent cache plus an atomic per-key loading mechanism, often storing a Sorry if i am wrong. |
|
Would appreciate it if you could address this minor issue in the current PR. |
Thanks for the detailed review, you're right on all three.
Pushed the two fixes as separate commits. |
please stop replying to discord msgs and things like this - you got your own issue ticket, you're constantly asking all over the place to get attention. this is not the way to do it. |
Hi, @Zrips!
Performance:
Fixes:
Each change is its own commit. Compiles clean, no behavior changes.