VS Code's piece table implementation of text buffer

358 views
Skip to first unread message

Neil Hodgson

unread,
Mar 24, 2018, 1:41:45 AM3/24/18
to Scintilla mailing list
I thought this article about the new implementation of text storage in Visual Studio Code was worth reading. Its essentially a tree of pieces and has interesting storage versus speed trade-offs.

https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation

Neil

Mike Lischke

unread,
Mar 24, 2018, 5:32:04 AM3/24/18
to scintilla...@googlegroups.com
>
> I thought this article about the new implementation of text storage in Visual Studio Code was worth reading. Its essentially a tree of pieces and has interesting storage versus speed trade-offs.
>
> https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation


I'm surprised they never mentioned a way to lower the node count after a while, to avoid growing that list endlessly. Could be done on file save, by merging in all changes in the nodes into the original text. The piece tree is a fine implementation, even though it causes a steeper learning curve for those studying the code.

Mike
--
www.soft-gems.net

Neil Hodgson

unread,
Mar 24, 2018, 5:13:25 PM3/24/18
to scintilla...@googlegroups.com
Mike Lischke:

> I'm surprised they never mentioned a way to lower the node count after a while, to avoid growing that list endlessly.

When there are few or no changes then the list will be short and it will be fast. I expect they have good telemetry on what users actually do in edit sessions and suspect that only a small proportion (maybe 5%?) of loaded files are edited at all since reading code is such a large part of development. An even tinier proportion of files are intensely edited with more than, say, 100 changes.

Neil

Reply all
Reply to author
Forward
0 new messages