• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Akemi

Is it worth logging every packet as a trace request?

7 posts in this topic

Writing a game and it seems like logging all packets sounds like a good idea in theory but it'll increase I/O load a lot and use a lot more disk space (plus increase filtering times.)

 

Is logging every packet sent and receive by a client in an authoritative server model good? Does anyone have some stories that show it can be useful?

0

Share this post


Link to post
Share on other sites

Is it worth it TO YOU?

 

Sometimes when you are hunting down a particularly rare bug it can be quite useful, you can find a malformed packet or other quirk in the system.

 

Sometimes they are awesome as they can let you completely replay a game through time to watch how to reproduce a bug.

 

Sometimes logging is useful to be triggerable, such as when an unexpected pattern happens logging gets turned on for a time and then report the results to either community managers or to the dev team.

 

Other times it serves as little more than a distraction.

 

Packet-level logs are only useful in limited circumstances. They should be configurable, something that can be reduced to zero output, with logs that can be rotated based on size and on duration, or logs that can indicate exactly which game session and which players are involved during the session in addition to the packet data.

0

Share this post


Link to post
Share on other sites

it'll increase I/O load a lot and use a lot more disk space (plus increase filtering times.)


If done well, it won't have any significant impact on performance. Queue up the packets into a buffer and then flush that on a separate thread (or even over a socket to another process/machine) when the buffer fills. The main processing of packets will be unaffected by the logging. The actual logs then can be gzipped and stored on a storage array with multiple terabytes of space (you can pick up 1TB disks for pretty cheap these days; just set up your log storage server/NAS with a handful of those and you should be good during at least development).
0

Share this post


Link to post
Share on other sites
Yes, a full log of all user input and network data is quite common (and handy.)

Given that your network throughput (10 kB/s ?) is about 10,000 less than your disk throughput (100 MB/s ?) it's unlikely there will be any perceptible impact by the logging. Make sure you use a buffered I/O mechanism. fwrite() is fine, or collect into your own 4kB buffer and flush when full. The kernel will in turn asynchronize the write, so there will be no stall in the writing thread.

Setting it up so that you can also play back the full stream is the pay-off for that logging -- this will let you very easily reproduce rare bugs.
1

Share this post


Link to post
Share on other sites

Agreed with Sean -- implemented well, with threading, it shouldn't have an undue load on I/O, your main thread, or the CPU in general.

 

If the packets are many and/or very large, then you can choose different hardware destinations in order to meet the throughput needs. By nature of these things coming over the network, I don't imagine you'd overshoot even a rotating magnetic HDD over SATA II/II, but it could be the case if you've got other IO happening on that spindle. Adding another physical drive dedicated to log capture should solve that, and if you have a second HDD controller, consider putting that dedicated drive on it, separate from the controller handling the game load. If that's still insufficient consider an SSD instead of a mechanical drive, they can be had now for even under 50 cents / GB for even modestly-sized drives, and you can get them in capacities ranging up to 1TB in the same 50-60 cents / GB ballpark. If a traditional SSD is still insufficient, a PCIe-based SSD will be more expensive but can achieve more than a GB / second transfer rate.

 

Finally, you should queue the packets into a memory buffer and write out larger chunks as Sean says. A very simple approach to this, if you know that the size of your traces will be relatively small (or that you care only about a rolling 'window' within the whole packet stream) -- say, under a handful of GB -- and you have the RAM (and memory bandwidth, sharing with your game/server) to spare, you can create a RAMDisk and just use normal file-io operations to it, then copy the file to permanent storage when the game's no longer running. A RAMDisk is basically a driver module that appears as a normal hard disk, but is backed by a portion of your RAM -- it has very, very high bandwidth and low latency as a result, but you obviously need a good chunk of RAM to spare -- Another benefit it that using a RAMDisk means that you can log the packets with normal file-io and be insulated from whether the backing storage is provided by any of the options I've mentioned, including RAM, which you would otherwise have to code specially.

 

Another thing you might possibly consider is simply pushing the packets out of another network interface to some kind of service backed by a fast key-value store (MongoDB or similar). This will push much of the load off of your machine, and also allow you to isolate all the provisioning decisions (whether to use mechanical, solid-state, or PCIe storage, whether to cache in memory) all using standard and well understood software and interfaces -- the downside, I suppose, is that you need another machine and some know-how to set that all up -- but it would be a solid and robust solution.

 

Finally part-II, consider the format that will store your traced packets in. The raw packets are often super important, but you might like to also/instead store them in human-readable form, such as JSON or perhaps YAML. You need to be careful not to introduce translation errors, which is why keeping the raw packets might be important too (so you can verify suspected mistranslations), but for a quick look-see, having human-readable text at the ready can be beneficial

0

Share this post


Link to post
Share on other sites

implemented well, with threading


You do not need threading. Unless you explicitly call sync() or a similar system call, write() will simply copy the data into a kernel buffer and scheduled for I/O later, and will not block your application. And, in fact, you may want to simply write() each piece of data directly, because this will survive an application crash. write() on a raw file descriptor will survive a process crash as soon as the write() returns, whereas fwrite() needs a fflush() to get to that point. write() will not guarantee against a full system crash, though -- only sync() does that (and then again, sometimes there's NO way of doing that, depending on how fast-and-loose the hard disks and drivers are playing.) Edited by hplus0603
0

Share this post


Link to post
Share on other sites

 

implemented well, with threading


You do not need threading. Unless you explicitly call sync() or a similar system call, write() will simply copy the data into a kernel buffer and scheduled for I/O later, and will not block your application. And, in fact, you may want to simply write() each piece of data directly, because this will survive an application crash. write() on a raw file descriptor will survive a process crash as soon as the write() returns, whereas fwrite() needs a fflush() to get to that point. write() will not guarantee against a full system crash, though -- only sync() does that (and then again, sometimes there's NO way of doing that, depending on how fast-and-loose the hard disks and drivers are playing.)

 

 

Ah, I forgot that writes were cached by the kernel and then flushed (write calls not being blocked.) That's a pretty big oversight on my problem and makes this a lot easier.

0

Share this post


Link to post
Share on other sites


You do not need threading


You're right -- threading isn't necessary if all you're doing is writing out data packets in raw format. I should have been more clear, though admittedly it was 50% my forgetting that the kernel doesn't block on disk IO. The other 50% was that if they want to do any additional processing on the data before logging, OP probably wants to thread that if it takes any significant time. At any rate, in the interest of full disclosure, my advice is sometimes over-engineered :)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0