EricLarsen Posted January 13, 2011 Report Share Posted January 13, 2011 So I just fixed was is probably the nastiest code bug I've ever had in my career. I had an event structure in a user interface that would run all fat and happy for weeks, and then it would get in a mode where it would start taking several minutes to process a front panel input. It would be in this mode for about an hour, then return to normal function again. This bug drove me and my users crazy for months. Yesterday I finally figured it out. The event structure was processing both front panel events and programmaticaly fired events. Due to a programming bug on my part, sometimes the programic events would fire 100s of times more often then I'd intended. Most of the time, the user interface could keep up with the extra events so I'd never noticed anything was wrong. But if the user performed a ceritan sequence of front panel actions, it would cause a slight bottleneck in the event structure. This would cause a flood of unprocessed programmic events to stack up, slowing everything down. After a while, the event structure would catch back up and everying would be fine again. This was one of those "perfect storm" bugs where a lot of things had to happen in the right order for things to go wrong. I'm pretty happy I figured it out. So this led me to the question, is there anyway to determine how many unprocessed events are waiting in an event queue? I think this question had come up before, but I couldn't find any threads that answered it. Quote Link to comment
hugo_fr Posted January 13, 2011 Report Share Posted January 13, 2011 (edited) oups Edited January 13, 2011 by hugo_fr Quote Link to comment
JackDunaway Posted January 13, 2011 Report Share Posted January 13, 2011 So I just fixed was is probably the nastiest code bug I've ever had in my career.... Due to a programming bug on my part, sometimes the programic events would fire 100s of times more often then I'd intended. Just don't let Norm find out you're using Val(Sgnl). So this led me to the question, is there anyway to determine how many unprocessed events are waiting in an event queue? There is not currently a method to know how many unprocessed events are in the "Event Queue" of the Event Handler Structure, here's the discussion. But there are a few Ideas (Discard Stale Entries, Event Queue Size Terminal, Register New Refs, Priority, Control Event Buffer) you can vote for to make the "Event Queue" behave more like an Event Queue. 1 Quote Link to comment
EricLarsen Posted January 14, 2011 Author Report Share Posted January 14, 2011 Just don't let Norm find out you're using Val(Sgnl). It was nothing like that! Actually I was using the DSC to generate a dynamic event every time the alarm status of a shared variable changed. Normally that would be about 1 event an hour. Unbeknowst to me, the option to generate an event every time the shared variable value changed had been checked on several dozen of those shared variables. I don't remember checking that option, but it must have been me. So when our process was in a rapidly changing state, it generated lots and lots of dynamic events. But since the problem wasn't actually in my code, but in the shared variable configuration, I barked up the wrong tree for months trying to track this down. There is not currently a method to know how many unprocessed events are in the "Event Queue" of the Event Handler Structure, here's the discussion. But there are a few Ideas (Discard Stale Entries, Event Queue Size Terminal, Register New Refs, Priority, Control Event Buffer) you can vote for to make the "Event Queue" behave more like an Event Queue. Great info, thanks! Quote Link to comment
tushar Posted February 16, 2011 Report Share Posted February 16, 2011 There is not currently a method to know how many unprocessed events are in the "Event Queue" of the Event Handler Structure, here's the discussion. But there are a few Ideas (Discard Stale Entries, Event Queue Size Terminal, Register New Refs, Priority, Control Event Buffer) you can vote for to make the "Event Queue" behave more like an Event Queue. I have developed my own framework which help me in this scenario. Also it offers complete "loose coupling" making application extension very simple. see this post http://www.jambhekar.com/blogs/?p=48 Also you can see the monitor app utility which allows you to see which messages are pending for processing Quote Link to comment
jgcode Posted February 16, 2011 Report Share Posted February 16, 2011 the option to generate an event every time the shared variable value changed had been checked on several dozen of those shared variables. In a current project I find the event structure bogs down on startup as a bunch of these events gets processed, after a while every goes back to normal and the Event Structure works fast. I do find this to be a little bit of a performance issue on startup, I need to investigate further tho. Quote Link to comment
SteveChandler Posted February 16, 2011 Report Share Posted February 16, 2011 I can't answer your question other than to say the desktop execution trace toolkit would have helped. I use it all the time to make sure everything is running as expected, references are closed, etc. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.