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

Make DB access async, add nanotime to debug, move mark to NameRecord. #16

Open
wants to merge 4 commits into
base: mc1.12
Choose a base branch
from

Conversation

caucow
Copy link

@caucow caucow commented May 8, 2020

Used bukkit scheduler + guava loadingcache to make name loading/generation/storage async
Added 3 config options (only present in code, not config.yml) to configure the cache
Added time measuring debug to the name loading/generation/storage

I wasn't sure whether the player ID/item type was being written to the database for logging purposes so "mark"ing a name as used (and including the name/item) is still done for every wordbanked item. That can be safely disabled by calling NameRecord.mark with force=false on line 183 of ActionListener.

@DevotedServant
Copy link

Can one of the admins verify this patch? @ProgrammerDan @Maxopoly

"ok to test" will build any commits made to this PR
"test this please" will build this PR once
"retest this please" will make another single build for this PR
"add to whitelist" will whitelist the creator of this PR and make jenkins automatically build any PRs made by him

@ProgrammerDan
Copy link
Contributor

ProgrammerDan commented May 8, 2020 via email

@DevotedServant
Copy link

Build finished.

@caucow
Copy link
Author

caucow commented May 8, 2020

Bug testing - next to none. Feature testing -
It compiles and runs on my 1.12 test server, spamming wordbank doesn't drop my TPS (though I don't have anything else going on in the background, the heavier/laggier stuff is async now so /shrug).
I started with a small wordlist using a scrape off the foobar wikipedia page, switched a little later to a list with "most english words". With wordlist 1, "butts" generated "§2cited titled", with wordlist 2 and before adding the database lookup, it generated something else. I screwed up the SQL syntax at first when adding the database lookup and it defaulted to generating the new string; after adding the fail_rename_on_db_error=true config option it gave up and didn't try to regenerate a name if there was an exception during the database lookup. After manually removing the newer entries from the database, and once the config option was in place and enabled it either failed to get a name at all (due to still bad SQL syntax), resulting in me getting the "still generating/maybe there was an error" message every time I tried to rename an item, or (once I fixed the query syntax) always getting the original name "§2cited titled".

Of note is that due to the name lookup/generate only being triggered by the "first hit" and the map entry marking a player's first hit only being removed after either the 10 second task timer runs out or the player successfully applyies a cached name to an item, a player cannot (usually) cause more than one lookup/generate to run at a time, ie. "spamming wordbank to lag the server/database" was unintentionally (somewhat) nerfed.

@DevotedServant
Copy link

Build finished.

With the async code put in place of the old non-async code, the player
would be charged the cost of a wordbank item even if the new name hadn't
finished loading yet. That's been fixed.

The unintentional cooldown on wordbank usage while a player waits for a
name to load, except sometimes not if player switches items, that's been
made more predictable now: if a player queues a name then tries to queue
another name without applying the first name, it'll warn them first and
either prevent them from loading the new name before the last name
loads, or allow them to queue the next name load regardless of whether
the last finished loading or not. Configurable with
"prevent_dblookup_spam", defaults to true, preventing players from
queueing second+ name lookups until the first has finished or the
hit-to-confirm timer ends.

The config option added in the last commit "force_mark_all_renames" has
been renamed to "dblog_all_item_marks" following crimeo's (very) valid
criticism of how awful and confusing the old name was.

The in-game error messages were also changed to red to be more
noticeable.
@DevotedServant
Copy link

Build finished.

@ProgrammerDan
Copy link
Contributor

How're you feeling about this commit? Feeling it's complete? or still planning more work?

@DevotedServant
Copy link

Build finished.

@caucow
Copy link
Author

caucow commented May 12, 2020

Yeah I'm not adding anything new, and I can't find anything else to break with these changes.

@ProgrammerDan
Copy link
Contributor

Ok, thanks, will review & merge asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants