Status
Not open for further replies.
Loads of bad news :( I finished fwatch up a few days ago... but I thought it was broken. Turns out it was just a cpu hog... I basically had a while loop that never exits constantly checking the scrlog.txt file for updates. Since it was constantly checking it ate all the cpu cycles leaving nothing for folding. At the time I didn't know this. I thought I just couldn't code at all and my future was screwed (as I plan to be a programmer) Last night I got bored and started playing around with some ideas. I found out what I was doing with fwatch worked fine and I didn't just totally blow as a programmer. So earlier today I made a quickie script to print out the time between each frame. Ran it and watched. After about five minutes without any output I got mad again. On a whim I ran task info and noticed the perl script was taking 95% of the cpu to folding's 2%!!! Total suckage! Even after setting the perl script to idle priority it was taking about 20% on average. I could just put folding on normal priority but then it sucks all the cpu up and makes EVERYTHING slow. I'm trying to decide if the performance hit is worth it. Plus the fact that I'll have to rewrite fwatch since I deleted it. If I think of a better way to monitor the file or a way to get the while loop to calm down, i'll go for it. Until then PP is our only choice :( Or the partly working fwatch port already floating around...

Edit: Typos and a new idea... I've thought about adding in a sleep to the loop. But when it starts the loop it goes through the entire scrlog.txt file until it hits the end, then starts taking time. If folding has been going for a while the sccrlog.txt file can be HUGE (mine is easily around 1500 lines right now...) and with a 5 second pause between every line you'll be waiting a while before you get any actual time reporting done. One work around would be having it go through the file, then starting the loop which would work great. As a matter of factly I'll make it do that. heheh this rocks. Now for the final problem, if the pause is too long it might miss an update throwing of the times. Sicne windows sucks, I'm having to use difference between the time of each update to get the times. Unlike in linux when you can check the time the process has been running and divide by the frame count (as the linux fwatch does). Enough boring theory talk... I don't wanna challenge Poof's crown of long posting... She might hurt me :)

[This message was edited by Skinny Little White Boy on January 13, 2001 at 16:58.]
 

Gyro77

Ars Tribunus Militum
1,787
I am no perl programmer, but isn't there a method or function that will allow you to only read in the last line of the file? Most other languages have this ability I think, and I know that perl is extremely versitile, so this should be possible. That way you can just query for the number from the last line and base your time estimate off of that. Just a thought, hope that helps.

Gyro77
 
Yes kinda... It's very easy to read just the last line. But here's the thing. the output from the client is sent to the scrlog.txt file. I want to catch that RIGHT when it happens. I have no way to know when it is going to happen, so I cant just read the last line. I have to watch the file for when the last line isn't the last line anymore (since it has been replaced by a new last line, if that makes any sense) Thanks for the input though.

I've already decided how I'm going to work it. A slight variation on the pause between each time it checks to see if a new last line is there.
 

Gyro77

Ars Tribunus Militum
1,787
yeah, forgot to mention just running a pause there, oops. :D Too bad there isn't a way to allow perl to keep the file open ina way that still allows FAH to write to it, that way you could just use something that passively waits for that change, rather than active polling the file. Wonder if something like that is even possible, hmmmmmm....... (I think I just talked myself into going out and learning a new language, must buy books....) :D

Gyro77
 

nottestuser

Ars Scholae Palatinae
1,049
Actually, I'll one up my own thought. F@H must have a handle on the srclog.txt file. With that handle, could you not hook the file position and have your own procedure fire when F@H changes the file position? This procedure could either read just the last line or seek to some practical position just short of the position F@H is using before starting with the readlns.
 
Gyro: perl having the file "open" doesn't stop folding from accessing it at all. If it did then I'd be really screwed :) I might look into watching the attributes and access times for a change... That's definitely an option...

hanser: I know that. Sometimes theres a pause of around 4-5 seconds between when the scrlog.txt is updated and when its actually printed out to the CLI. But it's pretty safe to say that it being sent to the file means the frame is done (although it isnt' reported to you in a easily viewable way) so thats when we want to catch the time.

nottestuser: I'm not reading the last line and checking for changes in the way you're thinking. I can't think of an easy way to explain it without using "perl terminology" which is usually incredibly retarded sounding to people who dont use perl. Basically I'm not having to compare the last line to anything to see if its changed, perl does that for me. So my while(1) loop keeps looping and looping and looping, but only does the code when the line has changed. I know it seems wierd, but most of the details are left out. Your one uped thought is fairly close to what happens, but instead of calling a procedure, it does whats within the while loop.


Edit: I've tried quite a few variations on the "pause between reads" approach, and its just not going to work... Since folding keeps the scrlog.txt file open all the time and writes to it every now and again as needed, I don't think watching for access times will work :(

[This message was edited by Skinny Little White Boy on January 13, 2001 at 20:39.]
 

nottestuser

Ars Scholae Palatinae
1,049
I'll two up my original thought. Check this out. (Loops that start with "while 1 do" are not the Windows way.)

http://www.delphiinformant.com/features/1999/03/di199903kb_f/di199903kb_f.asp

Sure it's in Delphi but it's still a good explaination of how to use the API and an external DLL (which is no problem in Perl, right?) to register to recieve window messages for shell modifications. I get to cheat since DI has already written a component to do the nitty-gritty. :)

Dexter does indeed rock. The Power Puff Girls rule though. Buttercup adorns my firewall.
 
That's basically the same thing as above, watching for a change, just on a lower level. It won't work though. Windows doesn't know the file is being changed, just that it's open. Perl also has a module (component) along those lines, Win32::ChangeNotification, and I have looked into using it. But sadly it won't work :(

I personally don't like the Pow(d)erPuff Girls. It's too ninny-ish for my liking.
 

nottestuser

Ars Scholae Palatinae
1,049
Well I tried it anyway. I put the component from DI on a form and told it to write a string to a memo component every time it recieved a message. Here's what I got when I ran it on a folder with a running copy of Folding:

Event number 0 detected at 18:17:52. Details:
Disk Event
Event number 1 detected at 18:17:52. Details:
Folder Updated
Event number 2 detected at 18:21:14. Details:
Disk Event
Event number 3 detected at 18:21:14. Details:
Folder Updated

etc.

Looks like the modification of the scrlog.txt file does cause a shell message even though the file is open.

Here's the exe and source if you want to try it on one of your boxes. NT only, gpf's under 9x.

homepages.together.net/~second/files/watch.zip

(And no comments about the exe being 325 KB. :) )
 
Status
Not open for further replies.