defmacro
  • Introduction 👋
  • Work 🎖
    • Building a graph viz 🔥
    • Accidentally building mirrors🪞
    • Improving my dev workflow - Save thy memory ⚡️
    • Portfolio website
  • 💻Clojure
    • Why?
    • Rationale
    • Simple made easy ⚡️
    • Specter ⚡️
    • Style guide, quick links
  • 📥Learning Model
    • Overview
    • Discovery ⚡️
    • Organization
    • Beat the Forgetting Curve
  • 📥Papers
    • Out of the Tar Pit ⚡️
  • Archives
Powered by GitBook
On this page
  • Problem
  • Solution
  • Links

Was this helpful?

  1. Work 🎖

Improving my dev workflow - Save thy memory ⚡️

PreviousAccidentally building mirrors🪞NextPortfolio website

Last updated 4 years ago

Was this helpful?

Problem

For my dev flow, I need to run a backend server, for frontend hot loading, and a database. For the uninitiated, each of them is running on a different JVM and now add IntelliJ(curse me for not learning Emacs), a with a million tabs, , Slack, Zoom and there's no difference between a toaster and Macbook.

Although you can control the JVM memory usage, it's easy to run into memory issues and I'm yet to find a decent balance between performance and memory usage.

macOS extensively uses swap to address memory overflow but SSD's lifespan decreases with each write and more importantly, it's slower than RAM, which results in slower operations and workflows.

Solution

Reduce the memory allocation pool by tuning JVM with

Putting all things in a server

Get your code on a which gives you 2CPUs and 4 gigs of RAM. I found this enough and just in case. Setup your Nginx ssl and certificates if any and start the servers.

Connecting to remote machine

You don't want to swap local URLs with server URLs and run the whole process; there's something better i.e . Start port forwarding with this:

ssh -L port-local-1:localhost:remote-port-1 -L port-local-2:localhost:port-local-2 root@server-ip

Every request to localhost:port-1 will forward to server's port-1

Syncing changes

Now for every change you make to your IntelliJ you want to see your changes hot loaded. All intelli-j products have . File watchers allow you to run a script when a file is saved, which is exactly what we need. Add a file watcher which your local codebase to remote. A couple of lines of bash

#!/usr/bin/env bash

cd ~/Documents
rsync -av proj/ root@server:~/a-folder --delete --exclude=exclude-folder/

And that's it.

Tip: Don't forget to forward your nrepl ports as well.

Although this is very specific to Clojure the key idea is to use an additional dedicated system for your computation and make it seem like your local machine is the dedicated machine.

Skip upgrading to an expensive macbook and get a cheap server(take advantage of promo credits😬)

Links

ring
figwheel
datomic
browser
Spotify
Xms option
20$ machine
added more swap
ssh port forwarding
file watchers
rsync's
IntelliJ IDEA
Ring Clojure
Figwheel
Brave browser
Linode Pricing
SSH port forwarding
File watchers—IntelliJ IDEA
Rsync local to remote
Cadjak
CM