Hacker Newsnew | past | comments | ask | show | jobs | submit | gdcbe's commentslogin

Hi HN, I'm the author.

This project started about three years ago as a small piece of a proxy project (ramaproxy.org): on every request we pick a random upstream proxy that matches a handful of flags and a country or city. The data barely changes, the queries happen constantly. Scanning a Vec got slow, and SQLite felt like a lot of database for "give me a random row with these flags".

VennDB is a Rust library: you add a derive macro to a struct, and it generates a database type and a query builder for it. Bools become bitmasks, filter values become sets of rows, and a query is the intersection of those sets. It can pick a random match without finding all of them first.

It is mostly a bitmap index, generated from your struct so you don't have to write and maintain it yourself. It is also narrow on purpose: append-only and in-memory, with no updates or deletes. As such it is not really a database in the traditional sense of the word, but as I was not sure how to name it differently given it does fulfill a niche subset of usecases that I would otherwise use an (in-memory) database for it seemed fitting.

We just released 0.7, which rewrote the engine. In the README compares it with a hand-written roaring bitmap index, SQLite and a plain Vec. roaring gets close on some queries. We're not database experts, so if the benchmarks look unfair or there's prior art we missed, I'd like to hear it.


I noticed some prior art when I wrote a similar library in C++ earlier this year, but unfortunately it's pretty much all deeply theoretical. The magic search term is "monadic unions of conjunctive queries", which is the class of queries this kind of system can express.

I'm still surprised there aren't more implementations out there, because it's a very useful class in application programming. For example, gameplay tags in unreal engine are queries in this class [0], and Intel ships a library using them for binary message parsing. It can also be done almost completely in SIMD, which is the route my shitty library takes. If you add recursion on top, you get queries that can express regular languages / monadic datalog.

My library quickly bottlenecked on memory bandwidth though. It doesn't seem like you're ordering joins by selectivity or a bitmap index to avoid reading unnecessary memory, so is this a direction you plan to explore more in the future?

[0] https://dev.epicgames.com/documentation/unreal-engine/using-...


I have a deep background in C++ and C with classes myself (drivers, embedded and most if at all for Game Engine development). That's also where I used bitflags a lot, though at much smaller scale. After having programmed in many different other languages as well over the years and decades I have settled for most of my work on Rust these days, having picked it up ~ 11 years ago.

Many years later while trying to figure out how we could best filter on our upstream proxies based on request and user requirements, and after having read a book of a fellow belgian about proc macros, did it come to me that this might actually work, and it did. That said, if you compare the first version of this lib vs what it is now it is still same in spirit but has gotten much better by now.

Thanks for the search term though :) Could you share your C++ library and the queries that hit the bandwidth limit? Your memory-bandwidth question got me to try this, and we just released the result in 0.7.1. VennDB already used bitmap indexes and could start from a selective filter. The change was to intersect dense indexes a block at a time, so if the first two filters empty a block, we can skip the remaining reads for it.

On an M4 Max with 8.4M rows, eight independent filters went from 184 to 158 µs. When the first two ruled out seven out of eight regions, it went from 183 to 78 µs. Those timings cover building the query through reading the first match. I’d be curious to see your C++ library. What did the queries look like when you hit the bandwidth limit?


> It is mostly a bitmap index, generated from your struct so you don't have to write and maintain it yourself.

That explanation makes complete sense, because with this in mind, I can compare it to Apache Druid which does the same thing for data spilled onto S3.

Since this is immutable, you only had to solve "naming things", since the caches didn't need to be invalidated.

Druid is technically mutable, since it lets you mutate whole segments & then cache these bitmasks without having the original data in memory.

But if your dataset is already in memory, this is a neat implementation of an index and it should be faster than Roaring since you can skip the extra translation to the row-id that requires.

Druid uses Roaring - https://dl.acm.org/doi/10.1145/2938503.2938515


Who had known that their Mac Minis would be the servers they never wanted to sell again :')


Seems not to be only an issue in the development world though.

At least in Belgium there’s also a lot of unregistered solar panels to the point that the energy regulator is using satellite imagery to catch and find them…


Why?


> Without declaration, there is not only a risk of grid overload and regular shutdowns of inverters, but technicians are also exposed to real danger during their interventions. An undeclared installation can cause serious electrical risks if technicians do not have the necessary information to work safely.

https://www.brussels.be/how-report-solar-panels-brussels

I have no idea how serious these reasons actually are. It seems registration is free, though you do need to have a digital meter, which may incur extra costs. The system is apparently designed to encourage self-usage rather than feeding back to the grid.

I don't really know the benefit of not registering. To register you may need an inspection, which could be a pain and cost some money. But if you've spent a bunch of money on a system... why not do the seemingly small extra steps?


> I have no idea how serious these reasons actually are.

Basically, the grid was built with the assumption that plants produce power, and that households only consume it. That means opening a breaker between the transport grid and the distribution lines should allow to safely work on the consumer-bound side.

That assumption no longer works if consumers energize the network, and while I assume workers have safety guidelines to check the line before starting work, there is still a risk.

Fixing this issue would require new remotely-operated breakers to be installed, which is costly, and it's hard to justify installing them proactively just in case.


Linemen have long be trained that a wire is either live or they have personally shorted it to ground. Even before solar, there are a lot of people with generators who didn't disconnect correctly.


When things like power lines fall down the system will detect and disconnect that portion of the grid, one problem with things like personal solar generation is you can keep feeding power to the fault and melt things down.


While possible, the reality is in almost all cases your home system will shut itself down from overload first.


> Fixing this issue would require new remotely-operated breakers to be installed, which is costly, and it's hard to justify installing them proactively just in case.

No, the fix for this issue is that the inverter of your local solar installation checks if the grid delivers a 50 or 60 Hz waveform, and breaks if it does not. This is pretty much the standard in any installation today, and it's mandatory whether you declare your installation or not.

Side note, there is recently a push to vary the allowed deviation from 50/60 Hz a bit for each installation. The risk is that if all installations stop delivering at, say 50.1 Hz, then if the grid exceeds that value for some reason, there would be a very sudden drop in supply since all solar installations shut off at the same time.


> No, the fix for this issue is that the inverter of your local solar installation checks if the grid delivers a 50 or 60 Hz waveform, and breaks if it does not.

It's hard to apply regulation to people who already decided to skip declaring their setup. If everything was done by the book, the stuff would be declared.


Generally the fix is to either have the inverter shut down if the grid fails, or automatically isolate the premises if the grid fails.


Isolation via a transfer switch or breaker lockouts is the right solution. If the grid fails and your power inverter shuts down, your house is without AC power.


Similarly the UK requires a "g98" notification for all solar installation, including balcony. But it's just a web form and free.

I have been wondering if there is a smart way to make use of "island" solar at home, but not thought of one other than heating assist (pipe tape heater).


I picked up one of these because of how cheap it is; can charge anything with a USB port, laptops, phones, torches, etc.

- https://www.action.com/de-de/p/3222881/re-load-solarmodul/

- https://www.action.com/de-de/p/3222880/re-load-faltbares-sol...

Despite the low capacity, given what can be done with a phone and a laptop, this is still potentially useful.


It happens that people need in planning things want to have numbers.

So for example a high voltage power line is planned to be installed between point A and B. Now, probably some land has to be bought. But maybe not everyone sells land. So maybe land is seized, for the good of all. But ... is it really for the good of alL? The government MUST know beyond a doubt it that line is really worthwhile for the entirety. They need hard planning numbers.

There are numerous scenarios available where a government --- or even private companies --- need dependable statistical numbers to do planning.

And that is e.g. the reason why in Germany businesses have to wire lots of data to a government statistical bureau. We all can then get the relevant statistics out of the 16 state and the one federal offices of statistics. Or (e.g in Germany) the "Bundesnetzagentur" uses it base decisions about the grid on it.

Or private people need to register (cost free, via web, at least in Germany) their balcony solar. Compared to what the businesses have to tell this is almost negligible. It only makes sense due to the sheer number of balcony solar installations.


Thanks. My question was genuine since I thought most places didn’t require it for small (e.g. balcony) solar


To fine them and make them pay continuous taxes of course!


Well, actually not. At least not in my country.

Governments have conflicting goals. You think "raise taxes" is the most important goal. But, believe it or not, some governments -- even conservative ones -- also have goals like "protect the envirnment".

In Germany for example, you are nominally required to register your balcony solar. Online, no fee. So it's easy. But .. there are no fines attached if you don't do it. And they don't ask for any taxes.

They are HAPPY that you do your local electricity power after Putin turned off gas export and it turned out that LPG import is way more costly (due to cooling and pressure, a lot of the stored energy is used for that during the transport/processing on that).

In Germany, there was even a process where the politics told the electrical engineers to not be so anal about electric security to make plug in of these devices into normal sockets a possibility. The VDE only wanted special sockets to be used. The politics said "Nope, too expensive for the normal people".

The idea that legislative and executive is only working AGAINST the people is invalid.


Starting from the upcoming 0.5 release of Rama (~ end of September '26), Rama's CLI `serve proxy` command will have a Man-In-The-Middle (MITM) mode `--mitm` that will serve a (protected) web GUI to monitor and engage with the network flowing through the proxy. Happy to also anwer any questions here regarding rama the network framework, or our CLI tool built with it.


You might want to read the “prior art” section of their article…


Who's right though? The article seems to go directly against what parent said above?

> In Java, there’s a similarly looking thread interruption mechanism. Critically, it doesn’t support interrupting syscalls: IOException and InterruptedException are both checked and unrelated, meaning that IOing functions are not interruptible

One says IOing functions are not interruptible, other says "You can interrupt a blocking IO operation" :)


The article seems to talk about how `Thread.interrupt` works with synchronous IO, rather than the async IO machinery of `java.nio`. So I'd say the article is inaccurate or at least incomplete.


NIO can be blocking or non-blocking. Indeed you can switch between the two on a single channel.


> IOException and InterruptedException are both checked and unrelated

https://docs.oracle.com/en/java/javase/25/docs/api/java.base...


Sort of.

The article just references Thread.interrupt


That’s an unrelated project indeed, both in terms of ownership as well as what it is about.

You can learn more about our project name origin at https://ramaproxy.org/book/faq.html#why-the-name-rama

I hope as you learn more about our project that you get excited once again! :)


Info for those who do not know Rama yet: it is a modular rust framework to build network services of any kind (client, server or proxies). For projects where you need to combine multiple protocols, be in control of the stack, build advanced stacks or any kind of proxy, rama is probably for you. And if not, do reach out to us.

Earlier this week we released Rama 0.4, and with it we are bringing system configured proxy support to clients (rama-net), this includes PAC support (rama-pac) driven by Javascript within a WASM runtime (rama-js). It also expands our gRPC support and adds support for ttRPC, a lightweight alternative to gRPC running directly on top of TCP.

Read more in the blog post and discover also the other new features and improvements that Rama brings in this new release, that is 0.4.

As always we are very much open to feedback on this Release, rama itself or how it is presented. It's a project 6 in the making, with everything written for production purposes since day 0. Feedback is always greatly appreciated especially if it allows us to improve Rama. Contributions welcome of course as well.


What differentiates Rama from e.g. Tower, which for me has always been the natural choice?


That is a question I can answer in many ways. But the prime answer is that it's a weird question to ask.

When you mention tower you might mean two things:

1. the `Service` and `Layer` concept. That is in the end just a "tool" to provide composition. Just like you also use records (`structs`), procedures (functions) etc... We also lean on that concept. And also note that Tower did not invent that concept either. So in that sense Rama is just another child down the lane of this lineage.

2. The tower ecosystem. Rama can bridge into it, but it's true that we are not itself part of it. Six years ago Rama was still built directly with Tower. Later we created `tower-async`, and eventually we went our own road. This because it was clear at that point (and still is) that the tower ecosystem is not really gonna change any time soon despite rust having evolved a lot since its initial conception.

So if you like the concept of Tower, with its services and how it allows you to compose than you will also like Rama. That's however kinda where the comparison ends. Rama is a protocol agnostic network framework to build clients, servers and proxies. That is not what Tower is or its goal. Tower its only goal is provide an impl of the concept of "services". Rama uses that same concept, but its just one of many ways how we allow composition and is in a way just one of the concepts that make it so nice to build network services / network stacks.

Now different than what you might be used to in tower, is that in rama the service concept is everywhere (https://ramaproxy.org/book/intro/services_all_the_way_down.h...). You might also like to read https://plabayo.tech/blog/rama-101-2-core-concepts. With rama your services go through the different OSI layers, and easier to use and implement.

Rama is there as the foundation to build network services. Tower is there to provide you with a way to impl the concept of Services. Tower is also a ecosystem and we keep a very close eye on it. I suggest you explore Rama a bit for yourself. A lot more will be clear to you than whatever I might say here.


I have yet to see an actual part of that policy which requires a cookie banner though. Seems more to me that it's a combination of (a) websites allowing all kind of fcked up use cases of cookies on their site (most sites do not even need cookies for real) and (b) not respecting http headers that ask to not be tracked... They much rather have a very confusing popup that kinda forces you to accept all :) How convenient.

Just like websites also give zero fcks about accept-language header... sure do geoip lookup, so much easier... not


I have always seen the cookie banner as a sort of punishment to the public for daring to have demanded better treatment.

“Oh you want consent involved in this interaction? Then we’ll annoy you about it constantly instead of respecting the intent of the regulation.”


I’m certain it’s often just the California “literally everything is known to cause cancer” problem.

It’s simplest just to put the bullshit everywhere and the dipshit bureaucrats will leave everyone alone.


Yes we use it for rama [1]. You can check its justfile and CI workflow file how we use it. Those run thousands and thousands of tests thx to nextest and what feels like instantly (once compiled).

Large projects build with rama use it as well. But those are proprietary from partners so sadly cannot share those.

[1]: https://github.com/plabayo/rama


Thank you very much for developing nextest. It is what allows our projects like rama [1] to run thousands and thousands of tests in a blink of an eye! Keep it up!

[1] https://ramaproxy.org


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: