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

artie icon artie

Programming WebRTC (with Elixir/Phoenix and SolidJS)

channel_order icon channel_order

Example Phoenix Application where channel order is reversed

credo icon credo

A static code analysis tool for the Elixir language with a focus on code consistency and teaching.

dead icon dead

Building something in Elixir with Phoenix LiveView and OTP (eventually distributed)

ecto icon ecto

A toolkit for data mapping and language integrated query.

elisp icon elisp

building a terrible lisp with leex, yecc, erlang, and elixir

elixir icon elixir

Elixir is a dynamic, functional language designed for building scalable and maintainable applications

elm-pfds icon elm-pfds

Purely Functional Data Structures in Elm with UI

failed-umbrella icon failed-umbrella

Individual apps will not compile if there is a . in the folder name

fast-elixir icon fast-elixir

:dash: Writing Fast Elixir :heart_eyes: -- Collect Common Elixir idioms.

filter_map icon filter_map

various implementations of filter_map + benchmark & tests

flippant icon flippant

:traffic_light: Feature flipping for the Elixir world

hawaii icon hawaii

the hawaii game but in elm instead of react

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.