Skip to content

Instantly share code, notes, and snippets.

View hpatro's full-sized avatar

Harkrishn Patro hpatro

View GitHub Profile
@hpatro
hpatro / migration-script.sh
Created October 31, 2025 05:55
Redis OSS 7.2.4 to Valkey 9.0
# Create docker network
docker network create valkey-net
# Start Redis OSS 7.2.4
docker run -d --name redis-primary \
--network valkey-net \
redis:7.2.4 \
--appendonly yes
# Start Valkey 9.0
@hpatro
hpatro / client_usage_tracking_optimization
Created October 20, 2022 22:32
Client Usage Tracking Optimization metrics data points
# Run 1 without Optimization (src/redis-benchmark -q -n 100000 -t set -l)
('Current Ops : ', 183523, 'Average: ', 183523)
('Current Ops : ', 183259, 'Average: ', 183391)
('Current Ops : ', 183971, 'Average: ', 183584)
('Current Ops : ', 184736, 'Average: ', 183872)
('Current Ops : ', 184459, 'Average: ', 183989)
('Current Ops : ', 183851, 'Average: ', 183966)
('Current Ops : ', 182509, 'Average: ', 183758)
('Current Ops : ', 182630, 'Average: ', 183617)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hpatro
hpatro / launch.json
Created July 9, 2022 17:43
VS Code Launch target(s)
{
"version": "0.2.0",
"configurations": [
{
"name": "Redis Server Run",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/src/redis-server",
"args": [],
"stopAtEntry": false,
@hpatro
hpatro / tasks.json
Created July 9, 2022 17:42
VS Code Tasks
{
"version": "2.0.0",
"tasks": [
{
"label": "Clean",
"type": "shell",
"command": "make",
"args": [
"clean"
],
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import redis
r=redis.Redis()
p = r.pipeline()
for j in range(100000000):
print("Step #", j)
for i in range(100):
p.mset({"Croatia" + str(i) + str(j): "Zagreb", "Bahamas" + str(i) + str(j): "Nassau"})
p.execute()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hpatro
hpatro / queue_multi_command_opt.c
Last active June 25, 2022 18:27
Queue Multi Command (exp. growth)
/* Add a new command into the MULTI commands queue */
void queueMultiCommand(client *c, uint64_t cmd_flags) {
multiCmd *mc;
/* No sense to waste memory if the transaction is already aborted.
* this is useful in case client sends these in a pipeline, or doesn't
* bother to read previous responses and didn't notice the multi was already
* aborted. */
if (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))
return;
@hpatro
hpatro / queue_multi_command_noopt.c
Last active June 25, 2022 18:28
Queue of command in MULTI/EXEC in Redis
/* Add a new command into the MULTI commands queue */
void queueMultiCommand(client *c, uint64_t cmd_flags) {
multiCmd *mc;
/* No sense to waste memory if the transaction is already aborted.
* this is useful in case client sends these in a pipeline, or doesn't
* bother to read previous responses and didn't notice the multi was already
* aborted. */
if (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))
return;