Commit Graph

64 Commits

Author SHA1 Message Date
Konstantin Bogdanov
41385c5159
Add missing file 2024-12-16 01:10:37 +01:00
Konstantin Bogdanov
89e904747d
Do not add build flags to chcache 2024-12-16 00:29:33 +01:00
Konstantin Bogdanov
8e50a981a1
Fix chcache build 2024-12-16 00:29:27 +01:00
Konstantin Bogdanov
e2cf96535a
Update rust_vendor submodule again 2024-12-05 10:58:00 +01:00
Konstantin Bogdanov
f26c63eb4e
Update Rust vendored dependencies 2024-12-03 12:32:19 +01:00
Evgeniy Leko
5076fe4705 Do not clear terminal after skim suggestions 2024-05-02 10:02:06 +02:00
Raúl Marín
20458b3e69 Completely disable rust build for FreeBSD 2024-04-10 12:39:44 +02:00
Raúl Marín
9afe5c4b24 Remove windows dependencies from vendor crates 2024-04-09 19:25:24 +02:00
Raúl Marín
26469c9c10 Update rustc to nightly-2024-04-01 2024-04-09 19:16:46 +02:00
Raúl Marín
88b11f7352 Add rust sanitizer support with vendored deps 2024-04-09 17:15:15 +02:00
Raúl Marín
e274bd7b64 Use a rust workspace
This fixes recompilation and avoids duplication of dependencies
2024-04-09 00:50:40 +02:00
Raúl Marín
54d75be48c Separate builds and registries 2024-04-05 13:17:25 +02:00
Raúl Marín
032016cc82 Update lock with custom tuikit 2024-04-04 19:42:33 +02:00
Raúl Marín
f77822e732 Vendor rust dependencies 2024-04-04 19:22:38 +02:00
Azat Khuzhin
e926253664 Check is Rust avaiable for build, if not, suggest a way to disable Rust support
Rust requires internet connection, so let's detect if it works, and if
not, suggest building with -DENABLE_RUST=OFF, here is an example of the
output in case of error:

    $ docker run --network=none ...
    -- Copy skim to /root/rust/skim
    CMake Error at rust/CMakeLists.txt:112 (message):
      Rust (/rust/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo)
      support is not available (likely there is no internet connectivity):

          Updating git repository `https://github.com/azat-rust/tuikit.git`

      warning: spurious network error (3 tries remaining): failed to resolve
      address for github.com: Temporary failure in name resolution; class=Net
      (12)

      warning: spurious network error (2 tries remaining): failed to resolve
      address for github.com: Temporary failure in name resolution; class=Net
      (12)

      warning: spurious network error (1 tries remaining): failed to resolve
      address for github.com: Temporary failure in name resolution; class=Net
      (12)

      error: failed to load source for dependency `tuikit`

      Caused by:

        Unable to update https://github.com/azat-rust/tuikit.git?rev=e1994c0e03ff02c49cf1471f0cc3cbf185ce0104

      Caused by:

        failed to clone into: /rust/cargo/git/db/tuikit-c3ca927b4dbcf00d

      Caused by:

        network failure seems to have happened
        if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
        https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

      Caused by:

        failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12)

      You can disable Rust support with -DENABLE_RUST=OFF
    Call Stack (most recent call first):
      rust/CMakeLists.txt:129 (add_rust_subdirectory)

    -- Configuring incomplete, errors occurred!

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-03-26 15:20:49 +01:00
Maximilian Roos
e257f1d455
Merge branch 'master' into prql-panic 2024-03-04 10:12:41 -08:00
Alexey Milovidov
9b4b4c0f8a
Merge pull request #60621 from max-sixty/skim
fix(rust): Fix skim's panic handler
2024-03-04 08:16:00 +03:00
Maximilian Roos
395cc63792
Fix source of panics, add tests 2024-03-03 16:08:55 -08:00
Maximilian Roos
1a5afa90a1
fix(prql): Robust panic handler 2024-03-01 16:04:01 -08:00
Maximilian Roos
7d58d82361
internal: Refine rust prql code
This makes the rust code a bit more idiomatic. It builds on top of #60616, which can merge first. There aren't any rust tests here, so would like to check CI.
2024-02-29 21:32:27 -08:00
Maximilian Roos
1df6f4cd5c
fix(rust): Fix skim's panic handler 2024-02-29 21:26:39 -08:00
Maximilian Roos
13d476a0f3
2024-02-29 18:35:42 -08:00
Maximilian Roos
81876435e6
build: Upgrade prqlc
We also changed the name of our library (though continue to publish to `prql-compiler` FWIW)
2024-02-29 17:51:02 -08:00
Azat Khuzhin
a3938e7df0 Respect CMAKE_OSX_DEPLOYMENT_TARGET for Rust targets
This should fix the following warnings:

    ld: warning: object file (rust/prql/Debug/lib_ch_rust_prql.a[74](aarch_aapcs64.o)) was built for newer 'macOS' version (14.0) than being linked (11.0)
    ld: warning: object file (rust/skim/Debug/lib_ch_rust_skim_rust.a[40](c0e230e4543ad627-lib.rs.o)) was built for newer 'macOS' version (14.0) than being linked (11.0)
    ld: warning: object file (rust/skim/Debug/lib_ch_rust_skim_rust.a[46](6c3a6ae2099d4914-cxx.o)) was built for newer 'macOS' version (14.0) than being linked (11.0)

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-02-11 10:55:14 +01:00
Azat Khuzhin
65cfbaaa4b Safer Rust (catch panic with catch_unwind())
Crossing boundaries of multiple languages is tricky, but we can do at
least something about this, in particular, use catch_unwind() [1] to
catch possible panic!()s.

  [1]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-01-31 22:31:18 +01:00
Alexey Milovidov
27cd218483 No debug symbols in Rust 2024-01-28 15:10:57 +01:00
Raúl Marín
99d1659b4c Replace rust's BLAKE3 with llvm's implementation 2023-12-18 15:29:01 +01:00
Raúl Marín
3343d59f80 Fix invalid memory access in BLAKE3 2023-12-14 18:47:53 +01:00
Azat Khuzhin
1e0d8e098f Fix building Rust with Musl
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-12-11 20:49:19 +01:00
Alexey Milovidov
bccd33932b
Update Cargo.toml 2023-11-24 22:59:29 +03:00
Azat Khuzhin
b6bd5ecb19 Fix possible crash of fuzzy finder in client
Refs: https://github.com/lotabout/tuikit/pull/51
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-11-24 17:46:25 +01:00
Azat Khuzhin
914462d3d5 Disable skim under TSan (Rust does not supports ThreadSanitizer)
Refs: https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#threadsanitizer
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-10-09 12:37:40 +02:00
Mikhail f. Shiryaev
ed7ade255a
Use sccache for rust builds 2023-08-10 22:09:20 +02:00
Mikhail f. Shiryaev
cbd81b3758
Partially revert changes from #52395 2023-08-10 22:09:19 +02:00
Maximilian Roos
cc5ec9e634
build: Upgrade PRQL version 2023-08-04 11:34:00 -07:00
Azat Khuzhin
0b258dda4e Reproducible builds for Rust
From now on cargo will not download anything from the internet during
builds. This step had been moved for docker image builds (via cargo
vendor).

And now cargo inside docker.io/clickhouse/binary-builder will not use
any crates from the internet, so we don't need to add --offline for
cargo commands in cmake (corrosion_import_crate()).

Also the docker build command had been adjusted to allow following
symlinks inside build context, by using tar, this is required for Rust
packages.

Note, that to make proper Cargo.lock that could be vendored I did the
following:
- per-project locks had been removed (since there is no automatic way to
  sync the workspace Cargo.lock with per-project Cargo.lock, since cargo
  update/generate-lockfile will use only per-project Cargo.toml files
  apparently, -Z minimal-versions does not helps either)
- and to generate Cargo.lock with less changes I've pinned version in
  the Cargo.toml strictly, i.e. not 'foo = "0.1"' but 'foo = "=0.1"'
  then the Cargo.lock for workspace had been generated and afterwards
  I've reverted this part.

Plus I have to update the dependencies afterwards, since otherwise there
are conflicts with dependencies for std library. Non trivial.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-07-22 22:46:22 +02:00
János Benjamin Antal
e74acda53e
PRQL integration (#50686)
* Added prql-lib

* Add PRQL parser

* Extend stateless tests

* Add unit tests for `ParserPRQL`

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-37-24.eu-central-1.compute.internal>
Co-authored-by: Ubuntu <ubuntu@ip-10-10-10-195.eu-central-1.compute.internal>
Co-authored-by: Александр Нам <47687537+seshWCS@users.noreply.github.com>
2023-07-20 12:54:42 +02:00
Azat Khuzhin
380b4ffe2b Reduce dependencies for skim by avoid using default features
By default skim requires cli -> clap -> termcolor -> winapi-util

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-07-19 12:29:39 +02:00
Raúl Marín
292eec2470 Run cargo update to fix build with nightly 2023-07-03 09:40:36 +02:00
Azat Khuzhin
f1058d2d9d Revert "Disable skim (Rust library) under memory sanitizer" 2023-06-05 09:08:01 +02:00
Azat Khuzhin
bf127f4e1e MSan support for Rust
Previously you have to unpoison memory from the Rust, however Rust does
supports MSan, so let's simply use it.

But for this we need nightly Rust and recompile standard library.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-06-04 23:04:55 +02:00
Alexey Milovidov
53ec091c8d Disable skim (Rust library) under memory sanitizer 2023-06-04 05:00:29 +02:00
Azat Khuzhin
1107988a82 Improve performance of BLAKE3 by 11% by enabling LTO for Rust
LTO in Rust produces multiple definition of `rust_eh_personality' (and
few others), and to overcome this --allow-multiple-definition has been
added.

Query for benchmark:

    SELECT ignore(BLAKE3(materialize('Lorem ipsum dolor sit amet, consectetur adipiscing elit'))) FROM numbers(1000000000) FORMAT `Null`

  upstream           : Elapsed: 2.494 sec. Processed 31.13 million rows, 249.08 MB (12.48 million rows/s., 99.86 MB/s.)
  upstream + rust lto: Elapsed: 13.56 sec. Processed 191.9 million rows, 1.5400 GB (14.15 million rows/s., 113.22 MB/s.)
  llvm BLAKE3        : Elapsed: 3.053 sec. Processed 43.24 million rows, 345.88 MB (14.16 million rows/s., 113.28 MB/s.)

Note, I thought about simply replacing it with BLAKE3 from LLVM, but:
- this will not solve LTO issues for Rust (and in future more libraries
  could be added)
- it makes integrating_rust_libraries.md useless (and there is even blog
  post)

So instead I've decided to add this quirk (--allow-multiple-definition)
to fix builds.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-05-06 22:28:56 +02:00
Alexey Milovidov
1bf4aa0dd5
Merge branch 'master' into build/rust-rebuild-fix 2023-02-13 14:40:15 +03:00
Azat Khuzhin
177c98b6a9 Use "exact" matching for fuzzy search
Right now fuzzy search is too smart for SQL, it even takes into account
the case, which should not be accounted (you don't want to type "SELECT"
instead of "select" to find the query).

And to tell the truth, I think too smart fuzzy searching for SQL queries
is not required, and is only harming.

Exact matching seems better algorithm for SQL, it is not 100% exact, it
splits by space, and apply separate matcher actually for each word.
Note, that if you think that "space is not enough" as the delimiter,
then you should first know that this is the delimiter only for the
input query, so to match "system.query_log" you can use "sy qu log"
(also you can disable exact mode by prepending "'" char).

But it ignores the case by default, and the behaviour what is expected
from the CaseMatching::Ignore.

TL;DR;

Just for the history I will describe what had been tried.

At first I tried CaseMatching::Ignore - it does not helps for
SkimV1/SkimV2/Clangd matches.

So I converted lines from the history and input query, to the lower
case. However this does not work for UPPER CASE, since only initial
portion of the query had been converted to the lower.

Then I've looked into skim/fuzzy-matcher crates code, and look for the
reason why CaseMatching::Ignore does not work, and found that there is
still a penalty for case mismatch, but there is no way to pass it from
the user code, so I've tried guerrilla to monkey patch the library's
code and it works:

    // Avoid penalty for case mismatch (even with CaseMatching::Ignore)
    let _guard = guerrilla::patch0(SkimScoreConfig::default, || {
        let score_match = 16;
        let gap_start = -3;
        let gap_extension = -1;
        let bonus_first_char_multiplier = 2;

        return SkimScoreConfig{
            score_match,
            gap_start,
            gap_extension,
            bonus_first_char_multiplier,
            bonus_head: score_match / 2,
            bonus_break: score_match / 2 + gap_extension,
            bonus_camel: score_match / 2 + 2 * gap_extension,
            bonus_consecutive: -(gap_start + gap_extension),
            // penalty_case_mismatch: gap_extension * 2,
            penalty_case_mismatch: 0,
        };
    });

But this does not sounds like a trivial code, so I decided, to look
around, and realized that "exact" matching should do what is required
for the completion of queries (at least from my point of view).

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-02-04 14:15:02 +01:00
Azat Khuzhin
780c8ea586 Avoid leaving symbols leftovers on the screen during query fuzzy search
In case of multi-line queries in the history, skim may leave some
symbols on the screen, which looks icky.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-02-02 19:31:45 +01:00
Azat Khuzhin
9f9989ea72 Properly detect changes in Rust code and recompile Rust libraries
Due to we need to substitude config for Rust builds (see #44762 for
details), the source dir is copied to the binary dir, but this is done
only once, so to detect changes in sources you need to run cmake,
without this patch.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-02-02 18:33:15 +01:00
Robert Schulze
cfb6feffde
What happens if I remove these 139 lines of code? 2023-01-03 18:35:31 +00:00
Azat Khuzhin
89c071e291 Build rust modules from the binary directory
Our crates has configuration files:
- config for cargo (see config.toml.in)
- and possibly config for build (build.rs.in)

Previously it uses source directory, and it will overrides files in the
source directory, which will require recompile of crates in case of
multiple builds for one source directory.

To avoid overlaps different builds for one source directory, crate will
be copied from source directory to the binary directory.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-30 18:15:41 +01:00
Alexey Milovidov
ed3d70f7c0
Merge pull request #44623 from azat/build/rust-fix
Fix rust modules rebuild (previously ignores changes in cargo config.toml)
2022-12-27 17:10:33 +03:00