Live data from Hacker News

Performance in Big Data Land: Every CPU cycle matters

eng.localytics.com

21–30 of 54 posts

Re: Performance in Big Data Land: Every CPU cycle matters

#21

Then why big data land is dominated by JVM-based frameworks?

Most JVM-based query engines uses bytecode generation and once JIT compiler decides that the code block is hot enough and can generate native code for generated bytecode, the output is identical to C and C++.

The author actually indicates that every CPU cycle is important for code block that will be executed for each row. So once you optimize hot code blocks, you're good to go.

Re: Performance in Big Data Land: Every CPU cycle matters

#22

Earlier quoted context omitted.

Once compiled to native code, which it will be for big data because the same classes are reused over and over, I would assume it would be in same ball-park as C/C++ code.

There's still a pretty big speed penalty for Java because the object model encourages a lot of pointer-chasing, which will blow your data locality. In C++, it's common for contained structs to be flat in memory, so accessing a data member in them is just an offset from a base address. In Java, all Object types are really pointers, which you need to dereference to get the contained object. HotSpot can't really optimiz…

Listen to the parent here, I've seen 10x performance in production Java code just using flatbuffers(and paying the marshaling costs from ByteBuffer).

50x is not unreasonable for C/C++ code that was OO and uses a data oriented approach instead.

Re: Performance in Big Data Land: Every CPU cycle matters

#23
CPU is probably not the best example, but the point is very valid, that at 100B scale anything is large.

We humans are not very good at appreciating orders of magnitude. I usually explain it this way: if it takes you 1 hour to process 1M records, then 10M will take 10 hours, and 100M will take 4.2 days while 10B will take over a year.

Re: Performance in Big Data Land: Every CPU cycle matters

#24

Then why big data land is dominated by JVM-based frameworks?

Because a couple decades ago Java convinced Enterprise Land that they can't hire millions of C++ jockeys and expect them to work effectively in huge projects that plan to evolve into the next decades' (aka: the present's) legacy mudball. Instead, they decided it would be easier to hire millions of Java jockeys and have them build enormous kiln-fired mudballs using the same architectural strategy as the Egyptian pyram…

Thank you

Re: Performance in Big Data Land: Every CPU cycle matters

#25
post #21

Then why big data land is dominated by JVM-based frameworks?

Most JVM-based query engines uses bytecode generation and once JIT compiler decides that the code block is hot enough and can generate native code for generated bytecode, the output is identical to C and C++. The author actually indicates that every CPU cycle is important for code block that will be executed for each row. So once you optimize hot code blocks, you're good to go.

Data access patterns are much more important than hot code optimization. Sadly Java offers few options on this front(until maybe Java 9 when values types might become a thing).

Modern CPUs have DRAM fetch time in the 100's of cycles. Any cache friendly algorithm is going to walk circles around something that plays pointer pinball instead.

Re: Performance in Big Data Land: Every CPU cycle matters

#26

I hope later posts in this series explore Linux perf_events or flame graphs, which is the origin of the (unattributed) background image ( http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html ). :)

Since you are here, how do you handle CPU (or code) graphing on distributed systems? In his case, you do not control which nodes and/or when the query will be executed. Any tips?

Re: Performance in Big Data Land: Every CPU cycle matters

#27
>If AUTOCOMMIT = ON (jdbc driver default), each statement is treated as a complete transaction. When a statement completes changes are automatically committed to the database. When AUTOCOMMIT = OFF, the transaction continues until manually run COMMIT or ROLLBACK. The locks are kept on objects for transaction duration.

This made me cringe. Whether a series of operations takes place in one transaction or many isn't something you can just turn on and off depending on what looks more expensive!

The article ended up suggesting more transactionality, which is generally good (although the reason given is not the important one, namely "you're less likely to have all your data completely ruined"), but if you make the process distributed and aren't careful about sharding you may end up trading average-case cost in network load for much worse worst-case cost due to lock contention and transaction failures.

Optimizing database access patterns at scale is hard, and blithely making major changes to things that impact correctness is not the way to do it.

Re: Performance in Big Data Land: Every CPU cycle matters

#28
post #11
post #3

I might suggest a new definition for "Big Data" - Data, whose size is greater than fits in one machine's memory.

The definition I like is that it's when the size of the data becomes a significant challenge to solving your problem. For example 1TB of data won't fit in memory, but if all you need to do is a sequential read in under a day then it's not a problem.

1TB /will/ fit in memory, you can get an ec2 instance with 2TB; but your point stands.

Re: Performance in Big Data Land: Every CPU cycle matters

#29
post #21

Earlier quoted context omitted.

Most JVM-based query engines uses bytecode generation and once JIT compiler decides that the code block is hot enough and can generate native code for generated bytecode, the output is identical to C and C++. The author actually indicates that every CPU cycle is important for code block that will be executed for each row. So once you optimize hot code blocks, you're good to go.

Data access patterns are much more important than hot code optimization. Sadly Java offers few options on this front(until maybe Java 9 when values types might become a thing). Modern CPUs have DRAM fetch time in the 100's of cycles. Any cache friendly algorithm is going to walk circles around something that plays pointer pinball instead.

This is why bytecode generation is used by query engines. They don't meant to be used for creating ArrayList or HashMap. Generally, they work with buffers instead of objects to avoid the issues you mentioned and garbage collection pressure.

Let's say we want to compile a predicate expression "bigintColumn > 4 and varcharColumn = 'str'". A generic interpreter would suffer from the addressed issues but if you generate bytecode for Java source "return longPrimitive > 5 && readAndCompare(buffer, 3, "str".getBytes(UTF8))" then you won't create even a single Java object the output is usually identical to C and C++.

Re: Performance in Big Data Land: Every CPU cycle matters

#30

Then why big data land is dominated by JVM-based frameworks?

Well, CPU utilization is the least of Hadoop's problems (picking on it, because it is the most well-known JVM-based framework)

Hadoop core has some shockingly bad design choices (lots of disk IO), and no amount of layers on top of it is going to fix latency issues.

It has nothing to do with JVM "overhead" (which is mostly a myth, anyway).

Post reply on HN