Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache SID result #24

Closed
dsawardekar opened this issue Oct 20, 2013 · 2 comments
Closed

Cache SID result #24

dsawardekar opened this issue Oct 20, 2013 · 2 comments

Comments

@dsawardekar
Copy link
Contributor

@luke-gru I recently added Profiling support to Speckle. While profiling my extensions I noticed that the SID function that Riml generates is executed a very large number of times. In Portkey this is most apparent with something like 30,000+ calls. The function itself is quite fast. Since the SID doesn't change I'd like to cache this out if possible.

I'm thinking something like a SID_VALUE that holds the result with a function like below,

function! s:SID()
  if exists('s:SID_VALUE')
    return s:SID_VALUE
  endif

  let s:SID_VALUE = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')

  return s:SID_VALUE
endfunction
@luke-gru
Copy link
Owner

Good idea! I just pushed a new version, 0.3.5, that includes this fix, along with several compiler speed-ups too. I ran portkey's vim tests, and they do run a couple of seconds faster on my computer, so it looks like caching the SID is paying off a lot 👍

In 0.3.5, there's also file rollback support that's explained in the CHANGELOG.

I'm planning on doing the smarter riml_include stuff now.

Thanks again!

@dsawardekar
Copy link
Contributor Author

That was quick. Thanks!

Rollback looks interesting. Although I rarely use riml_source. My workflow is to create 2 target files. plugin.vim and app.vim. Where app.vim is autoloaded with a viml call like my_plugin#app() which bootstraps the app and returns a reference to it.

I don't break the plugin/app into multiple vim targets. I find that this is more of an organizational thing that traditional viml plugins use. But with Riml there is already good organization by classes and objects in their own files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants