Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@
title: "Introducing Coco AI in Two Minutes - A Quick Start Video 🥥"
meta_title: "Introducing Coco AI in Two Minutes - A Quick Start Video "
description: "Discover How Coco AI to work with Google Drive"
date: 2024-12-10T09:00:00Z
date: 2024-12-10T15:00:00.000000000+08:00
image: "/images/posts/2024/introducing-coco-ai-in-two-minutes.png"
categories: ["AI", "Enterprise", "Search"]
author: "Medcl"
tags: ["Coco AI", "Search", "Gen-AI", "Enterprise"]
lang: "en"
category: "Blog"
subcategory: "Product"
draft: false
---

A quick start video to show how Coco AI to work with Google Drive.

{{< youtube t-mgb5ZuDqY >}}

Learn more about Coco AI and start exploring its features:
Learn more about Coco AI and start exploring its features:

🌐 [Coco Website](http://coco.rs)
📂 [Coco App on GitHub](https://github.com/infinilabs/coco-app/)
🔧 [Coco Server on GitHub](https://github.com/infinilabs/coco-server)

Join us in redefining how enterprises search, connect, and collaborate. 🎯
🔧 [Coco Server on GitHub](https://github.com/infinilabs/coco-server)

Join us in redefining how enterprises search, connect, and collaborate. 🎯
71 changes: 41 additions & 30 deletions content/english/posts/2024/adding-searchbox-to-hugo-blog-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,30 @@
title: "Adding Searchbox to Hugo!"
meta_title: "Adding Searchbox to Hugo Blog!"
description: "How to add a searchbox to your hugoblog site."
date: 2024-12-10T06:00:00Z
date: 2024-12-10T14:00:00.000000000+08:00
image: "/images/posts/2024/adding-searchbox-to-blog-site.png"
categories: ["Pizza", "Search"]
author: "Medcl"
tags: ["search", "searchbox", "hugo", "pizza","pizza-searchbox", "pizza-wasm", "wasm", "hugo"]
tags:
[
"search",
"searchbox",
"hugo",
"pizza",
"pizza-searchbox",
"pizza-wasm",
"wasm",
"hugo",
]
lang: "en"
category: "Blog"
subcategory: "Technology"
draft: false
---

As a static website, having a search function significantly enhances the user experience, allowing readers to locate content quickly and efficiently. Whether you’re managing a personal blog or a comprehensive documentation site, a search box is an essential feature to improve navigation and engagement.
As a static website, having a search function significantly enhances the user experience, allowing readers to locate content quickly and efficiently. Whether you’re managing a personal blog or a comprehensive documentation site, a search box is an essential feature to improve navigation and engagement.

In this article, we’ll guide you through the step-by-step process of integrating a search box into your Hugo-powered site. We’ll be using **Pizza**, a blazing-fast, WASM-based search engine that outperforms traditional JavaScript-based solutions. Pizza supports the complete Lucene query syntax, offering robust and versatile search capabilities for your site. From setup to customization, we’ll cover everything you need to create a powerful and seamless search experience.
In this article, we’ll guide you through the step-by-step process of integrating a search box into your Hugo-powered site. We’ll be using **Pizza**, a blazing-fast, WASM-based search engine that outperforms traditional JavaScript-based solutions. Pizza supports the complete Lucene query syntax, offering robust and versatile search capabilities for your site. From setup to customization, we’ll cover everything you need to create a powerful and seamless search experience.

## What is INFINI Pizza?

Expand All @@ -23,6 +36,7 @@ Currently, The website of INFINI Pizza have integrated INFINI Pizza for WebAssem
![INFINI Pizza Search](/images/posts/2024/pizza-search-box/pizza-search-box-1.png)

## How to use INFINI Pizza for WebAssembly?

Visit the website ([http://pizza.rs](http://pizza.rs/)), and by pressing the shortcut key 's', you can bring up the search box and experience the search capabilities provided by INFINI Pizza. Notably, during the search process, all of your actions are executed locally in the browser. Unlike traditional search implementations, where each query requires an interaction with a backend search server, INFINI Pizza for WebAssembly operates entirely offline. Even if you're disconnected from the internet, you can still enjoy a seamless search experience.

Without further ado, let's dive into how you can use INFINI Pizza for WebAssembly on your own site.
Expand Down Expand Up @@ -58,9 +72,9 @@ Since the example project has already uploaded the compiled code and samples, we
remote: Total 174 (delta 86), reused 147 (delta 59), pack-reused 0 (from 0)
Receiving objects: 100% (174/174), 941.94 KiB | 1.20 MiB/s, done.
Resolving deltas: 100% (86/86), done.
➜ /tmp cd pizza-searchbox/example/dist
➜ dist git:(main) python3 -m http.server 8083
➜ /tmp cd pizza-searchbox/example/dist
➜ dist git:(main) python3 -m http.server 8083

Serving HTTP on :: port 8083 (http://[::]:8083/) ...
```

Expand All @@ -78,12 +92,10 @@ The official website of Pizza/INFINI Labs is statically generated using Hugo, an

![INFINI Pizza Search](/images/posts/2024/pizza-search-box/pizza-search-box-4.png)


Add a JSON output option to the outputs parameter, and then define the JSON output format template in the theme's template files:

![INFINI Pizza Search](/images/posts/2024/pizza-search-box/pizza-search-box-5.png)


The text content is as follows for easy copying and pasting. Save the file with the name index.json:

```shell
Expand All @@ -93,28 +105,28 @@ The text content is as follows for easy copying and pasting. Save the file with
{{- end -}}
{{- $index | jsonify -}}
```

OK, next, we need to add the tags we’ve used above to the metadata of each article or blog post on the site:

![INFINI Pizza Search](/images/posts/2024/pizza-search-box/pizza-search-box-6.png)


OK, start the Hugo site:

```shell
hugo server --forceSyncStatic --minify --theme book
| EN


| EN
-------------------+------
Pages | 181
Paginator pages | 5
Non-page files | 0
Static files | 110
Processed images | 0
Aliases | 52
Sitemaps | 1
Cleaned | 0
Pages | 181
Paginator pages | 5
Non-page files | 0
Static files | 110
Processed images | 0
Aliases | 52
Sitemaps | 1
Cleaned | 0

Built in 323 ms
Watching for changes in /Users/medcl/Documents/rust/pizza/website/{assets,content.en,static,themes}
Watching for config changes in /Users/medcl/Documents/rust/pizza/website/config.yaml
Expand All @@ -137,17 +149,17 @@ Do you remember the resource files we downloaded from Pizza-searchbox earlier? W

```shell
/tmp/pizza-searchbox/example/dist
➜ dist git:(main) tree
➜ dist git:(main) tree
.
├── assets
├── index-C1z1vz3D.css
├── index-D_gOo737.js
└── pizza_wasm_bg-BRCuviY_.wasm
├── index.html
└── index.json

1 directory, 5 files
➜ dist git:(main)
➜ dist git:(main)
```

Open the index.html file, and you will see the following content:
Expand All @@ -167,7 +179,7 @@ Next, continue modifying the Hugo theme template files by adding a segment of co
Next, insert a `docsearch` tag in the appropriate place within the page template to place the search box, as shown in the image:
![INFINI Pizza Search](/images/posts/2024/pizza-search-box/pizza-search-box-12.png)

> the tag `docsearch` may be renamed to `searchbox` in the future
> the tag `docsearch` may be renamed to `searchbox` in the future

With that, the task is complete!

Expand All @@ -176,9 +188,8 @@ Open your browser to see the final result:

Finally, to summarize, with the help of the 3 lines of code and copy 3 files from INFINI Pizza searchbox, you can add a lightweight offline search functionality to your static site in just 5 minutes. Give it a try!


## References

* [https://pizza.rs](https://pizza.rs/)
* [https://github.com/infinilabs/pizza-wasm](https://github.com/infinilabs/pizza-wasm)
* [https://github.com/infinilabs/pizza-searchbox](https://github.com/infinilabs/pizza-searchbox)
- [https://pizza.rs](https://pizza.rs/)
- [https://github.com/infinilabs/pizza-wasm](https://github.com/infinilabs/pizza-wasm)
- [https://github.com/infinilabs/pizza-searchbox](https://github.com/infinilabs/pizza-searchbox)
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
title: "Profiling Rust Code on macOS: My Daily Workflow"
meta_title: "Rust Profiling on macOS: Micro-Benchmarks, Flamegraphs, and DTrace"
description: "Learn how to optimize Rust applications with profiling tools like criterion, cargo flamegraph, and DTrace on macOS."
date: 2024-12-11T08:00:00Z
date: 2024-12-11T16:00:00.000000000+08:00
image: "/images/posts/2024/benchmarking-and-profiling-rust-applications-on-macos-a-practical-guide/cover.jpg"
categories: ["Rust", "Performance"]
author: "Medcl"
tags: ["Rust", "Profiling", "macOS", "criterion", "flamegraph"]
lang: "en"
category: "Blog"
subcategory: "Technology"
draft: false
---

Profiling Rust code has become part of my daily routine. As I primarily develop on macOS, I've noticed there aren't many tools that allow for easy and quick profiling of Rust applications. So, I’d like to share my daily profiling workflow, in case it helps others. If you have other approaches or tools that work well for you, feel free to share—I’d love to hear them!


## Setting Up Micro-Benchmarks

I use micro-benchmark tests to track the performance of critical functions in my Rust application. For this, I rely on `criterion`, which is both powerful and easy to use. Here’s what my project setup looks like:


![Rust Profiling on macOS](/images/posts/2024/benchmarking-and-profiling-rust-applications-on-macos-a-practical-guide/benchmark-rust-1.png)

As you noticed, i organized my benchmark tests per module, and so i can easily include or exclude specify tests in the `benches.rs`, some times, they just take too much time, if i only want to profile specify tests, i can just comment out unrelated one. dirty but works.
Expand All @@ -28,10 +29,10 @@ If you have many similar tests, you may group them by use a customized name, lik

Micro-benchmarking is a fundamental step that helps track performance changes when refactoring code or adding new features.


## Profiling The Micro-Benchmark

What if some tests are slow, a quick way to profiling is to use:

```shell
sudo CARGO_PROFILE_BENCH_DEBUG=true cargo flamegraph --bench benches -o find-baseline.svg -- --bench
```
Expand All @@ -42,14 +43,10 @@ You can run the benchmarks with a single command, but be sure to comment out any

Now that you have several micro-benchmark tests, how can you continuously monitor performance? I’m glad I discovered a free service provided by bencher.dev. It helps track performance over time, making it easier to identify any regressions or improvements.



![Rust Profiling on macOS](/images/posts/2024/benchmarking-and-profiling-rust-applications-on-macos-a-practical-guide/benchmark-rust-3.png)




Here is my bencher command in my Makefile:

```shell
bencher-engine:
if [ -z "${BENCHER_API_TOKEN:-}" ]; then \
Expand All @@ -75,12 +72,12 @@ You can add a CI action to your GitHub repository to automatically track perform

![Rust Profiling on macOS](/images/posts/2024/benchmarking-and-profiling-rust-applications-on-macos-a-practical-guide/benchmark-rust-5.png)

## Profiling on MacOs
## Profiling on MacOs

Profiling on macOS can be slightly less convenient than on Linux, where there are many robust tools available. Here’s what I do to make the most of the profiling process, I use `Dtrace` along with two scripts:

```shell
➜ cat ~/start_profile.sh
➜ cat ~/start_profile.sh
#!/bin/bash

# Check if PID argument is provided
Expand All @@ -96,7 +93,7 @@ sudo rm -rf target/out.user_stacks || true

sudo dtrace -x ustackframes=100 -n "profile-97 /pid == $pid/ { @[ustack()] = count(); } tick-60s { exit(0); }" -o target/out.user_stacks

➜ cat ~/end_profile.sh
➜ cat ~/end_profile.sh
#!/bin/bash

# Clean up previous output files
Expand All @@ -115,26 +112,28 @@ And then start your target Rust application, make sure you set `debug=true` in `
And then execute the start script, wait for a while and Ctrl+C to capture profiling data:

```shell
➜ indexer git:(batch_indexing) ✗ ~/start_profile.sh 1494
➜ indexer git:(batch_indexing) ✗ ~/start_profile.sh 1494
dtrace: system integrity protection is on, some features will not be available

dtrace: description 'profile-97 ' matched 2 probes
^C%
^C%
```

And then you can generate the flamegraph:

```shell
➜ indexer git:(batch_indexing) ✗ ~/end_profile.sh
➜ indexer git:(batch_indexing) ✗ ~/end_profile.sh
Flamegraph generated at target/flamegraph.svg
```

Open it with your web browser and figure out what's the bottlenect, and rock with it.

![Rust Profiling on macOS](/images/posts/2024/benchmarking-and-profiling-rust-applications-on-macos-a-practical-guide/benchmark-rust-6.png)


That’s it! I hope this information helps you in your Rust development journey. If you have any questions or need further assistance, feel free to reach out!

References:

- https://github.com/bheisler/criterion.rs
- https://bencher.dev/
- https://bencher.dev/console/projects/pizza-engine-bd8p44nc/plots
- https://bencher.dev/console/projects/pizza-engine-bd8p44nc/plots
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
title: "Build a Vector Extension for Postgres - Introduction"
meta_title: "Build a Vector Extension for Postgres - Introduction"
description: ""
date: 2024-12-18T08:00:00Z
date: 2024-12-18T16:00:00.000000000+08:00
image: "/images/posts/2024/build_a_vector_extension_for_postgres_introduction/bg.png"
categories: ["vector database", "Postgres"]
author: "SteveLauC"
tags: ["vector database", "Postgres"]
lang: "en"
category: "Blog"
subcategory: "Technology"
draft: false
---

Expand Down Expand Up @@ -85,34 +88,34 @@ $ bat src/lib.rs
│ File: src/lib.rs
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ use pgrx::prelude::*;
2 │
2 │
3 │ ::pgrx::pg_module_magic!();
4 │
4 │
5 │ #[pg_extern]
6 │ fn hello_pg_vector_ext() -> &'static str {
7 │ "Hello, pg_vector_ext"
8 │ }
9 │
9 │
10 │ #[cfg(any(test, feature = "pg_test"))]
11 │ #[pg_schema]
12 │ mod tests {
13 │ use pgrx::prelude::*;
14 │
14 │
15 │ #[pg_test]
16 │ fn test_hello_pg_vector_ext() {
17 │ assert_eq!("Hello, pg_vector_ext", crate::hello_pg_vector_ext());
18 │ }
19 │
19 │
20 │ }
21 │
21 │
22 │ /// This module is required by `cargo pgrx test` invocations.
23 │ /// It must be visible at the root of your extension crate.
24 │ #[cfg(test)]
25 │ pub mod pg_test {
26 │ pub fn setup(_options: Vec<&str>) {
27 │ // perform one-off initialization when the pg_test framework starts
28 │ }
29 │
29 │
30 │ #[must_use]
31 │ pub fn postgresql_conf_options() -> Vec<&'static str> {
32 │ // return any postgresql.conf settings that are required for your tests
Expand Down Expand Up @@ -143,7 +146,7 @@ It will start the Postgres 17 instance and connect to it via `psql`, we can inst
pg_vector_ext=# CREATE EXTENSION pg_vector_ext;
CREATE EXTENSION
pg_vector_ext=# SELECT hello_pg_vector_ext();
hello_pg_vector_ext
hello_pg_vector_ext
----------------------
Hello, pg_vector_ext
(1 row)
Expand Down
Loading