Yasuhiro Matsumoto wrote:

> When vim allocate many objects, some times vim hang for GC. Ariya Mizutani 
> suggested below's patch.
> 
> https://gist.github.com/mattn/0c58a7398c63ab4c3066
> 
> Try following test code.
> ----------------------------------------------
> let s:hoge = {}
> let s:fuga = {}
> let s:arr = []
> 
> function! Prepare() abort " {{{
>   let s:hoge.a1 = map(range(1, 50000), '{}')
>   let s:hoge.a2 = map(range(1, 50000), '{}')
>   let s:hoge.a3 = map(range(1, 50000), '{}')
>   let s:hoge.fuga = s:fuga
>   let s:fuga.hoge = s:hoge
> endfunction " }}}
> 
> function! Release() abort " {{{
>   let s:arr = s:hoge.a2
>   unlet s:hoge
>   unlet s:fuga
> endfunction " }}}
> 
> let start = reltime()
> call Prepare()
> call Release()
> call garbagecollect()
> echomsg string(reltimestr(reltime(start)))
> ----------------------------------------------
> 
> Without this patch, it take 100 seconds to finish GC. And if set 100000 
> instead of 50000, vim often hangs. With this patch, it take just 0.133967 
> seconds. This patch avoid linear-search for freeing items.
> I think this is awesome patch for vim because people uses many plugins 
> recently.
> I tried this patch few days. I don't see any problems.

This looks too simple.  There is a remark that the next dict may have
been freed, I think that was there for a good reason (dict containing a
dict).  On the other hand, the comment just a few lines up suggests that
this is not possible.  I wonder which one of the two comments is
outdated...

It's possible to pass dd_next to dict_free() (or use an ugly global
variable) and set it to NULL if it gets freed.

-- 
hundred-and-one symptoms of being an internet addict:
76. Your ISP regards you as a business partner rather than as a customer.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

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

Raspunde prin e-mail lui