[patch] Improving timeOut performance

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

UltimaWeapon
Human
Human
Posts: 37
Joined: 04 Apr 2008, 22:55
Noob?: Yes
Location: Thailand

[patch] Improving timeOut performance

#1 Post by UltimaWeapon »

I have not testing it. But it should working perfectly. Please commit it. Thank! :mrgreen:

Code: Select all

Index: src/auto/XSTools/misc/fastutils.xs
===================================================================
--- src/auto/XSTools/misc/fastutils.xs	(revision 6742)
+++ src/auto/XSTools/misc/fastutils.xs	(working copy)
@@ -15,7 +15,17 @@
 MODULE = FastUtils	PACKAGE = Utils
 PROTOTYPES: ENABLE
 
+BOOT:
+	SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0);
+	
+	if (!svp)
+		croak("Time::HiRes is required");
+	else if (!SvIOK(*svp))
+		croak("Time::NVtime isn't a function pointer");
+	
+	NVtime = INT2PTR(void *, SvIV(*svp));
 
+	
 SV *
 binFind(r_array, ID)
 	SV *r_array
@@ -89,14 +99,6 @@
 			if (!(v_timeout = SvNV (compare_time)))
 				XSRETURN_YES;
 
-			if (!NVtime) {
-				SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
-				if (!svp)
-					croak("Time::HiRes is required");
-				if (!SvIOK (*svp))
-					croak("Time::NVtime isn't a function pointer");
-				NVtime = INT2PTR (void *, SvIV (*svp));
-			}
 			current_time = ((NVtime_t) NVtime) ();
 
 		} else {
@@ -113,14 +115,6 @@
 			if (!(sv_timeout = hv_fetch (hash, "timeout", 7, 0)) || !(v_timeout = SvNV (*sv_timeout)))
 				XSRETURN_YES;
 
-			if (!NVtime) {
-				SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
-				if (!svp)
-					croak("Time::HiRes is required");
-				if (!SvIOK (*svp))
-					croak("Time::NVtime isn't a function pointer");
-				NVtime = INT2PTR (void *, SvIV (*svp));
-			}
 			current_time = ((NVtime_t) NVtime) ();
 		}
 
I may make you misunderstand. Because my English isn't good enough. So Sorry.
Image
Bibian
Perl Monk
Perl Monk
Posts: 416
Joined: 04 Apr 2008, 03:08

Re: [patch] Improving timeOut performance

#2 Post by Bibian »

test first =P
kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: [patch] Improving timeOut performance

#3 Post by kali »

I'm not sure what kind of performance we're talking about here, but the xs functions are already in C/C++ - they're pretty fast already.

Perhaps a benchmark can show us which parts get improved? :)

Also, changing this means that we need to provide new compiled versions for windows users, and ensuring that compilation works for *nix users. Until that's sorted out, we'd have to have some pretty convincing reasons to roll out your fix. Not to say it isn't important, just that we need more time to fully test out its side effects :)
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.
UltimaWeapon
Human
Human
Posts: 37
Joined: 04 Apr 2008, 22:55
Noob?: Yes
Location: Thailand

Re: [patch] Improving timeOut performance

#4 Post by UltimaWeapon »

I see. Thank. :mrgreen:
I may make you misunderstand. Because my English isn't good enough. So Sorry.
Image