1. same problem , version 2
- Posted by useless Aug 29, 2009
- 1041 views
- Last edited Aug 30, 2009
Re the topic "same problem in v4 as previous editions" , i just could not leave the application alone. The issue besides the files crashing if edited was that it took so long for news.ex to even launch the wget.ex (or wget.exe), and i usually had changes in mind already for the next run. Ok, if i can't fix the crashing problem myself (except with system(attrib +r etc, but i assume Matt may work on that), i went on to fix the problem from another angle, that it took so long to get the treads running. It seriously peeved me that the 3rd task was starting at the time the 1st one was done, and zero work was being done on the 1st's task's results.
One thing led to another, resulting in speedup mods to http.e and a news2.ex and a news3.ex. Turns out the major problem wasn't due to task overhead at all.
Http.e now tries to be non-blocking in recieving data in get_http() (typically called thru get_url()) and part of that is task_yield.
News.ex uses system() to launch new external apps, the link below can use gnu.org's wget.exe or Euphoria's wget.ex (which calls http.e), both as external applications which pass their results back in temporary disk files. This was like a train wreck of blocking calls, and slowest possible methods of doing things. I also feared it could come to a dead stop once the number of permitted open disk files got consumed. But the tasking code worked, even if there was too much of it. If you want to see how to do what it does, study it. Disk files are one of the ways to share data between apps on windoze, and new.ex shows an easy way to use tasks to monitor when the file(s) are ready to be read, without stalling your reading app.
News2.ex no longer has any system() calls, which are blocking, regardless of if they are in a task or not, once system() is called, the main task issuing loop cannot continue running, launch new tasks, or yield until system() returns. It uses the newer and improveder http.e as an include. I severely trimmed the tasks calls in it compared to news.e, and it runs ~5x faster. News2.ex has a display that makes sure you know it's multitasking.
News3.ex is a speed improvement on news2.ex, with a more plain display, altho the results are still shown in real time. By optomising for Eu v4's built-in routines, i could remove more tasking calls with no speed hits, and gained speed instead. It's how you'd code if you want speed instead of flashy gui display. Of course, for even more speed, comment out all prints/puts and all calls to console.e.
I put the files up on my host to promote the use of Eu v4 tasks functions in any new code. Any multiuser or realtime internet code could use v4's tasks code, and likely Ai and games code. It is non-preemtive tasking, but it's sometimes hard to say which task method is best. In v4's way, the programmer of the application has most control over how their application is running.
The files are at news.ex , news2.ex , news3.ex , and you'll need this http.e for it's attempts at non-blocking sockets on win32.
Have funs, people!
Comments accepted from most people.
useless
2. Re: same problem , version 2
- Posted by jeremy (admin) Aug 30, 2009
- 984 views
Kat,
Is there any reason to keep news.ex and news2.ex? I was going to delete them both and promote news3.ex to news.ex.
Jeremy
3. Re: same problem , version 2
- Posted by useless Aug 30, 2009
- 948 views
Kat,
Is there any reason to keep news.ex and news2.ex? I was going to delete them both and promote news3.ex to news.ex.
Jeremy
Well, only as how i described them above. The existing news.ex fires off external applications of your choice, and shows the downside to blocking system calls. Perhaps someone else will be just as peeved as i was at the lack of speed doing that, and build on news.ex as i did, but have some way to make system() nonblocking. Comparing news to news2 shows the speedup when not calling external apps. Comparing news2 to news3 shows overhead to gui system calls vs getting the searching done.
I thought there was value in that progression being shown. If you are asking which i would use, it's news3, it fetches news with 100% Eu code, which i had a paw in writing. But it does not show how to call an external app which someone else may wish to run instead of fetching news.
useless
4. Re: same problem , version 2
- Posted by jimcbrown (admin) Aug 30, 2009
- 945 views
shows the downside to blocking system calls. Perhaps someone else will be just as peeved as i was at the lack of speed doing that, and build on news.ex as i did, but have some way to make system() nonblocking.
I feel that having a non-blocking system()/system_exec() is a must! On Unix we can already do this by changing system[_exec](s,i) to system[_exec](s&" &",i) but we should have a cross platform method of achieving this.
5. Re: same problem , version 2
- Posted by jeremy (admin) Aug 30, 2009
- 907 views
I thought there was value in that progression being shown. If you are asking which i would use, it's news3, it fetches news with 100% Eu code, which i had a paw in writing. But it does not show how to call an external app which someone else may wish to run instead of fetching news.
I'm not sure the demo/ directory is the place to teach programming practices. I'd like to remove news.ex, news2.ex and make news3.ex the standard news.ex, if you don't mind.
Maybe a mini-guide should be created on performance and have all sorts of information, such as what you did here. That would be my vote.
Jeremy
6. Re: same problem , version 2
- Posted by useless Aug 30, 2009
- 957 views
shows the downside to blocking system calls. Perhaps someone else will be just as peeved as i was at the lack of speed doing that, and build on news.ex as i did, but have some way to make system() nonblocking.
I feel that having a non-blocking system()/system_exec() is a must! On Unix we can already do this by changing system[_exec](s,i) to system[_exec](s&" &",i) but we should have a cross platform method of achieving this.
Would a dll placed between the Eu keyword and the win32 call work? If existing Eu "system()" is redirected in the source code to point to a Eu dll instead of kernal386 (or whichever), could that dll pass the call to windoze and then immeadiately return to the Eu code? Or, perhaps this is a good reason to make a threaded call to these blocking functions? I see no way atm to write Eu code that can issue a system() or dir() call and then go do stuff while waiting on the OS to reply.
useless
7. Re: same problem , version 2
- Posted by useless Aug 30, 2009
- 911 views
I thought there was value in that progression being shown. If you are asking which i would use, it's news3, it fetches news with 100% Eu code, which i had a paw in writing. But it does not show how to call an external app which someone else may wish to run instead of fetching news.
I'm not sure the demo/ directory is the place to teach programming practices. I'd like to remove news.ex, news2.ex and make news3.ex the standard news.ex, if you don't mind.
Maybe a mini-guide should be created on performance and have all sorts of information, such as what you did here. That would be my vote.
Jeremy
Well, i spose. Thing is, it would likely have all 3 news apps as examples in that guide. I see your point. Who is going to write the mini-guide? Whoever, the versions on my website are the latest, i have not svn'd them up yet.
useless
8. Re: same problem , version 2
- Posted by jeremy (admin) Aug 30, 2009
- 918 views
Well, i spose. Thing is, it would likely have all 3 news apps as examples in that guide. I see your point. Who is going to write the mini-guide? Whoever, the versions on my website are the latest, i have not svn'd them up yet.
What have you changed? I added file writing to news3.ex, added back in clear_screen() and use maybe_any_key() instead of always presenting a Press any key prompt.
Jeremy
9. Re: same problem , version 2
- Posted by useless Aug 30, 2009
- 954 views
Well, i spose. Thing is, it would likely have all 3 news apps as examples in that guide. I see your point. Who is going to write the mini-guide? Whoever, the versions on my website are the latest, i have not svn'd them up yet.
What have you changed? I added file writing to news3.ex, added back in clear_screen() and use maybe_any_key() instead of always presenting a Press any key prompt.
Jeremy
I removed a few task_* calls, changed a couple, added more comments. Nothing serious. I had committed them after a night working on them, and they weren't nit-pickey-ed over yet. Should i svn down, patch, and re-up them?
useless
10. Re: same problem , version 2
- Posted by jeremy (admin) Aug 30, 2009
- 890 views
I removed a few task_* calls, changed a couple, added more comments. Nothing serious. I had committed them after a night working on them, and they weren't nit-pickey-ed over yet. Should i svn down, patch, and re-up them?
Just go ahead and commit them. I'm going to be releasing 4.0b2 very soon and would like to get them in the b2 release.
Jeremy
11. Re: same problem , version 2
- Posted by jimcbrown (admin) Aug 30, 2009
- 840 views
Would a dll placed between the Eu keyword and the win32 call work? If existing Eu "system()" is redirected in the source code to point to a Eu dll instead of kernal386 (or whichever), could that dll pass the call to windoze and then immeadiately return to the Eu code? Or, perhaps this is a good reason to make a threaded call to these blocking functions? I see no way atm to write Eu code that can issue a system() or dir() call and then go do stuff while waiting on the OS to reply.
If by redirecting, you mean somehow making a dll replace the keyword in the interpreter? That would be really tricky to do without modifying the source code of the interpreter itself (but, really easy to do if someone is willing to modify the source code of the interpreter itself).
Using an Eu dll means that there are two Eu engines running - the main interpreter and the Eu engine running inside of the dll. So it would be much safer to use threads inside the Eu dll to prevent the blocking.
I don't think there would be any other benefit to using a dll, though, and with the right W32API calls multithreading is not needed to turn system() into a nonblocking call. It's just a little bit more work to do on Windows then on Linux. (Actually, it could be done in 100% Eu once the W32API calls were wrapped.)
12. Re: same problem , version 2
- Posted by useless Aug 30, 2009
- 834 views
Would a dll placed between the Eu keyword and the win32 call work? If existing Eu "system()" is redirected in the source code to point to a Eu dll instead of kernal386 (or whichever), could that dll pass the call to windoze and then immeadiately return to the Eu code? Or, perhaps this is a good reason to make a threaded call to these blocking functions? I see no way atm to write Eu code that can issue a system() or dir() call and then go do stuff while waiting on the OS to reply.
If by redirecting, you mean somehow making a dll replace the keyword in the interpreter? That would be really tricky to do without modifying the source code of the interpreter itself (but, really easy to do if someone is willing to modify the source code of the interpreter itself).
Using an Eu dll means that there are two Eu engines running - the main interpreter and the Eu engine running inside of the dll. So it would be much safer to use threads inside the Eu dll to prevent the blocking.
I don't think there would be any other benefit to using a dll, though, and with the right W32API calls multithreading is not needed to turn system() into a nonblocking call. It's just a little bit more work to do on Windows then on Linux. (Actually, it could be done in 100% Eu once the W32API calls were wrapped.)
The last option you mentioned is prolly preferable, making it more likely that the non-blocking-system() can smell like an Eu task, so we can use existing task operators to know if it's done, maybe. I just figured if it was possible just by wrapping the right calls, it would have been done already.
useless