Commit f11cbb7f authored by Camil Staps's avatar Camil Staps 🚀

Reload cache without forking

This will cause a longer timeout when updating, but the fork apparently
causes performances issues
parent c8dc44d5
Pipeline #17222 passed with stage
in 14 minutes and 34 seconds
......@@ -194,7 +194,8 @@ Start w
# (ok,f,w) = fopen (fromJust opts.test_file) FReadText w
| not ok = errexit "Could not open test file\n" -1 w
= test opts.test_options f db w
#! (db,w) = if opts.reload_cache (doInBackground reloadCache) id (db,w)
| opts.reload_cache
= reloadCache db w
= serve
{ handler = handle
, logger = Just log
......@@ -284,26 +285,19 @@ where
}
(give,keep) = splitAt MAX_RESULTS results
reloadCache :: !*(!*CloogleDB, !*World) -> *(!*CloogleDB, !*World)
reloadCache (db,w)
reloadCache :: !*CloogleDB !*World -> *World
reloadCache db w
# (ks,w) = allCacheKeys LongTerm w
= loop ks db w
where
loop :: ![RequestCacheKey] !*CloogleDB !*World -> *(!*CloogleDB, !*World)
loop [] db w = (db,w)
loop :: ![RequestCacheKey] !*CloogleDB !*World -> *World
loop [] _ w = w
loop [k:ks] db w
# w = removeFromCache LongTerm k w
# (_,_,db,w) = handle (Just $ fromRequestCacheKey k) db w
# db = resetDB db
= loop ks db w
doInBackground :: (*a -> *a) *a -> *a
doInBackground f w
#! (pid,w) = fork w
| pid < 0 = abort "fork failed\n"
| pid > 0 = w // Parent: return directly
| otherwise = snd $ exit 0 $ f w // Child: do function
test :: ![TestOption] !*File !*CloogleDB !*World -> *World
test opts queries db w
# (e,queries) = fend queries
......
#!/bin/sh
mkdir -p ./cache/lt ./cache/brief
RELOAD="--reload-cache"
stdbuf -i0 -o0 -e0 ./CloogleServer --reload-cache | tee -a cloogle.log
while :
do
stdbuf -i0 -o0 -e0 ./CloogleServer -p 31215 $RELOAD | tee -a cloogle.log
RELOAD=""
stdbuf -i0 -o0 -e0 ./CloogleServer -p 31215 | tee -a cloogle.log
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment