Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 01-17-2005, 08:14 AM   #1 (permalink)
Junkie
 
Location: RI
[C] Debugging and tracking down problems

Hey everyone
Just as a quick background, I run an online text-based game written in C, right now we're getting some hefty lag spikes which is either 1 or 2 things which would be either the host is getting high volumes of traffic which is a possability or I have some bad functions. What programs do you guys run to track these types of problems down? I've used gdb but that's useful in crashes, or at least how I know it.
Thanks
Fallon is offline  
Old 01-17-2005, 10:46 AM   #2 (permalink)
Psycho
 
noodles's Avatar
 
Location: sc
well... first, can you just ask the host if they've been having high volumes of traffic? that kind of strikes that one out quickly, or if its is the case, there's not much that you can do about it.

second, you might want to check to see the resources the game takes up over time. just check up on it over the period of a day or so, from a fresh execution. figure out if there's a memory leak or something. (i don't know if there's any program to help with this, i'm not an expert at developing in c)

third, and this is just an idea i had, you may want to create a timekeeping library, one which is short and quick to use for debugging in this case. at the start of your functions, initiate the timekeeper, at the end of your functions, call the timekeeper and print out the time it took to run the function. this might be an easy way to find functions that are many orders of magnitude too slow, or are taking progressively longer and shouldn't be. (just an idea, again, maybe there's a program that will do this for ya)
noodles is offline  
Old 01-17-2005, 09:12 PM   #3 (permalink)
Insane
 
Location: Vermont
I know there are a couple of linux based memory checking programs, but I can't remember names right now.
Might be a good place to start.
RAGEAngel9 is offline  
Old 01-17-2005, 09:18 PM   #4 (permalink)
Crazy
 
Location: here and there
http://www.nagios.org/
is great for server monitoring. if you have the access to install it on the server, it can provide you with TONS of information about server stats.
__________________
# chmod 111 /bin/Laden
theFez is offline  
Old 01-18-2005, 04:29 PM   #5 (permalink)
Crazy
 
Location: Salt Town, UT
There are two things I go to when I start with something like that:

1. strace (or truss, or something else, depending on which os you are running on), it will give you a real-time list of every system call that process is making. It is pretty intensive, so it takes a bit, but it will let you know if you are doing a flood of reads or writes or malloc's that are killing your system. I've used it to debug a few things.

2. vmstat (or something else, depending on what system you are running on), this will let you know what part of your system appears to be the bottleneck, it will show you if it is swapping, or if you are running a ton of I/O and your disk can't keep up.

If it's not one of those, or vmstat is showing that your CPU is spiking, odds are that you have some bad code in there. To figure out what kind of code is killing you, you need a profiler, gprof is one I have tried, but it has been ages, so I can't remeber how to use it, I can just tell you to give it a shot. If you are really looking to run some optimizations (hopefully not needed for a text-based game), you can also run valgrind to see where your cache choke points are.

Just remember, try and optimize the largest thing and only the largest thing, one at a time and just keep on moving down the list until you get it good enough.
Rawb is offline  
Old 01-18-2005, 10:11 PM   #6 (permalink)
Insane
 
Kalibah's Avatar
 
Location: Padded Playhouse
MUD?

Care to share link
Kalibah is offline  
Old 01-20-2005, 11:33 AM   #7 (permalink)
Insane
 
trache's Avatar
 
Use GNU gprof. It will tell you how long certain portions of your code take to run. While functions themselves don't affect network lag much, this may help a tiny bit. At least it will tell you where you need to fix your code up, if there are certain portions that take time.
__________________
"You looked at me as if I was eating runny eggs in slow motion." - Gord Downie of The Tragically Hip
trache is offline  
Old 01-20-2005, 06:21 PM   #8 (permalink)
I am Winter Born
 
Pragma's Avatar
 
Location: Alexandria, VA
I'd recommend using Ethereal to find out if it's a network issue [i.e.: trace all network traffic and see if everything is sending like it should be]. If you don't find any problems there, then I'd recommend using gdb with breakpoints set up around any code you think may have issues and trace through very carefully.
Pragma is offline  
Old 01-21-2005, 12:53 PM   #9 (permalink)
Crazy
 
You can profile your code to see if you have bad functions that eat up processor cycles. "man gprof" is what I'm talking about (if you're using Windows, my condolences....)
__________________
I want no escape.
roboshark is offline  
Old 02-01-2005, 03:05 PM   #10 (permalink)
Tilted
 
I've used gprof, but never have had a lot of success with it. In all honestly, its probably my failure to learn to REALLY use it well. But it also requires compilation w/ -pg. What I recommend, if you can get yourself into the situation to use it, is Shark on a Mac. I know thats something of a special case, but it is an INCREDIBLE sampler. It makes it VERY easy to just run some code, look at the output, tweak it and run again. It makes iterative optimizing very easy. It also has a very nice GUI for browsing the time spent in various functions.

Its not installed by default, but part of the free CHUD downloads. I recommend it to anyone who can get their hands on it.

If you can't get that, then another linux suggestion (outside of gprof) is oprofile. Its newer than gprof, requires a kernel module, but its pretty nice. It can sample random running processes.

As far as memory tracking, theres always valgrind (which has a performance tool called cachegrind).
ergdork is offline  
 

Tags
debugging, problems, tracking


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:08 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360