Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-31616

builtin clangd integration is slower than using clangd as custom Language Client at highlighting syntax

    XMLWordPrintable

Details

    • Linux/X11

    Description

      Qt Creator can use custom LSP server in Language Client settings. I can set up clangd as the custom LSP server, with the custom arguments that matches mostly with the builtin one:

      ```
      --compile-commands-dir=%

      {ActiveProject:BuildConfig:Path}

      -j=8 --background-index --background-index-priority=low --header-insertion=never --limit-references=0 --rename-file-limit=0 --clang-tidy=0 --use-dirty-headers --ranking-model=decision_forest
      ```

      And make sure the startup behavior is set to Start Server per Project.

      Then open a project with precompiled headers enabled that contains many headers, like this:

      ```cmake
      target_precompile_headers(
      ${TARGET_NAME}
      PRIVATE

      1. — stdlib —
        <string>
        <vector>
        <array>
        <map>
        <unordered_map>
        <set>
        <unordered_set>
        <queue>
        <stack>
        <deque>
        <ranges>
        <string_view>
        <tuple>
        <optional>
        <variant>
        <any>
        <bit>
        <iostream>
        <fstream>
        <sstream>
        <algorithm>
        <functional>
        <memory>
        <utility>
        <numeric>
        <limits>
        <mutex>
        <atomic>
        <thread>
        <chrono>
      2. — Boost —
        <boost/asio.hpp>
        <boost/cobalt.hpp>
        <boost/container/stable_vector.hpp>
        <boost/container/static_vector.hpp>
        <boost/container/vector.hpp>
        <boost/hof.hpp>
        <boost/lambda2.hpp>
        <boost/move/utility.hpp>
        <boost/safe_numerics/exception.hpp>
        <boost/safe_numerics/safe_integer.hpp>
        <boost/safe_numerics/safe_integer_literal.hpp>
        <boost/safe_numerics/safe_integer_range.hpp>
        <boost/scope/defer.hpp>
        <boost/scope/scope_exit.hpp>
        <boost/scope/scope_fail.hpp>
        <boost/scope/scope_success.hpp>
        <boost/smart_ptr.hpp>
        <boost/smart_ptr/atomic_shared_ptr.hpp>
        <boost/smart_ptr/local_shared_ptr.hpp>
        <boost/smart_ptr/make_local_shared.hpp>
      3. — Qt —
        <QGuiApplication>
        <QVulkanInstance>
        <QWindow>
        <QApplication>
        <QWidget>
        <QtCore>
        )
        ```

      then the builtin clangd integration is much slower than the clangd running as custom LSP server in Language Client settings.

      If I open a very small C++ source/header file, the custom clangd takes about 2 seconds to highlight the syntax, while the builtin one takes like 10 seconds.

      I'm not sure about the reason but I suppose the PCH handling in Qt Creator is to be blamed. The only difference in arguments between those two is the `--compile-commands-dir`: the custom one points to the build folder where `compile_commands.json` is generated by CMake, while the builtin one points to the `.qtc_clang` directory.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kandeler Christian Kandeler
            jclink Jessia Clinkscale
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes