aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-05-31 21:24:35 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-05-31 21:24:35 +0200
commite12d4aec1153c77fd39db7c163e159d9d53a93a5 (patch)
treeba724aaab1d3e109ddf1b8c4fe52f95ad4a0288c /include
parentc215b9142b4fb03f18e132391538cd1d1e916d61 (diff)
api: Fix bad hash-logic, front: Performance and more
Fixes #93 Fixes #92 Fixes #91 The hash logic with FreezeThaw wasn't consistent, which broke a lot of optimizations. This might be slower (?) but it's consistent which means we'll make up for it by better cache utilization. To utilize this I also added delayed JSON parsing (#91) with a big description of why we want it. This also means that #90 and #89 is a lot less important. One issue right now is that "time" isn't part of the ETag. This is both a blessing and a curse. If we are going through time we will actually use in-app cache (not browser cache - the URL changes). This makes for nice CPU savings, but ultimately means we can't tell that the data for two distinct times is identical because we only see one. Oh well... On the simpler side, I fixed/improved the clearBox logic to fix the artifacts. Might need to tune this. I also added some optimizations to avoid redrawing identical text. This is what pointed out to me that the hash was broken too: The resizeEvent was triggering all the time, forcing redraws all the time. This happened because nmsData.switches "updated" frequently which should only happen if someone adds/moves/removes a switch or linknet - regardless of time travel. This was caused by the inconsistent hash causing a false cache miss. Anyway, if you are still reading this, you almost got a patch with "kjell magne bondevik uten mellomnavn" as a literal text string... TOO BAD.
Diffstat (limited to 'include')
-rwxr-xr-xinclude/nms/web.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/nms/web.pm b/include/nms/web.pm
index 18fe919..fcd45b4 100755
--- a/include/nms/web.pm
+++ b/include/nms/web.pm
@@ -76,7 +76,9 @@ sub setwhen {
sub finalize_output {
my $query;
- my $hash = Digest::SHA::sha512_base64(FreezeThaw::freeze(%json));
+ $Data::Dumper::Indent = 0;
+ $Data::Dumper::Sortkeys = 1;
+ my $hash = Digest::SHA::sha512_base64(Data::Dumper::Dumper(\%json));
$dbh->commit;
$query = $dbh->prepare('select extract(epoch from date_trunc(\'seconds\', ' . $now . ')) as time;');
$query->execute();