ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

CPU 100% while testing #1214

Closed ctm closed 1 year ago

ctm commented 1 year ago

Figure out why the CPU goes to 100% sometimes when logging in on localhost.

This may be a regression, although more likely I'm triggering a bug that's been there but just not been hit. The issue is that when I have a bunch of players (currently seven) attached, there can be a big pause when I'm logging in. When that happens, the CPU goes to 100% and, not surprisingly, the other clients are unresponsive, too.

I've labeled this as easy, because all I need to do is stop mb2 when it's happening and get a backtrace. That may be the default behavior if I send it the right kind of signal, but if not, I should be able to assign a signal handler and do it myself.

ctm commented 1 year ago

In theory, this can be done with rust-gdb, however, it looks like I'll have to codesign gdb.

ctm commented 1 year ago

Turns out, I only needed to invoke gdb via sudo. I didn't have to do the codesigning. However, I got a bunch of errors:

warning: can't find symbol '_ZN17compiler_builtins3int19specialized_div_rem11u32_div_rem17hbefdd49fa72f1f73E' in minsymtab warning: can't find symbol '_ZN17compiler_builtins3int19specialized_div_rem11u64_div_rem17h983a4403ccbd2b71E' in minsymtab … warning: /Users/ctm/poker/rust/poker/target/debug/deps/mb2-00ea2fadcf5e5cdf.12a5t5gtc6dm2g79.rcgu.o': file time stamp mismatch. warning:/Users/ctm/poker/rust/poker/target/debug/deps/mb2-00ea2fadcf5e5cdf.12lxn61jljb3yl3h.rcgu.o': file time stamp mismatch.

and then bt yielded unhelpful info (this was done when the CPU wasn't pegged, just as a test of bt):

(gdb) bt

0 0x00007ff80570d1fe in ?? ()

1 0x0000000103024e61 in ?? ()

2 0x3b9aca00be4f8fe8 in ?? ()

3 0x00007f9a07707bb8 in ?? ()

4 0x00007ff7be4f9610 in ?? ()

5 0x0000000302d96e20 in ?? ()

6 0x0000000000000000 in ?? ()

Presumably this will be easy to fix, by looking at the solutions in this thread. Or, I could just try lldb.

ctm commented 1 year ago

Turns out on my local machine, the last few accounts I created had insane (IMO) argon2 defaults. I looked for them on craftpoker.com and couldn't find any, so I tried to create an account and it crashed the instance, by trying to eat up too much memory.

Somewhere along the way, the argon2 default became insane. I need to fix this ASAP.

ctm commented 1 year ago

This happened when I bumped rust-argon2 to 2.0.0. It is annoying other people, too.

ctm commented 1 year ago

Deployed.

Oh, and just for completeness, I used lldb to find the source of the slowdown. Once I did that, the rest was easy. Now I'm crazy embarrassed that I didn't look into this the first time I saw the slowdown.