<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 13 Aug 2018, at 17:10, Ilya Biryukov <<a href="mailto:ibiryukov@google.com" class="">ibiryukov@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Thanks for the details.<div class="">The "json-inside-xpc" looks a bit hacky on first notice, but the adapter is actually trying to solve a different problem of dispatching requests to the correct clangd instance based on the workspace.</div><div class="">In that case, it does make sense to avoid losing time converting between the protocols.</div></div></div></blockquote><div><br class=""></div><div>Right, the other motivation is that XPC is a prescribed form of IPC for client-service on macOS and actually provides more user-friendly API than POSIX. So we need to use it but there’s no specific requirement *how* to use it and actually this form of optimization is also used by some other services.</div><div>Anyway, we could consider this just an implementation detail and add a minimal JSON string -> xpc_dictionary conversion for LSP as a library for clangd XPC consumers to use. Then we could label the XPC representation as a stable API. Not sure if that’s necessary though. What do you think?</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><br class=""></div><div class="">One thing that might turn out to be problematic with the 'clangd-per-workspace' approach is that clangd manages some resource (ASTs, worker threads) and, obviously, can only do that inside a single process, so there are possibilities of resource starvation if too many clangd instances are running at the same time and don't know about each other.</div></div></div></blockquote><div><br class=""></div><div>We were also discussing that and our main concern were possibly duplicate ASTs in different clangd processes’ memory. Since our supported use-case is "just a few workspaces” (think 1-3 with let’s say 5 being already an extreme case) we concluded that for the time being it’s fine. In general we’d just use some reasonable limits for resources (e. g. -j 10 or whatever value we find optimal for worker threads). For general memory consumption we’ll need to implement some strategy anyway since in our case clangd would be a long-lived process running on developer’s machine. We were thinking about keeping N least recently used ASTs in memory and dropping the rest. </div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><br class=""></div></div><br style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr" class="">On Fri, Aug 10, 2018 at 7:01 PM Jan Korous <<a href="mailto:jkorous@apple.com" target="_blank" class="">jkorous@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word; line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><br class="">On 9 Aug 2018, at 18:00, Ilya Biryukov <<a href="mailto:ibiryukov@google.com" target="_blank" class="">ibiryukov@google.com</a>> wrote:</div><br class="m_599287317744190033m_-7429177264232536160Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Jan,<br class=""><div class=""><br class=""></div><div class="">Thanks for the update! It's great that we're after a solution that works at the protocol boundary, that does sound like something that should be easier to maintain and not too complicated.</div><div class="">I have skimmed through the patch, and as far as I can tell the idea is to forward raw JSON messages back and forth via XPC without actually converting from JSON to XPC and back.<br class=""></div><div class="">Am I reading it correctly?</div></div><br class=""></div></blockquote><div class=""><br class=""></div><div class="">Hi Ilya,</div><div class=""><br class=""></div><div class="">Yes that’s correct - we did some performance measurements and it turned out that for JSON containing a lot of sub-objects (think 40k CompletionItem[]) the cost of conversion to XPC dictionary is actually higher than what we gain at IPC. Just sending string over XPC is faster.</div><div class="">Since we might possibly need to use ranking and filtering logic on client side this use-case is interesting for us.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Jan</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Aug 8, 2018 at 5:38 PM Jan Korous via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank" class="">clangd-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word; line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">Based on our discussion with Sam in <a href="https://reviews.llvm.org/D48559" target="_blank" class="">https://reviews.llvm.org/D48559</a> we talked about our requirements internally and ultimately decided to change our approach.</div><div class=""><br class=""></div><div class="">We are going to use serialized JSON LSP over XPC instead of custom transport layer and we aren’t going to indroduce XPC-specific code to clangd binary itself which has several advantages.</div><div class=""><br class=""></div><div class="">I put our current design for review to continue the discussion.</div><div class=""><a href="https://reviews.llvm.org/D50452" target="_blank" class="">https://reviews.llvm.org/D50452</a></div><div class=""><br class=""></div><div class="">I would like to thank you all for the great feedback you gave us! It helped us to precisely pinpoint our requirements.</div><div class=""><br class=""></div><div class="">Thanks.</div><div class=""><br class=""></div><div class="">Jan</div><div class=""></div></div>_______________________________________________<br class="">clangd-dev mailing list<br class=""><a href="mailto:clangd-dev@lists.llvm.org" target="_blank" class="">clangd-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br class=""></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class="m_599287317744190033m_-7429177264232536160gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">Regards,</div><div class="">Ilya Biryukov</div></div></div></div></div></div></blockquote></div><br class=""></div></blockquote></div><br clear="all" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><span style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div dir="ltr" class="m_599287317744190033gmail_signature" data-smartmail="gmail_signature" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">Regards,</div><div class="">Ilya Biryukov</div></div></div></div></div></div></blockquote></div><br class=""></body></html>