Skip to content

Instantly share code, notes, and snippets.

@irevoire
irevoire / lib.md
Last active July 27, 2021 11:02
meilisearch lib.rs

MeiliSearch

Hello there, future contributors. If you are here and see this code, it's probably because you want to add a super new fancy feature in MeiliSearch or fix a bug and first of all, thank you for that!

To help you in this task, we'll try to do a little overview of the project.

Milli is the core library of MeiliSearch, it's where we actually index documents and perform searches. It's aim is to do theses two tasks as fast as possible. You can give an update to milli and it'll uses as many cores as provided to perform it as fast as possible. Nothing more. You can perform searches at the same time (search only use one core). As you can see we're missing quite a lot of features here, milli does not handle multiples indexes, it can't queue updates, it doesn't provide any web / API frontend, it doesn't implements dumps or snapshots, etc...

The index module is what encapsulate one milli index. It abstracts over its transaction an

@irevoire
irevoire / main.rs
Last active June 1, 2021 18:12
A fsm you can serialize with serde only on some state
use std::marker::PhantomData;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
struct A;
#[derive(Debug, Serialize)]
struct B;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[derive(Debug)]
pub struct Machin {
pub s: String,
pub a: String,
}
fn main() {
let machin = Machin { s: String::from("s"), a: String::from("a") };
let s = machin.s;
let a = machin.a;
const IDLE1: [u8; 636] = [
0, 0, 126, 126, 24, 60, 102, 66, 0, 12, 28, 112, 112, 28, 12, 0, 116, 116, 20, 20, 124, 104, 0,
124, 124, 0, 112, 120, 44, 36, 124, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 128, 64, 64, 32, 32, 32, 32, 16, 16, 16, 16, 16, 8, 8, 4, 4, 4, 8, 48,
64, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 0, 0, 0, 0, 192, 96, 48, 24,
12, 132, 198, 98, 35, 51, 17, 145, 113, 241, 113, 145, 17, 51, 35, 98, 198, 132, 12, 24, 48,
96, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 100, 130, 2, 2, 2, 2, 2, 1,
0, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 48, 48, 0, 192, 193, 193, 194, 4, 8,
16, 32, 64, 128, 0, 0, 0, 128, 128, 128, 128, 64, 64, 64, 64, 32, 32, 32, 32, 16, 16, 16, 16,
exception Error of string
type 'a node =
| Cons of { current: 'a; next: 'a node }
| Nil
module Node = struct
let empty = Nil
let add a b = Cons { current = a; next = b }
@irevoire
irevoire / prout.md
Last active December 8, 2019 16:19
aoc

--- Day 8: Two-Factor Authentication ---

You come across a door implementing what you can only assume is an implementation of two-factor authentication after a long game of requirements telephone .

To get past the door, you first swipe a keycard (no problem; there was one on a nearby desk). Then, it displays a code on a little screen , and you type that code on a keypad. Then, presumably, the door unlocks.

Unfortunately, the screen has been smashed . After a few minutes, you've taken everything apart and figured out how it works. Now you just have to work out what the screen would have displayed.

The magnetic strip on the card you swiped encodes a series of instructions for the screen; these instructions are your puzzle input. The screen is 50 pixels wide and 6 pixels tall ,

@irevoire
irevoire / py
Created December 3, 2019 13:29
draw python
import sys
import numpy as np
import scipy.stats as stats
from scipy.fftpack import fft
import matplotlib.pyplot as plt
import sys
if len(sys.argv) < 2:
print("mettre le nom du / des fichiers en argument")
sys.exit()
@irevoire
irevoire / phd
Last active October 8, 2019 12:43
Title:
Reoptimizing meta-tracing
Synopsis:
Meta-tracing enables virtual machines (VMs) to decide which part
of a program should be optimized. When a VM gets some code to execute, it
needs to convert the code to instructions that can be executed on the
hardware. The VM can either convert the code to assembly or try to
optimize the code before generating assembly. Optimizing code is an
expensive operation; that is why most VMs usually identify ahead which
portion of code could be worth optimizing (in the sense that you would
@irevoire
irevoire / showily.c
Created October 2, 2019 14:09
son truc
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define panic(s) \
{ \
perror(s); \
exit(-1); \
}
@irevoire
irevoire / bash.sh
Created July 16, 2019 16:45
snabb apps/intel_mp/selftest.sh
% sudo SNABB_PCI_INTEL0=0000:04:00.0 SNABB_PCI_INTEL1=0000:04:00.1 apps/intel_mp/selftest.sh
Using deterministic random numbers, SNABB_RANDOM_SEED=2896935582.
Using deterministic random numbers, SNABB_RANDOM_SEED=2896935582.
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 34 -> 35]
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 35 -> 36]
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 36 -> 37]
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 37 -> 38]
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 38 -> 39]
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 39 -> 40]
[memory: Provisioned a huge page: sysctl vm.nr_hugepages 40 -> 41]