Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 03 Jun 2003
Offline Last Active Yesterday, 07:55 PM

Topics I've Started

glGetError() causes 5-second stalls?

11 September 2014 - 02:06 PM

I'm working on a toy project using GLFW and GLAD. The project renders a UI composited by simple 2D sprites, using GLFW for the main window and GLAD for GL extension/version loading/handling. This is on Windows 8.1, x64, using NVIDIA GTX 870M graphics and an Intel HD4600 framebuffer. The CPU is a Core i7-4702HQ.
The program also spawns two threads for background audio, but all communication with those is done through a non-blocking FIFO.

The project runs in windowed mode, and uses the regular Windows cursor for mouse input; the GLFW callbacks in my program then turns input events into data I can poll in the actual main loop. The main loop runs at 60 Hz just fine when I use glfwPollEvents(), and I've also tried glfwWaitEvents() (because this is a GUI-style app, no real-time simulation going on.)

The problem is that, occasionally (every 10-20 seconds perhaps) my proejct stalls the main thread. Clicking on things on the screen doesn't register until I wait for the stall to complete. These stalls are sometimes less -- from a few hundred milliseconds, often 1-2 seconds, and sometimes as big as 5 seconds.

I've traced the stall down to specific calls to glGetError(). When I remove all glGetError() calls, the stalls move to a call to glReadPixels() that I do right before glfwSwapBuffers() to prevent the GPU from running ahead of the program. I *want* this synchronization. As I said, it runs at 60 Hz just fine, most of the time.

So, the first level of advice I expect I'll get is "never read anything back." I understand that advice, and I don't think it's applicable here. If the only problem was that reading something back flushes/stalls the GPU, then I'd expect the maximum stall to be at most 16 milliseconds -- the game runs at 60 Hz just fine, and the fill rate used just isn't that much (and this is a very fast machine. It runs Unreal Engine 4 demos just fine :-)

Secondly, glGetError() doesn't necessarily have to stall or flush the pipeline. Indeed, the whole point of GL is that the application pushes commands into a command stream, and glGetError() reports the fact that "I couldn't put this command into the stream because you called it wrong." Anything that happens on the other end of that stream is not readable through glGetError() -- at least, in the platonic model of the API. I understand that IHVs may do other crazy stuff in their drivers. But not stalling for 5 seconds.

Stalls that behave like this kind-of feel like a thread priority inversion problem. I can't quite see how that would happen, though. At most, the CPU load on my system is 50% (and usually lower,) and my application only spawns a total of three threads, out of 8 hardware threads available on the 4 CPU cores.

Note that when I remove both the glGetError() calls and the glReadPixels() calls, the stalls happen less often, but they do still happen, at the glfwSwapBuffers() call in that case. Occasionally.

So -- has anyone seen stalls like this? Any idea what it could be, and what I could do to fix it?

Cocos2d-x on Visual Studio 2012 Pro?

29 March 2013 - 11:45 AM

See, this is why I dislike and distrust "wizards" and other such tomfoolery.

I want to set up a cocos2d-x project for visual studio 2012 pro. However, all the documentation I have found just says "run the wizard" and the wizard is for visual studio 2010.

Is there a good resource for "here's how to manually set up a cocos2d-x project" or, worst case, a version of the wizard for 2012?

Finding good people to port an OpenGL engine?

31 January 2013 - 11:28 PM

I have an engine written in C++ for OpenGL ES that currently compiles for WebGL using clang and Emscripten. (Yeah, I know, crazy, right? :-)
Now, I'd like to compile it for/port it to iOS using Apple tools, but I have very little experience on iOS, and very little time available to actually do that.
This sounds like the kind of thing that could easily be outsourced for some amount of money, but I've tried oDesk and Freelancer, and the quality of the contractors I find there are ... not what I'd hope so far.
Does anyone have a good idea of where to find some solid help that can do this not-too-complicated task for a not-outrageous amount of money, and help accelerate this port?

How to track 500,000 counters every 10 seconds

27 September 2012 - 11:23 AM

This is networking related, bear with me :-)

At my day job, we solve problems that most indies don't have, like "Oh, our gigabit network link is saturating, how can we route more fiber into our data center?" or "we're running out of space on our 50 terabyte storage cluster; can we get new drives from Dell in time?"

One of the things we do to manage this challenge is Continuous Deployment -- as soon as a code commit is done and tests pass, we deploy it in production. Why wait? Get feedback quicker!

Part of continuous deployment is an immune system, which detects when things "go pear shaped" in response to deploying new code, and automatically rolls back the latest commit.

To do that detection with high accuracy, short detection time, and low number of false positives, we needed better instrumentation of our application and data center than we could get through existing monitoring tools like Graphite, Zabbix, OpenTSDB, Cacti, etc. Specifically, we needed a very high rate of sampling (every 10 seconds), a very long retention time (10 days for 10 second data, 6 years for downsampled data) and statistics in real time about the sampling (mean, standard deviation, min, max, for each sample)

Because we couldn't find anything that did this, we wrote it outselves, using boost::asio and C++. And, we release it as open source! "istatd" has been used for the last year to gather, report, and chart metrics for over 500,000 counters (including the 3 different retention intervals, so 130,000 names) every 10 seconds. It rocks!

And, because it uses boost::asio, and does high-throughput networking and I/O, it might be useful for those who want to dive into that kind of network programming with a working, real-life example. Or it might be useful just if you want to track a bunch of counters over time. And if you only have three counters you care about, it'll still work, and draw pretty charts for you; it only uses as much resources as it needs :-)

Check it out at http://github.com/imvu-open/istatd/wiki
Also, I wrote a blog post describing the background: http://engineering.imvu.com/2012/09/26/continuous-monitoring-real-time-statistics-for-a-thousand-servers-and-the-application-they-serve/

Networking session at GDC Europe

03 June 2012 - 04:51 PM

Shameless self-promotion: Come watch me speak about web server versus game server scalability and architecture at GDC Europe, August 13-15, 2012! http://www.gdceurope.com/news/