SublimeHaskell / SublimeHaskell

A Sublime Text 3 plugin for Haskell. Features cabal building, error and warning highlighting, smart completion and ghc-mod integration.
MIT License
572 stars 86 forks source link

loading standard modules #60

Closed princemaple closed 11 years ago

princemaple commented 11 years ago

Sublime Haskell: loading standard modules info for cabal within 111.931780307 seconds

Is this supposed to happen every time Sublime starts?

I think there was once that Sublime Haskell can cache this, not loading for 100+ seconds every time. Now it doesn't? Or I remembered wrong?

mvoidex commented 11 years ago

Do you have 'cache/cabal/cabal.json' in your 'Sublime Haskell' package folder?

Loading cache in my case takes 2-3 seconds.

princemaple commented 11 years ago

It exists, but it only has {} in it. So, it is not caching for me. Any ideas why? Yes, two bytes only.

mvoidex commented 11 years ago

If you remove 'cache' folder, restart Sublime and wait until it loads standard modules, will 'cabal.json' be the same? Also, if you have any opened cabal projects, check contents of 'cache/projects'. Are they empty too?

Open Sublime console (ctrl+`), then type:

import autocomplete as a
a.autocompletion.database.cabal_modules.object['cabal'].keys()

It will print module names from cabal, for which info is loaded. If it is ok, try this:

import cache
cache.encode_json(a.autocompletion.database.cabal_modules.object['cabal'], indent = 2)

It will produce string, that normally must be in cabal.json.

princemaple commented 11 years ago

Will try tomorrow, 1:00am here, got to sleep :)

[sent from mobile phone] On 01/05/2013 12:49 AM, "Alexandr Ruchkin" notifications@github.com wrote:

If you remove 'cache' folder, restart Sublime and wait until it loads standard modules, will 'cabal.json' be the same? Also, if you have any opened cabal projects, check contents of 'cache/projects'. Are they empty too?

Open Sublime console (ctrl+`), then type:

import autocomplete as a a.autocompletion.database.cabal_modules.object['cabal'].keys()

It will print module names from cabal, for which info is loaded. If it is ok, try this:

import cache cache.encode_json(a.autocompletion.database.cabal_modules.object['cabal'], indent = 2)

It will produce string, that normally must be in cabal.json.

— Reply to this email directly or view it on GitHubhttps://github.com/SublimeHaskell/SublimeHaskell/issues/60#issuecomment-17231738 .

princemaple commented 11 years ago

[] and '{}'

It's the same if I comment out all the user setting for SublimeHaskell. I only have

"auto_completion_popup": true,
"enable_hdevtools": false

anyways.

Any idea?

mvoidex commented 11 years ago

Try to

import autocompletion as a
a.autocompletion.module_completions.object['cabal']

It must output names standard modules (not loaded yet, just names)

As loading lasts for ~112 seconds, seems, that this list is not empty.

Then try to load info for any module, for example, for Data.List:

import util
util.browse_module('Data.List')

In my case, I get this:

>>> import util
>>> util.browse_module('Data.List')
<symbols.Module object at 0x000000000F508C50>
>>> util.browse_module('Data.List').declarations.keys()
[u'all', u'unfoldr', u'notElem', u'dropWhile', u'find', u'group', u'mapAccumL', u'init', u'findIndices', u'mapAccumR', u'splitAt', u'unzip', u'scanr1', u'unzip5', u'unwords', u'unlines', u'foldl1', u'break', u'tails', u'words', u'unzip4', u'insert', u'unzip6', u'unzip7', u'genericReplicate', u'unzip3', u'drop', u'genericDrop', u'foldr', u'deleteBy', u'intersectBy', u'repeat', u'genericSplitAt', u'foldl', u'scanl1', u'nub', u'groupBy', u'zip5', u'zip4', u'stripPrefix', u'sum', u'unionBy', u'intersect', u'transpose', u'foldr1', u'genericTake', u'subsequences', u'intersperse', u'zipWith7', u'zipWith6', u'zipWith5', u'zipWith4', u'zipWith3', u'last', u'reverse', u'intercalate', u'filter', u'length', u'deleteFirstsBy', u'or', u'minimumBy', u'scanl', u'nubBy', u'findIndex', u'span', u'zip', u'union', u'tail', u'concatMap', u'replicate', u'zipWith', u'scanr', u'sort', u'head', u'sortBy', u'genericIndex', u'maximum', u"foldl' :: (a -> b -> a) -> a -> [b] -> a", u'isPrefixOf', u'delete', u'and', u'maximumBy', u'takeWhile', u'permutations', u'zip3', u'minimum', u'insertBy', u'null', u'any', u'genericLength', u'zip7', u'zip6', u'lookup', u'take', u"foldl1' :: (a -> a -> a) -> [a] -> a", u'map', u'product', u'elemIndices', u'isInfixOf', u'dropWhileEnd', u'iterate', u'concat', u'cycle', u'isSuffixOf', u'partition', u'lines', u'elem', u'elemIndex', u'inits']

I think, you'll get None. The only reason for None is empty result of call to ghc-mod browse -d Data.List You can check it with this commands:

import sublime_haskell_common as c
c.call_ghcmod_and_wait(['browse', '-d', 'Data.List'])

If it's empty, try to call ghc-mod in cmd/terminal: ghc-mod browse -d Data.List

princemaple commented 11 years ago

Hmm, I found the reason.

My ghc-mod was outdated. It cannot run ghc-mod browse -d Data.List

Fixed after update

Thank you for your help, again :)

princemaple commented 11 years ago

Now that the cache file is filled, but it still takes about 40 seconds to load Sublime Haskell: loading standard modules info for cabal within 43.0495275434 seconds

Is it the correct behavior?

mvoidex commented 11 years ago

I've made commit to log time of cache-loading:

Sublime Haskell: loading standard modules cache for cabal within 6.37898108829 seconds

When plugin updates, you can check, how much time it takes to load cache.

~43 second is not normal, on my system it takes 2-3 seconds, so I haven't optimized it. I have system with same issue (~30 seconds), where I can test it. I'll create another issue for it

princemaple commented 11 years ago
Sublime Haskell: loading standard modules cache for cabal within 6.60345688371 seconds

but why it still does this

Sublime Haskell: loading standard modules info for cabal
Sublime Haskell: loading standard modules info for cabal within 44.6623139267 seconds
mvoidex commented 11 years ago

It's ok. After last update (I've commited ~5 minutes ago) it will look like this:

Sublime Haskell: loading standard modules cache for cabal within 6.13843829297 seconds
...
Sublime Haskell: loading standard modules info for cabal
Sublime Haskell: loading standard modules info for cabal within 2.89315583762 seconds
mvoidex commented 11 years ago

Sublime doesn't load info with ghc-mod if cache exists, it just checks if it already loaded for every module. And it loads only new modules, that are not in cache. And in your case it takes 44 seconds. I think it's just not optimized (there may be many locks) and I've created issue #61 for it.

princemaple commented 11 years ago

OK, thank you!

mvoidex commented 11 years ago

@princemaple, I described workaround in #61. It's not a solution, but will help.

princemaple commented 11 years ago

@mvoidex Thank you!

princemaple commented 11 years ago

Sublime Haskell: loading standard modules cache for cabal within 13.7681546678 seconds Sublime Haskell: loading standard modules info for cabal Sublime Haskell: loading standard modules info for cabal within 45.5319991898 seconds

Now ghc is 7.6.3

Any idea?

mvoidex commented 11 years ago

@princemaple, there is workaround described in #61 It's not fixed yet

princemaple commented 11 years ago

@mvoidex Thanks. Do I lose anything for using this work around?

mvoidex commented 11 years ago

No, it just makes 'ghc-mod browse ModuleInGhcPackage' not to fail.

princemaple commented 11 years ago

@mvoidex Cool, thank you very much.

mvoidex commented 11 years ago

no problem, feel free to ask anything :)