Serpent7776

joined 2 years ago
 

I encounter memory corruption issue at work coming from a signal handler and decided to write a blog post about it. Feedback welcome.

 

This allocates required number of pages using mmap, fills it with AMD64 instructions, changes the memory protections and execute the memory as code.

This works fine on my machine, but I'm not sure if it's guaranteed to work in all cases. I assume it's safe to execute arbitrary asm code from OCaml. I'm not sure if the conversions I do are valid.

 

Example usage:

-- Register with default settings (41 timestamp bits, 10 type bits, 12 counter bits)
CALL snowflake.register('user_id');

-- Generate a user ID
SELECT snowflake.generate_user_id(now(), 1, 1);

-- Register with custom bit allocation
CALL snowflake.register('order_id', 42, 8, 13);

-- Generate an order ID with specific type and counter
SELECT snowflake.generate_order_id('2023-12-01 10:30:00 UTC', 5, 1000);
[–] Serpent7776@programming.dev 1 points 7 months ago

AFAIK you can't do this with BPF as it doesn't have any kind of sleep functionality. I'm also not sure how would you achive this using cgroup, which are about quotas AFAIK.

 

Crawlio is a simple C tool that slows down I/O operations by adding a specified amount of time to each I/O call. It uses LD_PRELOAD.

  • Test application behaviour under slow I/O conditions
  • Bring back the dial-up nostalgia
  • Learn how to use LD_PRELOAD
 

I'm doing an extension that creates a pool of named background workers. Happy to hear any feedback on this.

CREATE EXTENSION pg_worker_pool;
CALL worker_pool.submit('foo', 'create index myindex_1 on my_big_table (id)');
CALL worker_pool.submit('foo', 'create index myindex_1 on my_big_table (name)');
CALL worker_pool.submit('bar', 'create index otherindex_2 on other_big_table (author)');
CALL worker_pool.submit('bar', 'create index otherindex_2 on other_big_table (title)');

This will start two background workers, foo and bar. foo will create an indices on table my_big_table and bar on table other_big_table. foo and bar will run independently of each other, but all indices submitted to the same worker will be created in order.

 

I wrote a blog post comparing several range libraries for a case that is doing filter with non-trivial lambda and then reverse.

 

A blog post shows an example usage of hyperfine CLI tool to measure and plot time of startup and shutdown of several code interpreters.

 

I created a very simple script that shows the history usage of your shell. Should work with bash and fish shells.

This basically goes through the history and counts the command names. So all of git push, git pull, etc will count as just git.

Example output:

    847 pacman
    296 cd
    206 git
    203 time
    180 vim
    172 awk
    166 aur
    142 strace
    141 cat
    125 ls
Total commands:  7008
Unique commands: 753
view more: next ›