Alfonso Villalobos (@chatocv12) header
Alfonso Villalobos (@chatocv12) profile picture
Joined October 2010
Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)Photo by Alfonso Villalobos (@chatocv12)
Alfonso Villalobos retweeted
En México ya no se debe viajar de noche y de día es un albur.
994
3,332
336
48,379
12,955,920
Alfonso Villalobos retweeted
I patched my phone kernel to enable systemd and Linux namespaces so now it runs NixOS alongside Android (no VM) and can be connected to a remote monitor. Its chip is faster than my Macbook M2 so if I fix the GPU my computer should soon fit in my pocket github.com/th0rgal/omarchnix
88
115
18
2,396
87,821
Alfonso Villalobos retweeted
electrical engineer here! this guy needs to be in a mental institution!
Horas soldando y al final… sigue sin mandar video 😔😩
157
1,562
22
35,668
672,670
Alfonso Villalobos retweeted
"What are you doing?" - "Oh just playing a Switch game."
272
3,589
258
42,893
1,882,250
Alfonso Villalobos retweeted
You should be fascinated hitting the power button on your computer. Every boot on an x86 machine iterates through the entire sequence of computing evolution in a few milliseconds: Stage 1: 16-bit Real Mode, acts like an 8086 from ~1978. 500ns (ish); about 15-30 instructions. Goal of this stage is to create a writeable stack+heap. Stage 2: 32-bit Protected Mode, acts like a 386 from ~1985. Tens of millions of instructions; takes forever on DDR5 /w memory training. Temporarily uses L2/L3 “cache-as-ram” to kickstart main ram (Intel calls this NEM). Stage 3: 64-bit Long Mode, acts like AMD64 from ~2003. Hundreds of millions of instructions; enumerate pcie devices, gpu, bootloader, etc. Stage 4+: Secondary core wakeup. Every *single* core has to go through the same process, but by this point it’s faster because Main RAM is warmed up. Stage 2 is just so neat man. Quite literally the same concept as an APU/cart start. Use the smaller motor (L2/L3) to kickstart the main turbine (Main Ram) and execute the training process. Is that not just the coolest thing? Next time I’m annoyed waiting at the DDR5 training process, I’m going to imagine it’s spinning up SR71 turbines.
126
451
43
6,653
141,017
Alfonso Villalobos retweeted
De entre todas las fotos que podía haber usado, eligió la de variables de entorno con las cadenas de conexión a bases de datos. Buena elección Un backup en Twitter :)
Solo los que trabajamos remoto podemos hacer esto 😁
25
55
6
921
113,490
“Squirtle” Por este auto que se puso un pokemón que “mea” a todos los que le tocan bocina.
118
3,727
325
52,969
2,293,849
Alfonso Villalobos retweeted
You get a spoon every time you have to do a hotfix in prod
2
12
804
Alfonso Villalobos retweeted
12-hour timelapse of American Airlines, Delta, and United plane traffic after what was likely the biggest IT outage in history forced a nationwide ground stop of the three airlines.
1,052
18,872
2,841
96,996
14,591,304
Alfonso Villalobos retweeted
how I squeeze 60K RPS out of SQLite on a $5 VPS: There are tons of tutorials on how to setup SQLite, and sometimes they contradict each other. Here is what worked for me. 1. Configuring PRAGMAs. We need to send the following PRAGMA commands right after opening the connection: PRAGMA journal_mode = WAL; - enables write-ahead log so that your reads do not block writes and vice-versa. PRAGMA busy_timeout = 5000; - sqlite will wait 5 seconds to obtain a lock before returning SQLITE_BUSY errors, which will significantly reduce them. PRAGMA synchronous = NORMAL; - sqlite will sync less frequently and be more performant, still safe to use because of the enabled WAL mode. PRAGMA cache_size = -20000; - negative number means kilobytes, in this case 20MB of memory for cache. PRAGMA foreign_keys = true; - because of historical reasons foreign keys are disabled by default, we should manually enable them. PRAGMA temp_store = memory; - moves temporary tables from disk into RAM, speeds up performance a lot. Do NOT use cache=shared! Some tutorials recommend configuring it, but this is how you get nasty SQLITE_BUSY errors. It is disabled by default, so you don't have to do anything extra. 2. Use immediate transactions If you know that transaction can possibly do a write, always use BEGIN IMMEDIATE or you can a get SQLITE_BUSY error. Check your framework, you should be able to set this at the connection level. 3. Open two connection pools Another trick is to open 2 connection pools, one for reads only and another for reads/writes. Set the connection limit of write pool to 1, and the connection limit of the read pool to some reasonably high number, e.g. number of your CPU cores. 4. Bonus: how I configure sqlite with Go Here is the code in go I use to configure the sqlite connections: ```go func SQLiteDbString(file string, readonly bool) string { connectionParams := make(url.Values) connectionParams.Add("_journal_mode", "WAL") connectionParams.Add("_busy_timeout", "5000") connectionParams.Add("_synchronous", "NORMAL") connectionParams.Add("_cache_size", "-20000") connectionParams.Add("_foreign_keys", "true") if readonly { connectionParams.Add("mode", "ro") } else { connectionParams.Add("_txlock", "IMMEDIATE") connectionParams.Add("mode", "rwc") } return "file:" + file + "?" + connectionParams.Encode() } func OpenSqliteDatabase(file string, readonly bool) (*sql.DB, error) { dbString := SQLiteDbString(file, readonly) db, err := sql .Open("sqlite3", dbString) pragmasToSet := []string{ "temp_store=memory", } for _, pragma := range pragmasToSet { _, err = db.Exec("PRAGMA " + pragma + ";") if err != nil { return nil, err } } if readonly { db.SetMaxOpenConns(max(4, runtime.NumCPU())) } else { db.SetMaxOpenConns(1) } return db, nil } ```
26
131
15
1,599
224,103
Alfonso Villalobos retweeted
219
7,609
273
181,345
5,295,307
Alfonso Villalobos retweeted
So I started using SQLite as a database for my side project, and I want to share my experience so far: 1. It is fast. Like really fast. My architecture is a monolith written in Go (this is intentional, I sacrificed scalability to improve my shipping speed), and this is where SQLite shines. With a DB located on the local NVMe disk, a 5$ VPS can deliver a whopping 60K reads and 20K writes per second. No other database is even close. 2. Backups are simple. There is project called litestream, and it provides real-time replication to an S3 bucket. With this I get point-in-time recovery with 1 second replication lag for pennies/month. 3. Pairs well with monolithic architecture. Because SQLite is embedded in your backend, N+1 queries are not a problem, e.g. you can fetch a user, and then based on the user_id fetch more data from the database. The latency is so small so you can join directly in your application and speed up your shipping speed. Overall I'm quite satisfied. SQLite seems amazing for all use cases that can fit on a single server. The only tricky part is setting up the SQLite configuration right. The correct values for journal_mode, busy_timeout, and synchronous pragmas are essential to get good performance. Shall I write a post about configuring SQLite to run on a server?
87
123
15
2,277
333,332
Alfonso Villalobos retweeted
I was surprised to see The Wire down at #6 on the list of best shows of all time. Guess it's time to watch Breaking Bad.
8,210
3,996
5,363
55,289
16,848,555
Alfonso Villalobos retweeted
Slack uses Apache Kafka at scale: • 6.5 Gbps • 700TB of data • 100s of nodes Here's their fun story 👇
18
212
25
1,692
518,402
Alfonso Villalobos retweeted
Skeletor is sharing some life changing advice 😂
148
1,464
111
12,109
900,942
Alfonso Villalobos retweeted
Size of this Flemish giant rabbit 📹 donizete_teixeira_barbosa xitter.cf/Visionaledge/status/17…
790
2,187
3,225
20,372
19,362,312
The tables have turned
526
16,561
939
139,688
10,507,440
Alfonso Villalobos retweeted
100
6,226
154
84,848
2,130,602
Alfonso Villalobos retweeted
Your periodic reminder that less ice at the Arctic is consistent with a weaker jet stream that allows cold air to drift down into the Great Plains. The frigid temps you're experiencing happen BECAUSE of a warming planet, not in spite of it.
1,031
8,670
482
30,136
1,771,140