Skip to content

Instantly share code, notes, and snippets.

View AmineDiro's full-sized avatar
:octocat:
Cooking

AmineDiro AmineDiro

:octocat:
Cooking
View GitHub Profile
@AmineDiro
AmineDiro / nsight.sh
Created October 25, 2025 12:43 — forked from mcarilli/nsight.sh
Favorite nsight systems profiling commands for Pytorch scripts
# This isn't supposed to run as a bash script, i named it with ".sh" for syntax highlighting.
# https://developer.nvidia.com/nsight-systems
# https://docs.nvidia.com/nsight-systems/profiling/index.html
# My preferred nsys (command line executable used to create profiles) commands
#
# In your script, write
# torch.cuda.nvtx.range_push("region name")
# ...
@AmineDiro
AmineDiro / schema.sql
Last active June 14, 2025 12:29
Postgres job queue
CREATE TYPE job_status AS ENUM ('pending', 'in_progress', 'done', 'failed');
CREATE TABLE jobs (
id SERIAL PRIMARY KEY,
status job_status NOT NULL DEFAULT 'pending',
payload JSONB,
created_at TIMESTAMP DEFAULT now(),
updated_at TIMESTAMP DEFAULT now(),
visible_at TIMESTAMP DEFAULT now(), -- SQS visibility timeout
retry_count INT DEFAULT 0
@AmineDiro
AmineDiro / Cargo.toml
Created August 2, 2024 06:53
bench_upload_route
[package]
name = "uploader"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.86"
clap = { version = "4.5.13", features = ["derive"] }
futures = "0.3.30"
reqwest = { version = "0.12.5", features = ["multipart", "stream"] }
@AmineDiro
AmineDiro / bench_ws_server.rs
Created March 19, 2024 21:16
Websocket server axum tokio-tungestnite
use axum::{
extract::ws::{Message, WebSocket, WebSocketUpgrade},
response::IntoResponse,
routing::get,
Router,
};
use test_websockets::ClientMessage;
use tracing::{debug, error, info};
use std::net::SocketAddr;
@AmineDiro
AmineDiro / bench_ws_client.rs
Last active March 19, 2024 21:57
Websocket client
use flume;
use futures::future::join_all;
use futures::stream::iter;
use futures_util::stream::FuturesUnordered;
use futures_util::{SinkExt, StreamExt};
use std::borrow::Cow;
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use test_websockets::ClientMessage;
use tokio::fs::OpenOptions;
use tokio::io::{AsyncWriteExt, BufWriter};
@AmineDiro
AmineDiro / fast-client.rs
Created November 6, 2023 22:29
reqwest client
#![feature(array_chunks)]
use std::mem;
use std::time::Duration;
use anyhow::Result;
use bytes::Bytes;
use futures::{stream, StreamExt};
use reqwest::{self, Client};
use serde::Serialize;
@AmineDiro
AmineDiro / soa.rs
Last active October 9, 2023 20:48
Struct of arrays
use rand::Rng;
use std::time::Instant;
const N: usize = 1_000_000;
const N_WARMUP: usize = 100;
struct Shapes {
rectangles: Vec<Rectangle>,
triangles: Vec<Triangle>,
squares: Vec<Square>,
use std::time::Instant;
use rand::Rng;
const N_WARMUP: usize = 100;
static SHAPES_COEFF: [f32; 3] = [1.0, 1.0, 0.5];
const N: usize = 1_000_000;
#[derive(Clone, Copy)]
enum Type {
use std::time::Instant;
const N: usize = 10000;
#[derive(Clone, Copy)]
enum Shape {
Rectangle(Rectangle),
Triangle(Triangle),
Square(Square),
Init,
}
@AmineDiro
AmineDiro / data_oriented.rs
Last active October 10, 2023 13:21
cleancode rust data oriented
use rand::Rng;
use std::time::Instant;
const N: usize = 1_000_000;
const N_WARMUP: usize = 100;
enum Type {
Rectangle,
Square,
Triangle,