Better HN
topnewbestaskshowjobs
Log inSign up

dustingetz

7,912 karma · joined Sep 11, 2009 (17y ago) · 3,625 submissions

Founder Electric Clojure https://github.com/hyperfiddle/electric

https://twitter.com/dustingetz

Submissions

comment 9y ago · link · parent

wow, thanks

comment 9y ago · link · parent

What is the scroll bug exactly, or are you referring to the perf problems?

comment 9y ago · link · parent

our renders are compute heavy because it is so dynamic (most of today's apps aren't). Think of it this way. Virtual DOM is like a spreadsheet. You only want to recompute the stuff downstream of what's changed. That's basically what React's render-tree pruning is all about. But there are a couple problems.

First, naive server rendered React isn't diffing anything at all, it recomputes the whole virtual dom from scratch every time. So there isn't any render-tree pruning since we're not doing a diff. That's what the walmart-labs patches help with, since obviously a lot of SSR'ed components aren't changing between SSRs, that can be reused, and we can be fast again.

Second, React.js views are more than just banging html together, it also has to call a bunch of functions as part of that process. For example client side sorting, or map/reduce/filter. So if those functions are expensive, your views are slow, even if the html itself isn't all that complex.

Third, since much of our "view rendering" cost is actually computation not directly related to making html, React can't reuse pieces of those computations anyway. You'd need to code your "math" in terms of React components even though there's no html associated with them.

Fourth, if your dataflows are dynamic enough, like a spreadsheet, even if React actually could optimize those computations (which it cant), it wouldn't even be helpful, because while Views are trees, many computations are not. For example, in a spreadsheet: Edit cell C7, quick what is the tree of computations you can skip? The question doesn't even make sense, because spreadsheets aren't trees. Spreadsheets do complicated graph dependency tracking, with cycle analysis and all that, in order to make this fast. React doesn't do that.

As an example of how dynamic Hyperfiddle is, go to http://dustingetzcom2.hyperfiddle.net/ and in the top toolbar click "data" and then click "dev". Dustingetzcom2 is not coded in javascript, its coded in data, and you edit the data live in the dev pane, and the right things update live as you make changes. That's why the render computation is so expensive.

comment 9y ago · link · parent

Not really, I'm the consultant people hire when they need to solve issues like this. There are some screenshots of what we're doing here: http://www.hyperfiddle-consulting.com/ http://hyperfiddle.net/

As I said, our app is sophisticated

comment 9y ago · link · parent

It's a real issue, my startup's react SSR times are ~5 seconds of blocking the node thread on my $40 droplet. It's about 50% react. Our pages are way more sophisticated than your average page with like a query and a form, though. There are many ways to make faster though, one of which is to simply configure your CDN properly.

comment 9y ago · link · parent

https://github.com/walmartlabs/react-ssr-optimization

React definitely needs work here and i think the right people are quite aware of the issues.

comment 9y ago · link · parent

"2020s" e.g. 2028

Apps are like moores law; every 1.5 years the sophistication doubles.

comment 9y ago · link · parent

That's super interesting. I dont think React is the end state; it has a couple warts that are solved in research communities.

TLDR React is not efficient enough, the performance requirements of next-gen apps of 2020s is going to break React because rendering is not incremental. These warts are basically places where React departs from pure functional programming to achieve ease of use.

1) Fundamental performance problem in render-tree-pruning (it is not truly reactive, it does more work than necessary). This is not an issue today except in the most sophisticated apps, but in apps of the 2020s it's going to be a huge problem. My startup http://hyperfiddle.net/ spends a great deal of energy trying to make React faster, it all boils down to forceUpdate which breaks the "functional programming" philosophy and makes the programming model significantly worse.

2) The solution to (1) is a reactive, spreadsheet-like programming model that generalizes to more than just the View-as-a-function, but also to the rest of the functions. React's solution injects fat "Component" instances everywhere in the view; its not actually just functions, so it breaks for the other expensive computations in the app, which will also need to be optimized in the 2020s.

https://github.com/slamdata/purescript-halogen is the best shot i know of at solving all this; it may be 5 more years yet until this is simplified enough to become mainstream, but all-in-all the ever increasing complexity of apps means truly efficient rendering is inevitable, and React is not that.

comment 9y ago · link · parent

Where are the engineering recruiting channels? Can't find anything except corpspeak blah blah that isnt even meant to be read

comment 9y ago · link · parent

I think there's a stateful load balancer polling every replica

"By routing read operations only to replicas that are caught up enough to run them accurately"

"To save every api process from having to reach out and check on the replication status of every replica for itself, we’ll have a process called an observer that periodically refreshes the state of every replica and stores it to a Postgres table. ... Keep in mind that this status information could really go anywhere. If we have Redis available, we could put it in there for fast access"

"The observer runs in a loop, and executes something like this on every iteration"

Also, "The technique is inspired by GitLab’s article on scaling their database, where they refer to it as 'sticky connections'"

comment 9y ago · link · parent

If I understand this right, they can guarantee fresh point reads. But an actual query needs a consistent snapshot of all entities (rows) under consideration for the query. ... for all of the "hundreds of queries a mature application might execute to fulfill a single request". You need a snapshot of the entire database (like git)

FTA "When mutating a resource in the system we’ll store the last committed log-sequence-number for the entity making the request"

This is what Datomic does by design, if you need infinity read scaling and perfect consistency just use that, and you get a host of other benefits (the replica is inside your application process, like a data structure, which has profound architectural consequences, for example you can query in a loop so N+1 problem is solved).

comment 9y ago · link · parent

thank you for that link !!

comment 9y ago · link · parent

Useless like git? :) Immutable here just means append-only. If old history is fixed it is really easy to have pervasive caching, which helps make chatty queries faster (e.g. solve N+1 problem)

comment 9y ago · link · parent

Parallel but consistent indexes could be done in a single process too. The tradeoff is natural reads at the cost of extra constant factor of write computation and storage.

Which is exactly the tradeoff RDBMS indexes already make.

comment 9y ago · link · parent

This is great, thanks. I think the issue is, things quickly turn bullshit.

Programming math is high school stuff, but imperative programming is bullshit. Memory leaks. Exceptions. Callback chaining. Asynchrony. Model-change listeners. Spooky action at a distance. Legacy interfaces.

Functional programming fixes all that.

Programming excel is college stuff. RDBMS is bullshit. JOIN pain, batching vs caching, ORM, pressure to denormalize for performance at scale, eventual consistency at scale. Non-RDBMS solutions generally make sacrifices regarding ACID vs consistency vs performance. Bullshit.

Immutability in the database fixes that too.

comment 9y ago · link · parent

You actually don't need to have the same storage data layout if you use a time series as a starting point; because you can maintain different data layouts in parallel, and the time dimension permits strong consistency across them all.

If this is what you mean by a "database frontend", I am really confused as to why you object to this?

I think this property of time series is going to prove very important in the 2020s

comment 9y ago · link · parent

My questions were in the context of effective caching in the query process, sorry that wasn't clear. A process on a single machine somewhere has to get enough of the indexes and data into memory to answer questions about it. Though I guess there are other types of queries you might want to do, like streamy mapreduce type stuff that doesn't need the whole log.

I will have to think about if a key-value-time storage backend would have any implications in Datomic. One thing Datomic Pro doesn't have is low-cost database clones through structure sharing, and it doesn't make sense to me why.

Here is a description of some storage problems that arise with large Datomic databases, though it's not clear to me if ZLog can help with this < http://www.dustingetz.com/ezpyZXF1ZXN0LXBhcmFtcyB7OmVudGl0eS..., >

comment 9y ago · link · parent

A lot of stuff in those links that I'm not familiar with. I'd expect challenges around what will happen when the log doesn't fit in memory? What if even the index you need doesn't fit in memory? If I understand, zlog is key-value-time, so I'm not sure what type of queries are interesting on that. Datomic is essentially a triple store with a time dimension so it can do what triple stores do. What do you think the use cases are for a key-value-time store?

comment 9y ago · link · parent

That's a question for the mailing list, but IIRC the new product "Datomic Cloud" (aws-native rewrite) does this out of the box. Datomic Cloud isn't out yet but Cognitect says 2017 Q4. https://www.youtube.com/watch?v=Ljvhjei3tWU

comment 9y ago · link · parent

Datomic is my default choice for any data processing software (which is almost everything).

Immutability in-and-of-itself is not the selling point. Consider why everyone moved from CVS/SVN to Git/dvcs. The number of people who moved to git then and said "man I really wish I could go back to SVN" is approximately zero. Immutability isn't why. Git is just better at everything, that's why. Immutability is the "how".

I don't see why I would use an RDBMS to store data ever again. It's not like I woke up one day and started architecting all my applications around time travel†. It's that a lot of the accidental complexity inherent to RDBMS - ORM, N+1 problems (batching vs caching), poorly scaling joins, pressure to denormalize to stay fast, eventual consistency at scale...

Datomic's pitch is it makes all these problems go away. Immutability is simply the how. Welcome to the 2020s.

†actually I did, my startup is http://hyperfiddle.net/

comment 9y ago · link · parent

Yes! "code/data locality" is key for real apps.

Everyone has seen "numbers every programmer should know" < https://gist.github.com/jboner/2841832 > If you're going to do complex data analysis, e.g. machine learning, you want your data access latency to be on the short end of this chart :) When you end up on the long end (like in RDBMS) this is known as N+1 problem.

But modern size data doesn't fit into memory. Distributed systems necessarily add latency, and to fix that we add caching, which hurts consistency. I blew up this thread further down about how Datomic's core idea is to provide consistent data to your code; which is the opposite of how most DBMS (including kbd) make you bring the code into the database.

comment 9y ago · link · parent

It's definitely not new, but it is innovative. Kafka can totally be an implementation detail of a system like what we are discussing. Once you're immutable, we're no longer constrained to a single "actual representation of data"; you can maintain many in parallel, so long as there is a way to keep the representations consistent (that time dimension is really important!)

CQRS has the right fundamental constituents but puts them together in the wrong way, I think. The command abstraction is in the application layer (we're talking about stores not apps) and the properties of the read-side are fixed (e.g. decisions about document-orientation, column- or row- are coded in advance). But those same parts can be used to make something more flexible, that lets the properties of the read-side be less fixed.

Datomic maintains multiple builtin indexes to support several query styles (so multiple parallel "representations of data") < http://docs.datomic.com/indexes.html >, so Datomic has native support for querying in the shape of: documents, rows, columns, time, values. The storage is actually represented all those ways in parallel copies. (and yet the time dimension keeps us linearized and strongly consistent, like git!)

More interesting than the builtin indexes though, is that you can conceptually implement your own index, since immutability lets you distribute/cache the data in your application processes, the query engine is actually a library running in your query process. (Datomic Datalog is literally a jar file running in your elastic app processes and it works on vanilla JVM data structures)

This is called "code/data locality" and it's extremely powerful. You don't need to go fork the database codebase to add a new type of index, like people had to do to add geospatial index to a fork of Postgres. You can incrementally maintain your own indexes. You can ignore datalog and implement your own query functions to query your special index. Or you can seamlessly compose your own query functions inside datalog queries, you can pass your index as an input to a datalog query. Here's a snippet of what that looks like: https://i.imgur.com/GJuTkJR.png

comment 9y ago · link · parent

Both what you write and what I wrote are true.

To scale writes you shard writes. This generally means running multiple databases (in any DBMS)

The key insight is that Datomic can cross-query N databases as a first class concept, like a triple store. You can write a sophisticated relational query against Events and Photos and Instagram, as if they are one database (when in fact they are not).

This works because Datomic reads are distributed. You can load some triples from Events, and some triples from Photos, and then once you've got all the triples together in the same place you can do your queries as if they are all the same database. (Except Datomic is a 5-store with a time dimension, not a triple store.)

In this way, a Datomic system-of-systems can scale writes, you have regional ACID instead of global ACID, with little impact to the programming model of the read-side, because reads were already distributed in the first place.

For an example of the type of problems Datomic doesn't have, see the OP paragraph "To sort, or not to sort?" - Datomic maintains multiple indexes sorted in multiple ways (e.g. a column index, a row index, a value index). You don't have to choose. Without immutability, you have to choose.

comment 9y ago · link · parent

In RDBMS, when you shard, read shards and write shards are in lock-step, which is the whole problem with sharding. In Datomic (and in git), by sharding writes, it doesn't really impact reads.

This is interesting, because consider a large system like Facebook. Transactions naturally fall within certain boundaries. You never transact to Events, Photos, and Instagram all at once - from the write side, they don't have to share the same single-writer process delivering ACID.

You do however, on the read side, need to have fluid queries across them all, as if they were one database. RDBMS can't do that, but Datomic can, and Git can too - consider submodules. Immutability is what makes it possible to shard like this without sacrificing query expressiveness, strong consistency or ACID (like every other distributed system that isn't accumulate only)

comment 9y ago · link · parent

Datastore of 2020s will be designed around an immutable log because it permits both strong consistency and horizontal scaling (like git).

Once you're both distributed and consistent, the problems today's stores are architected around, go away. Your distributed queries can index the immutable log however they like. column-oriented, row-oriented, documents, time-oriented, graphs, immutability means you can do all of it, as a library in your application process

http://www.datomic.com/ - it's what you get when Facebook's graph datastore has a baby with immutability.

comment 9y ago · link · parent

Just wrote this in r/clojure hth https://www.reddit.com/r/Clojure/comments/7a4qxp/dueling_rhe...

RH already gave a great nontechnical introduction in the EDN talk in 2012, I linked you a transcription of it upthread

comment 9y ago · link · parent

EDN is much more like XML than it is JSON.

1) When I read #uri "http://google.com" my app code sees (java.net.URI. "http://google.com"), not Tag "URI" "http://google.com" or whatever. clojure.core/map does not see tagged values, it does not know that the values were ever read from edn.

2) Extension happens in userland library code, you don't need to go modify the hardcoded pattern match in core. (Talking about reifying actual instances that we can code to, not reader tags)

3) Data is just information. Information isn't coupled to code, it's abstract values, totally separate from the concrete implementation. As RH says: "code is data. But data is not code until you define a language around it." Typeclasses are about code.

4) EDN values are cross platform and a platform's EDN reader can reify the value into an idiomatic type for that platform. E.g. a haskell edn reader could reify #error "foo" into Left String; a Java reader a Throwable to be re-thrown later.

5) The whole prism diversion is sophomoric. Once you've read the EDN into concrete values of whatever platform type, you can use whatever platform abstractions you like to manipulate them. Clojure has lenses too: http://funcool.github.io/lentes/latest/#composition

You can watch the EDN talk or read the transcript if you'd like to learn more. This topic is very deep but this thread is not doing it justice.

comment 9y ago · link · parent

c-f "degoes" in this thread

2069.

Transcript of Rich Hickey's Original EDN Talk(github.com ↗)

3 points · by dustingetz · 9y ago · discuss

1
686970
121