Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Give up more intelligently; precache an extra minute ahead if time.

  • Loading branch information...
commit a2bf646932b69d6e91b326dadeeaaab37753191f 1 parent efd1081
Jamie McCarthy authored July 19, 2004

Showing 1 changed file with 26 additions and 17 deletions. Show diff stats Hide diff stats

  1. 43  themes/slashcode/tasks/precache_gse.pl
43  themes/slashcode/tasks/precache_gse.pl
@@ -52,38 +52,47 @@
52 52
 	# We'll try precaching two queries for each virtual user,
53 53
 	# one with Collapse Sections and one without.  Look ahead
54 54
 	# 40 seconds because that is guaranteed to cross the next
55  
-	# minute boundary.
  55
+	# minute boundary.  And if there's time, precache the
  56
+	# next upcoming minute too.
56 57
 	my $mp_tid = $constants->{mainpage_nexus_tid};
57 58
 	my $default_maxstories = getCurrentAnonymousCoward("maxstories");
58 59
 	my @gse_hrs = (
59  
-		{ fake_secs_ahead => 40,
  60
+		{ fake_secs_ahead =>  40,
60 61
 		  tid => $mp_tid,
61 62
 		  limit => $default_maxstories	},
62  
-		{ fake_secs_ahead => 40,
  63
+		{ fake_secs_ahead =>  40,
  64
+		  tid => $mp_tid,
  65
+		  limit => $default_maxstories,
  66
+		  sectioncollapse => 1		},
  67
+		{ fake_secs_ahead => 100,
  68
+		  tid => $mp_tid,
  69
+		  limit => $default_maxstories	},
  70
+		{ fake_secs_ahead => 100,
63 71
 		  tid => $mp_tid,
64 72
 		  limit => $default_maxstories,
65 73
 		  sectioncollapse => 1		},
66 74
 	);
67 75
 
68  
-	# Sleep until :30 after the top of the minute.
  76
+	# Sleep until :10 after the top of the minute.
69 77
 	my $time = time;
70 78
 	my $now_secs = $time % 60;
71 79
 	return "started too late" if $now_secs > 40;
72  
-	sleep 30 - $now_secs if $now_secs < 30;
73  
-	my $max_time = time - $now_secs + 55;
  80
+	sleep 10 - $now_secs if $now_secs < 10;
  81
+	my $max_time = $time - $now_secs + 55;
74 82
 
75 83
 	# Make each gSE query to each virtual user.
76  
-	for my $vu (@virtual_users) {
77  
-		if (time >= $max_time) {
78  
-			push @errs, "ran out of time on vu '$vu': " . scalar(gmtime);
79  
-			last;
80  
-		}
81  
-		my $vu_db = getObject('Slash::DB', { virtual_user => $vu });
82  
-		if (!$vu_db) {
83  
-			push @errs, "no db returned for vu '$vu'";
84  
-			next;
85  
-		}
86  
-		for my $gse_hr (@gse_hrs) {
  84
+	OUTER: for my $i (0..$#gse_hrs) {
  85
+		my $gse_hr = $gse_hrs[$i];
  86
+		INNER: for my $vu (@virtual_users) {
  87
+			if (time >= $max_time) {
  88
+				push @errs, "ran out of time on i $i vu $vu";
  89
+				last OUTER;
  90
+			}
  91
+			my $vu_db = getObject('Slash::DB', { virtual_user => $vu });
  92
+			if (!$vu_db) {
  93
+				push @errs, "no db returned for i $i vu $vu";
  94
+				next INNER;
  95
+			}
87 96
 			my %copy = %$gse_hr;
88 97
 			my $dummy = $vu_db->getStoriesEssentials(\%copy);
89 98
 		}

0 notes on commit a2bf646

Please sign in to comment.
Something went wrong with that request. Please try again.