Diary · #code · Page 2

September 17, 2024

Implemented view rendering today for uExpress. Added a bunch of tests for popular view engines.

Fixed next() for .param and bunch of other routing issues.

Now only express.static() and res.sendFile options left and it’s done!


Finally played Yume 2kki again. We’ve decided to go on Expedition. Expedition went through Amoeba Woods, so we’ve got to visit this beautiful place again.

Expedition destination was a pretty boring place, so we just continued going into random places. We’ve found some pillar world and some person chilling in front of entrance to a new place.

1000018313.png

A new place was Downpour (Rain World!!!), the only thing that world had was 2 powerlines and endless rain and lightning. The lightning effect was really nicely done. Probably the best I’ve seen out of all games I’ve ever played.

After that we found our Final Destination: Rainy Sundial.

1000018314.jpg

Looking up, you can see beautiful cherry blossom tree. Using Rainbow effect, you can stop the rain and Blossom will become more colorful, and on the right side a new Main Menu theme unlocks. It’s probably our deepest world so far, being more than 10 worlds deep. It feels rewarding to find something at the end of the journey.

September 16, 2024

Windy weather is so rare for some reason lately. I woke up and it was a really nice wind, so I went outside for a walk. I went to a park, sat down in front of a river and ████████████████████████████████████████████████████

████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

██████████████████████

Spent the day optimizing uExpress even more. Few things I did:

  • switched from PassThrough to Writable (+2.5k)
  • wrote a tiny pipe for Request instead of Readable (+2.5k)
  • now only reading body on non-GET requests (+10k)

In general, on simplest requests speed went from 55k to 70k. Also implemented req.fresh.

image.png

Tags: #code

September 15, 2024

██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Huge day for uExpress:

image.png

Implemented almost all app settings, refactored routing, fixed baseUrl and implemented body reading. I didn’t even really had to code body parsers, just made Request extend Readable stream and it worked with Express’s middlewares. Very nice feeling. Cookie parser also worked with no changes except for signing cookies.

Tags: #code

September 14, 2024

██████████████████████████████████████████████████████████████████████████████████████████████████████

█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████


██████████████████████████████████████████████████████████████████████████████████████████████████████████████████ Implemented piping into res and res.sendFile.

At first I implemented sendFile using only streams, and speed was about 13k/sec. In comparison Express has 4k/sec. Then I’ve decided to split the mechanism into 2 parts:

  1. If file is less than 64 KB in size, just read it with readFile and send (since streams read file in 64 KB chunks anyway, useless overhead).
  2. If file is over 64 KB create a read stream and pipe into response, like before

This made it go to ~18k/sec. While playing around with readFileSync I realized that it’s much faster - 25k/sec, but I really didn’t work to play around with sync on main thread, so I’ve decided to experiment a bit with workers, and it worked out better than I expected! Speed is now 30k/sec, I finally found a good use for workers.

Basically finished implementing res.

image.png

Tags: #code

September 13, 2024

Spent the day implementing APIs. Finally no more routing… For now.

image.png

Getting quite green now. Hopefully it’ll be in actually usable state soon. While coding this, I’ve noticed that creating Buffer and then checking it’s underlying ArrayBuffer with Buffer.buffer showed completely different content and size.

image.png

It made me extremely confused, and I actually thought I found a Node.js vulnerability, but apparently it’s expected behavior. But it’s VERY weird. You can read and write into completely random Buffers you usually shouldn’t have any access to.

█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Tags: #code

September 12, 2024

Quite a lot of progress on uExpress today. Added a lot of Request APIs, and then spent the night trying to optimize routing.

If path is simple (just a string), it’s possible to precalculate the path request would go through. This is what I did initially, and it raised speed from 20k/sec to 27k/sec at 1000 routes. But then I realized, I can then create actual uWS routes when route is simple and just use that precalculated path. And that significantly increased speed. It’s now 61.66k with 1000 routes and 90k/sec with 1 route. And 1000 routes + 1000 middlewares is now 26k/sec instead of 3k/sec. Great progress so far. Tomorrow I’ll have to also make it work with routers too, as right now it only optimizes paths for top application only.

image.png

Tags: #code

September 9, 2024

Continued coding uExpress today. Managed to implement Routers, which were really hard. Not gonna lie, I almost gave up but somehow did it (though idk if they really work properly in all cases…)

image.png

They’re pretty slow though. Nested router brings down speed to like 55k/sec. Normal request rate is about 85k/sec.

Finally played Yume 2kki again. Explored computer-y parts of it today, one of them was a maze (Data Stream) with a secret and cool music.

image.png

September 8, 2024

█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Recently I’ve realized how line between sleeping and being awake is very blurry for me. I can be extremely energetic and then in 5 minutes already falling asleep.

Today I’ve started coding µExpress - hopefully a drop-in replacement for Express, with much better performance.

So far, it’s going unexpectedly well. I did a benchmark, and it’s 9X faster than normal Express.

1000018151.png

Express: 10k/sec µExpress: 92k/sec µWS: 106k/sec

Along the way making tests, and so far implemented following features:

image.png

Tags: #code

September 2, 2024

Day started from me seeing that my website, services, Nekoweb and everything else was down. Apparently Contabo was having some issues in their datacenter, and I think this was the last stretch for me. While my VPS was usually fine and rarely had any issues, Nekoweb’s one constantly gets random freezes from time to time, and Nekoweb being down for 10 hours is just unacceptable.

I was meaning to do it for a long time, and this has finally made me get an actual dedicated server for Nekoweb. I browse Hetzner auction very often, but it seems to keep having same-ish servers with not very good specs, at the minimal range of price.

So I’ve decided to look for more expensive options, and found a pretty good server for it’s price. Quite modern CPU (2019), 6x2 TB of storage, 64 GB of RAM.

As I was ordering it, something unbelievable happened! Price of the server changed in my eyes, and now it had the minimal price. I was checking the auction (it’s Dutch style) quite often throughout the months, and I’ve never seen server this good to be sold at this price, so I hurried and ordered it. Now I have this server for same price as all other, much worse servers. I plan to move all my sites and services to it, not just Nekoweb, since it has more than enough specs for everything.

GWeX9_AWYAAep95.png

This is so beautiful, I’ve never seen htop so big…

I then installed Ubuntu on the server. And then realized I need to get RAID1, so installed it again with RAID1. And then realized I did it with wrong partitions, so installed it again…

image

RAID1 sync is taking a very long time, so I can’t really do anything with server while it’s going, since it’s just too slow.

In mean time, my brother visited me, and we talked about what’s going on in our life. █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Played more Yume 2kki with friends. Got all of the effects now, so I’m finally truly free to explore the world. At the end I have rested in my favorite place so far - Sewers.

image

It’s my element.

1 [2]