# Richard Startin

Published articles for Richard Startin.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## How Async-Profiler's crash handler works

DevFeed: [How Async-Profiler's crash handler works](<https://devfeed.tech/articles/how-async-profiler-s-crash-handler-works-25637.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/async-profiler-crash-handler>)

Author: Richard Startin's Blog

Published: 2023-11-12T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [async](<https://devfeed.tech/topics/async.md>), [c/c++](<https://devfeed.tech/topics/c-c-plus-plus.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Java](<https://devfeed.tech/topics/java.md>), [JIT](<https://devfeed.tech/topics/jit.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [c](<https://devfeed.tech/tags/c.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [crash](<https://devfeed.tech/tags/crash.md>), [handler](<https://devfeed.tech/tags/handler.md>), [jit](<https://devfeed.tech/tags/jit.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [linux](<https://devfeed.tech/tags/linux.md>), [memory-safety](<https://devfeed.tech/tags/memory-safety.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [run](<https://devfeed.tech/tags/run.md>), [safety](<https://devfeed.tech/tags/safety.md>), [signal](<https://devfeed.tech/tags/signal.md>)

### AI overview

This article explains how async-profiler uses Linux signals and signal handlers to inspect thread state and safely dereference arbitrary pointers without crashing the JVM. It introduces signal-based sampling and frame-pointer unwinding, including the role of JIT-compiled code.

### Source excerpt

Raw pointers in C/C++ open up entire classes of error that are practically unimaginable in higher level languages. So why does anybody use them at all? Unfortunately, it's impossible to write a profiler without getting close to some of the sharp edges of unsafe memory. The async-profiler code base contains a lot of low level tricks, and it's worth studying how some of them work.

## Understanding Request Latency with Profiling

DevFeed: [Understanding Request Latency with Profiling](<https://devfeed.tech/articles/understanding-request-latency-with-profiling-25645.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/wallclock-profiler>)

Author: Richard Startin's Blog

Published: 2023-09-05T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Latency](<https://devfeed.tech/topics/latency.md>), [Java](<https://devfeed.tech/topics/java.md>), [datadog](<https://devfeed.tech/topics/datadog.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [applications](<https://devfeed.tech/tags/applications.md>), [backend](<https://devfeed.tech/tags/backend.md>), [blog](<https://devfeed.tech/tags/blog.md>), [code](<https://devfeed.tech/tags/code.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [datadog](<https://devfeed.tech/tags/datadog.md>), [java](<https://devfeed.tech/tags/java.md>), [latency](<https://devfeed.tech/tags/latency.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [request](<https://devfeed.tech/tags/request.md>), [root-cause-analysis](<https://devfeed.tech/tags/root-cause-analysis.md>)

### AI overview

This article explains how Datadog's Java wallclock profiler can help investigate high request latency when time spent off CPU, rather than CPU time, is the likely cause. It discusses using profiling to support root-cause analysis without changing or even seeing the application code.

### Source excerpt

It can be hard to figure out why response times are high in Java applications. In my experience, people either apply a process of elimination to a set of recent commits, or might sometimes use profiles of the system to explain changes in metrics. Making guesses about recent commits can be frustrating for a number of reasons, but mostly because even if you pinpoint the causal change, you still might not know why it was a bad change and are left in limbo. In theory, using a profiler makes root cause analysis a part of the triage process, so adopting continuous profiling should make this whole process easier, but using profilers can be frustrating because you're using the wrong type of profile for analysis. Lots of profiling data focuses on CPU time, but the cause of your latency problem may be related to time spent off CPU instead. This post is about Datadog's Java wallclock profiler, which I worked on last year, and explores how to improve request latency without making any code changes, or even seeing the code for that matter.

## Evaluating Equality Predicates with RangeBitmap

DevFeed: [Evaluating Equality Predicates with RangeBitmap](<https://devfeed.tech/articles/evaluating-equality-predicates-25641.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/range-bitmap-equality-queries>)

Author: Richard Startin's Blog

Published: 2022-12-18T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Library](<https://devfeed.tech/topics/library.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [data observability](<https://devfeed.tech/topics/data-observability.md>)

Tags: [benchmarking](<https://devfeed.tech/tags/benchmarking.md>), [cardinality](<https://devfeed.tech/tags/cardinality.md>), [comparison](<https://devfeed.tech/tags/comparison.md>), [data-engineering](<https://devfeed.tech/tags/data-engineering.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [java](<https://devfeed.tech/tags/java.md>), [library](<https://devfeed.tech/tags/library.md>), [memory](<https://devfeed.tech/tags/memory.md>), [pinot](<https://devfeed.tech/tags/pinot.md>), [range](<https://devfeed.tech/tags/range.md>), [roaring](<https://devfeed.tech/tags/roaring.md>), [speed](<https://devfeed.tech/tags/speed.md>)

### AI overview

This article evaluates equality and inequality queries using RangeBitmap in the RoaringBitmap library. It explains how the enhancement can support equality filtering as a compact inverted-index alternative, including as a fallback for Apache Pinot range indexes, and reports faster selection than a stream-based scan in the described example while using less space than some inverted indexes.

### Source excerpt

I have just implemented support for (in)equality queries against a RangeBitmap, a succinct data structure in the RoaringBitmap library which supports range queries. RangeBitmap was designed to support range queries in Apache Pinot (more details here) but this enhancement would allow a range index to be used as a fallback for (in)equality queries in case nothing better is available. Supporting (in)equality queries allows a RangeBitmap to be used as a kind of compact inverted index, trading space for time, capable of supporting high cardinality gracefully. Since RangeBitmap supports memory mapping from files, I think that it could be used for data engineering beyond Apache Pinot.

## Using JFR and JMC to root cause a performance bug in JMC caused by a typo in JFR

DevFeed: [Using JFR and JMC to root cause a performance bug in JMC caused by a typo in JFR](<https://devfeed.tech/articles/using-jfr-and-jmc-to-root-cause-a-performance-bug-in-jmc-caused-by-a-typo-in-jfr-25638.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/jmc-hanging>)

Author: Richard Startin's Blog

Published: 2022-12-18T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [JDK Flight Recorder](<https://devfeed.tech/topics/jdk-flight-recorder.md>), [Parser](<https://devfeed.tech/topics/parser.md>), [performance-optimization](<https://devfeed.tech/topics/performance-optimization.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [java](<https://devfeed.tech/tags/java.md>), [load](<https://devfeed.tech/tags/load.md>), [overlap](<https://devfeed.tech/tags/overlap.md>), [performance](<https://devfeed.tech/tags/performance.md>), [profiling](<https://devfeed.tech/tags/profiling.md>)

### AI overview

JMC can take far longer to load a JFR profile when same-thread events of the same type overlap. Its parser groups those events into lanes that are normally disjoint; overlap triggers quadratic scaling, though the excerpt says such files are practically impossible to generate without modifying async-profiler's JFR output. The author profiles JMC during loading with JFR, then examines a flamegraph with over 6,000 CPU samples. A wide frame may be a red herring: sampling cannot distinguish a slow method from one called too often. The excerpt recommends inspecting lower stack frames' code to help distinguish constant-factor costs from algorithmic problems, and ends before the investigation's conclusion.

### Source excerpt

When you open a profile in JMC, it normally takes a few seconds, but there are some profiles that JMC struggles to load. This happens when a profile contains events which violate an assumption made in JMC's parser: events on the same thread are almost always disjoint in their durations. When JMC parses a JFR file, it splits the events of the same type emitted on the same thread into lanes so that events within a lane are disjoint. JMC can handle overlapping events, but assumes this essentially never happens, and exhibits quadratic scaling when events overlap.

## Counting over Range Predicates

DevFeed: [Counting over Range Predicates](<https://devfeed.tech/articles/counting-over-range-predicates-25643.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/range-counts>)

Author: Richard Startin's Blog

Published: 2022-03-27T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Tool](<https://devfeed.tech/topics/tool.md>), [IntelliJ IDEA](<https://devfeed.tech/topics/intellij-idea.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [branch](<https://devfeed.tech/tags/branch.md>), [count](<https://devfeed.tech/tags/count.md>), [database](<https://devfeed.tech/tags/database.md>), [effective](<https://devfeed.tech/tags/effective.md>), [efficiency](<https://devfeed.tech/tags/efficiency.md>), [java](<https://devfeed.tech/tags/java.md>), [performance](<https://devfeed.tech/tags/performance.md>), [predicate](<https://devfeed.tech/tags/predicate.md>), [range](<https://devfeed.tech/tags/range.md>), [roaring](<https://devfeed.tech/tags/roaring.md>), [sorting](<https://devfeed.tech/tags/sorting.md>), [stream-api](<https://devfeed.tech/tags/stream-api.md>), [streams](<https://devfeed.tech/tags/streams.md>), [time](<https://devfeed.tech/tags/time.md>), [timestamps](<https://devfeed.tech/tags/timestamps.md>)

### AI overview

For counting objects that satisfy range predicates, a specialized scan can avoid the work of selecting and materializing matching objects. The Java Stream approach checks every transaction; in the described test, 1 million transactions with about 250 matches took roughly 10 ms. Applying the time filter first helps because the transactions are sorted by time, and Stream API performance can benefit from a single filter implementation being inlined; using many filters may reduce that advantage. The author notes that Streams cannot be told to exploit sorted input or derive range-search shortcuts from predicates. Handwritten Java can use the ordering to narrow the time range, then apply the other predicates to roughly 10% of the data. Sorting was excluded from the benchmark, and the excerpt cuts off before the implementation or full results are shown.

### Source excerpt

This post follows on from my last post about selecting objects satisfying a range predicate, and instead looks at how to count the objects. If you can select objects, you can count them too, but it's a simpler problem so resources can be saved with a specialised solution.

## Evaluating Range Predicates

DevFeed: [Evaluating Range Predicates](<https://devfeed.tech/articles/evaluating-range-predicates-25644.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/range-predicates>)

Author: Richard Startin's Blog

Published: 2022-03-12T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Data analysis](<https://devfeed.tech/topics/data-analysis.md>), [ordering](<https://devfeed.tech/topics/ordering.md>), [Tool](<https://devfeed.tech/topics/tool.md>)

Tags: [about](<https://devfeed.tech/tags/about.md>), [all](<https://devfeed.tech/tags/all.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [api](<https://devfeed.tech/tags/api.md>), [application](<https://devfeed.tech/tags/application.md>), [applying](<https://devfeed.tech/tags/applying.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [benefit](<https://devfeed.tech/tags/benefit.md>), [binary-search](<https://devfeed.tech/tags/binary-search.md>), [branch](<https://devfeed.tech/tags/branch.md>), [complex](<https://devfeed.tech/tags/complex.md>), [data](<https://devfeed.tech/tags/data.md>), [data-analysis](<https://devfeed.tech/tags/data-analysis.md>), [doing](<https://devfeed.tech/tags/doing.md>), [java](<https://devfeed.tech/tags/java.md>), [kind](<https://devfeed.tech/tags/kind.md>), [range](<https://devfeed.tech/tags/range.md>), [roaring](<https://devfeed.tech/tags/roaring.md>), [sales](<https://devfeed.tech/tags/sales.md>), [transaction](<https://devfeed.tech/tags/transaction.md>), [transactions](<https://devfeed.tech/tags/transactions.md>)

### AI overview

For Java filtering over data that cannot be queried through SQL, predicate order and data layout affect performance. In the author's benchmark on one million transactions, reordering conditions to evaluate predictable checks first halved runtime and reduced branch misses by about 10x. When timestamps are sorted and the selected range covers about 10% of the data, binary searching for its bounds could improve performance by up to about 10x; the benchmark excludes sorting, which may pay off when multiple filters reuse the collection. The excerpt also identifies RoaringBitmap as a data structure for range predicates on unsorted data, describing it as immutable and suited to data with a known value range; it suggests building indexes on multiple attributes may be worthwhile when applying several filters.

### Source excerpt

Suppose you are doing some kind of data analysis in Java, perhaps you are analysing transactions (as in sales made). You have complex filters to evaluate before performing a calculation on Transaction objects.

## RangeBitmap - How range indexes work in Apache Pinot

DevFeed: [RangeBitmap - How range indexes work in Apache Pinot](<https://devfeed.tech/articles/rangebitmap-how-range-indexes-work-in-apache-pinot-25642.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/range-bitmap-index>)

Author: Richard Startin's Blog

Published: 2022-03-07T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Database](<https://devfeed.tech/topics/database.md>), [database-optimization](<https://devfeed.tech/topics/database-optimization.md>), [parquet](<https://devfeed.tech/topics/parquet.md>), [Server](<https://devfeed.tech/topics/server.md>)

Tags: [accelerate](<https://devfeed.tech/tags/accelerate.md>), [apache](<https://devfeed.tech/tags/apache.md>), [array](<https://devfeed.tech/tags/array.md>), [columnar](<https://devfeed.tech/tags/columnar.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [databases](<https://devfeed.tech/tags/databases.md>), [indexes](<https://devfeed.tech/tags/indexes.md>), [java](<https://devfeed.tech/tags/java.md>), [merge](<https://devfeed.tech/tags/merge.md>), [partitioning](<https://devfeed.tech/tags/partitioning.md>), [pinot](<https://devfeed.tech/tags/pinot.md>), [predicate](<https://devfeed.tech/tags/predicate.md>), [pruning](<https://devfeed.tech/tags/pruning.md>), [queries](<https://devfeed.tech/tags/queries.md>), [query](<https://devfeed.tech/tags/query.md>), [range](<https://devfeed.tech/tags/range.md>), [roaring](<https://devfeed.tech/tags/roaring.md>), [routing](<https://devfeed.tech/tags/routing.md>), [server](<https://devfeed.tech/tags/server.md>), [servers](<https://devfeed.tech/tags/servers.md>), [unsorted](<https://devfeed.tech/tags/unsorted.md>), [values](<https://devfeed.tech/tags/values.md>)

### AI overview

A Pinot range index must repeatedly find row indexes whose unsorted numeric values satisfy a range predicate, while returning those indexes in sorted order; preprocessing and extra storage are acceptable because queries recur. The excerpt explains that Pinot stores data in independently queried, columnar segments, with sorting scoped to each segment. Servers load indexes, prune and query segments, then merge segment results; brokers route queries and merge server results, and can also prune segments. Indexing slow spans must account for other query needs, including computing time spent in each trace operation, as well as broker routing based on segment partitioning. The excerpt ends before describing the indexing method or further constraints.

### Source excerpt

Suppose you have an unsorted array of numeric values and need to find the set of indexes of all the values which are within a range. The range predicate will be evaluated many times, so any time spent preprocessing will be amortised, and non-zero spatial overhead is expected. If the data were sorted, this would be very easy, but the indexes of the values have meaning so the data cannot be sorted. To complicate the problem slightly, the set of indexes must be produced in sorted order.

## Loop Fission

DevFeed: [Loop Fission](<https://devfeed.tech/articles/loop-fission-25639.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/loop-fission>)

Author: Richard Startin's Blog

Published: 2021-11-27T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [vectorization techniques](<https://devfeed.tech/topics/vectorization-techniques.md>), [JIT](<https://devfeed.tech/topics/jit.md>), [Code generation](<https://devfeed.tech/topics/code-generation.md>), [Cache](<https://devfeed.tech/topics/cache.md>)

Tags: [array](<https://devfeed.tech/tags/array.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [bits](<https://devfeed.tech/tags/bits.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c2](<https://devfeed.tech/tags/c2.md>), [cache](<https://devfeed.tech/tags/cache.md>), [clang](<https://devfeed.tech/tags/clang.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [container](<https://devfeed.tech/tags/container.md>), [hotspot](<https://devfeed.tech/tags/hotspot.md>), [java](<https://devfeed.tech/tags/java.md>), [jit](<https://devfeed.tech/tags/jit.md>), [loops](<https://devfeed.tech/tags/loops.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>), [xor](<https://devfeed.tech/tags/xor.md>)

### AI overview

Loop fission can improve performance when a fused loop prevents the compiler from vectorizing its faster operation. In the bitmap XOR example, splitting XOR and bit-counting into separate loops lets Hotspot's C2 compiler vectorize XORs; on the author's JDK 11 laptop, each instruction handles 256 bits instead of 64 bits in the fused loop. The split version is noticeably faster for small arrays, with the difference narrowing as arrays grow. The author says the bitmap size is fixed at 1,024 elements, so the added pass's cache cost is immaterial in this case. The excerpt also notes that clang can vectorize popcount and performs loop fission (called distribution), making the fused C++ loop faster than the Hotspot case.

### Source excerpt

Loop fission is a process normally applied by a compiler to loops to make them faster. The idea is to split larger loop bodies which perform several distinct tasks into separate loops, in the hope that the individual loops can be optimised more effectively in isolation. As far as I'm aware, C2, Hotspot's JIT compiler, doesn't do this so you have to do it yourself. I came across a couple of cases where this was profitable recently, and this post uses these as examples.