Excessive memory usage and death

22 views
Skip to first unread message

Michael Thomas

unread,
Jun 17, 2016, 8:22:47 AM6/17/16
to liquidhaskell
When running the command, liquid --totality MyFile.hs, I end up maxing out my RAM (8 GB) and swap drive and eventually the process is killed.

**** DONE:  Parsed All Specifications ******************************************
 

**** DONE:  Loaded Targets *****************************************************
 
Killed

Another file in the same project runs fine. Also, this same file was working earlier. I have narrowed the problem down to this function that I recently included-

sortElementSymbolMap :: Map ElementSymbol Int -> [(ElementSymbol, Int)]
sortElementSymbolMap m = sortBy (hillSystem fst) elementSymbolIntList
     where
       elementSymbolIntList = toList m
       elementSymbols = fst <$> elementSymbolIntList
       containsC = C `elem` elementSymbols
       hillSystem f a b = case (f a, f b) of
         (C, _)   -> LT
         (_, C)   -> GT
         (H, b')  -> if containsC then LT else (show . elementName) H `compare` show b'
         (a', H)  -> if containsC then GT else show a' `compare` (show . elementName) H
         (a', b') -> show a' `compare` show b'

Any ideas why this function and liquid haskell aren't getting along?


Ranjit Jhala

unread,
Jun 17, 2016, 6:37:45 PM6/17/16
to Michael Thomas, liquidhaskell
Hi Michael, 

Thanks for pointing this out! 

Can you send the full file or a link to the repo or such so we can try to reproduce the issue?

Best,

Ranjit.

--
You received this message because you are subscribed to the Google Groups "liquidhaskell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liquidhaskel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Thomas

unread,
Jun 17, 2016, 9:05:26 PM6/17/16
to liquidhaskell, micha...@gmail.com, jh...@cs.ucsd.edu
Hi Ranjit,

You can try Base.hs in the branch liquid3. I have commented out the sortElementSymbolMap function and replaced it with undefined. Running liquid --totality Base.hs works fine like this. If I uncomment the sortElementSymbolMap function, I get the memory issue. On a side note, I am having a problem running the other file now, Isotope.Parsers.hs. I am getting a problem with "Invalid source.....unable to find module....".

https://github.com/Michaelt293/isotope/blob/liquid3/src/Isotope/Base.hs

Ranjit Jhala

unread,
Jun 17, 2016, 9:48:26 PM6/17/16
to Michael Thomas, liquidhaskell
Hi Michael -- thanks! Will take a look! Re the "unable to find module" have you tried running it with "-i src/" (assuming you're running from the root of your project) so

liquid -i src path/to/file.hs

Michael Thomas

unread,
Jun 17, 2016, 10:20:15 PM6/17/16
to liquidhaskell, micha...@gmail.com, jh...@cs.ucsd.edu
Hi Ranjit,

Along those lines, I ran "stack exec liquid src/Isotope/Parsers.hs" from the root of the project and that worked! However, running "stack exec liquid src/Isotope/Base.hs" with the sortElementSymbolMap function uncommented out still doesn't work.

Ranjit Jhala

unread,
Jun 20, 2016, 3:46:53 PM6/20/16
to Michael Thomas, liquidhaskell
Dear Michael,

The issue here is the `ElementSymbol` type with 100+ constructors, which causes
some nasty blow-ups in the pattern-matching code. The solution is to run with 

   --no-case-expand 

(which tells LH to _not_ enumerate all the cases...)

Hope this helps!

- Ranjit.

Ranjit Jhala

unread,
Jun 20, 2016, 3:47:39 PM6/20/16
to Michael Thomas, liquidhaskell
That is, this works:

   stack exec -- liquid src/Isotope/Base.hs --no-case-expand

(though it still takes rather longer than it should IMO... will keep digging)


Michael Thomas

unread,
Jun 21, 2016, 4:23:23 AM6/21/16
to liquidhaskell, micha...@gmail.com, jh...@cs.ucsd.edu
Thanks for that. Everything appears to be working fine now.
Reply all
Reply to author
Forward
0 new messages