Verified Commit 5835547a authored by Camil Staps's avatar Camil Staps 🚀

Several performance improvements

parent 84ab357a
Subproject commit 1bf618f0f25f38d1a70be983c9cec2bc9b3bbcdc
Subproject commit c1ccaba33a375818daea03744dbcb7fc10400f3f
......@@ -75,6 +75,7 @@ Start w
# w = disableSwap w
#! (_,f,w) = fopen "types.json" FReadText w
#! (db,f) = openDb f
#! db = eval_all_nodes db
#! (_,w) = fclose f w
= serve (handle db) (Just log) (toInt port) w
where
......@@ -93,6 +94,14 @@ where
# io = io <<< "Could not lock memory (" <<< err <<< "); process may get swapped out\n"
= snd $ fclose io w
eval_all_nodes :: !.a -> .a // From GraphCopy
eval_all_nodes g = code {
push_a 0
.d 1 0
jsr _eval_to_nf
.o 0 0
}
handle :: !CloogleDB !(Maybe Request) !*World -> *(!Response, CacheKey, !*World)
handle db Nothing w = (err InvalidInput "Couldn't parse input", "", w)
handle db (Just request=:{unify,name,page}) w
......
......@@ -18,8 +18,8 @@ from Text import class Text(concat,startsWith), instance Text String
import CloogleDB
import Type
from CloogleDBFactory import findModules, getModuleTypes, constructor_functions,
record_functions
from CloogleDBFactory import :: TemporaryDB, newTemporaryDb, finaliseDb,
findModules, indexModule, constructor_functions, record_functions
:: CLI = { help :: Bool
, version :: Bool
......@@ -85,7 +85,8 @@ Start w
| cli.version = fclose (f <<< VERSION) w
# (modss, w) = mapSt (flip (uncurry $ findModules cli.exclude cli.root) "") cli.libs w
# mods = flatten modss
#! (db, w) = loop cli.root mods newDb w
#! (db, w) = loop cli.root mods newTemporaryDb w
#! db = finaliseDb db newDb
#! db = putFunctions predefFunctions db
#! db = putClasses predefClasses db
#! db = putTypes predefTypes db
......@@ -98,13 +99,22 @@ Start w
| not ok = abort "Couldn't close stdio"
= w
where
loop :: String [(String,String,Bool)] !CloogleDB !*World -> *(!CloogleDB, !*World)
loop :: String [(String,String,Bool)] !TemporaryDB !*World -> *(!TemporaryDB, !*World)
loop _ [] db w = (db,w)
loop root [(lib,mod,iscore):list] db w
#! w = snd (fclose (stderr <<< lib <<< ": " <<< mod <<< "\n") w)
#! (db, w) = getModuleTypes root mod lib iscore db w
#! (db, w) = indexModule root mod lib iscore db w
#! db = eval_all_nodes db
= loop root list db w
eval_all_nodes :: !.a -> .a // From GraphCopy
eval_all_nodes g = code {
push_a 0
.d 1 0
jsr _eval_to_nf
.o 0 0
}
parseCLI :: [String] -> Either String CLI
parseCLI [] = Right zero
parseCLI [x:a] = case (x,a) of
......@@ -123,17 +133,15 @@ where
<<< "| Functions | " <<< funs <<< " |\n"
<<< "| Types | " <<< types <<< " |\n"
<<< "| Classes | " <<< classes <<< " |\n"
<<< "| Instances | " <<< insts <<< " |\n"
<<< "| Derivations | " <<< derives <<< " |\n"
<<< "+-------------+-------+\n"
where
[modules,funs,types,classes,insts,derives:_]
[modules,funs,types,classes,derives:_]
= map (pad 5)
[ moduleCount db
, functionCount db
, typeCount db
, classCount db
, instanceCount db
, deriveCount db
]
pad n i = {' ' \\ _ <- [0..n-size (toString i)-1]} +++ toString i
......@@ -155,6 +163,7 @@ predefClasses
, ce_context=[]
, ce_documentation=Nothing
, ce_members=[]
, ce_instances=[]
}
)
]
......
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