Git Product home page Git Product logo

Immutable

This isn't true immutability, but effective immutability.

This is an experiment in generically replicating and reviving data, with and without diffs.

Thoughts

Making copies is a good thing. It allows us to know the state of our system at a particular time and to travel back to that point in time selectively or as a whole.

We don't need to colocate our current state with our past state.

Reviving a previous state is necessary, but uncommon, whereas accessing and manipulating the current state will happen constantly.

You can store changes instead of whole records, if space is a concern.

Replay will happen in order, so the copying of states should happen in order.

Copying can be tied to inserting/updating, or can happen asynchronously, to your taste.

Application schemata/structs can change, and you may not want to put an old record into a current schema.

Potential Strategies

  • async Tasks (does not guarantee order)
  • async Queue (guarantees order)
  • sync Multi (links replication)
  • no-diff persistence (requires full record, more space, faster lookup)
  • diff persistence (requires only changes, less space, slower lookup)

Todos

  • Multi functions
  • delete functions
  • ! functions
  • _all functions
  • associations

Metrics

Insert 1 record.

Randomly edit the record 20,000 times.

Insert 20,000 unrelated records.

Edit half of those unrelated records.

Make controlled edits to the initial record.

Begin metrics on table size and time to calculate previous version.

Average across runs.

Method Space used Time to calculate
diff 7680 kb 152 ms
full 10 mb 5 ms
  • Note: the "full" method requires a complete data copy each edit, whereas the "diff" method does not.

Database Instructions

brew services start postgresql

createuser -d postgres

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server

Now you can visit localhost:4000 from your browser.

Anderson Cook's Projects

pfds icon pfds

Purely Functional Data Structures in Elixir

phoenix icon phoenix

Peace of mind from prototype to production

piji icon piji

Erlang OTP 23 pg experiment

prom_ex icon prom_ex

An Elixir Prometheus metrics collection library built on top of Telemetry with accompanying Grafana dashboards

react-slingshot icon react-slingshot

React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app, all built in

scrapbook2 icon scrapbook2

web-development notes and archive of Old articles

synth icon synth

Back end capstone. Synthesizer with web sockets

tic-tac-toe icon tic-tac-toe

Tic Tac Toe with eventual web sockets implementation

tla-plus icon tla-plus

playing along at home with Practical TLA+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.