News for hackers. Stuff that matters.
Re:Software engineering topics I changed my mind on by specialist on Saturday January 23, 2021 @10:34PM (#25888901)
I was on a team which used DynamoDB for their hottest data set. Which would trivially fit in RAM.
Re:Software engineering topics I changed my mind on by busterarm on Saturday January 23, 2021 @10:56PM (#25889059)
If I had a dollar for every senior engineer I've worked with who has never heard of SQLite...
Re:Software engineering topics I changed my mind on by xxs on Sunday January 24, 2021 @12:00AM (#25889436)
Truth be told I am yet to see a reason to use in-memory database. Datstructures, maps/trees/set - yes. Concurrent/lock free/skip lists/whatever - all great. I don't need a relational database when I can use objects/structs/etc.
Re:Software engineering topics I changed my mind on by Falkon1313 on Sunday January 24, 2021 @04:26AM (#25890604)
I think that depends on what you're doing with the data. If you're just grabbing one thing and working with it, or looping through and processing everything, maybe not.

But if you're doing more complicated query-like stuff, especially if you want to allow for queries you haven't thought of yet, then the DB might be useful.

Sometimes a hybrid of query-able metadata in a DB along with plain old data files is good.

That depends very much on your data, how much things key to each other, and what you're doing with it.

Re:Software engineering topics I changed my mind on by xxs on Sunday January 24, 2021 @05:32AM (#25890904)
>doing more complicated query-like stuff

That's some kind of fallacy - standard datastructures would totally destroy any-sql-alike thing, if it comes to performance (and memory footprint). I guess it does depend on where the background comes when it comes to convenience - or how people tend to see their data. However like I said - for close to 3 decades I have not seen a single reason to do so. On the contrary I've had cases where optimization of 3 orders of magnitude was possible.

Re:Software engineering topics I changed my mind on by jawns on Sunday January 24, 2021 @09:33AM (#25892290)
It's easier to find devs who know basic SQL than it is to find devs who know pandas or whatever your language specific SQL-like library is. And the more complicated the queries, the more the gulf widens.
Re:Software engineering topics I changed my mind on by recursive on Sunday January 24, 2021 @01:04PM (#25894128)
I don't think pandas was the proposal here. I think "standard data structures" refers to arrays, hash tables, trees, and the like.
Re:Software engineering topics I changed my mind on by busterarm on Sunday January 24, 2021 @11:00AM (#25893044)
Performance is not god. It is not the altar at which we sacrifice all other considerations.
Re:Software engineering topics I changed my mind on by throwaway08320 on Sunday January 24, 2021 @08:23AM (#25891817)
> for close to 3 decades I have not seen a single reason to do so

Evidently you don't have dataset far exceeding the amount of RAM you can afford.

For a good example look at LMDB.

Re:Software engineering topics I changed my mind on by busterarm on Sunday January 24, 2021 @02:30AM (#25890112)
ACID transactions, validations & constraints, and the ability to debug/log by dumping your data to disk which can then easily be queried with SQL.

All of the same reasons you would store relational data in a dbms...

Re:Software engineering topics I changed my mind on by xxs on Sunday January 24, 2021 @05:28AM (#25890893)
>ACID transactions, validations & constraints

There is no D from the ACID. For the D to happen, it takes transaction logs + write barrier (on the non-volatile memory). Doing Atomic, consistent and isolated is trivial in memory (esp. in GC setup), and a lot faster: no locks needed.

Validations and constraints are simple if-statements, I'd never think of them as sql.

Re:Software engineering topics I changed my mind on by piggubiggu on Sunday January 24, 2021 @08:43AM (#25891960)
It sounds like you're talking about toy databases which don't run at a lot of TPS. Let me point out some features missing from your simple load a map in memory architecture.

You also have to do backup and recovery. And for that, you need to write to disk, which becomes a big bottleneck since besides backup and checkpointing there is no other reason to ever write to disk.

Then, you have to know that even in mem database, data needs to be queried, and for that you need special data structures like a cache aware B+tree. Implementing one is non trivial.

Thirdly, doing atomic, consistent and isolated transaction is certainly trivial in a toy example but in an actual database where you have a high number of transactions, it's a lot harder. For example, when you have multiple cores, you certainly will have resource contention, and then you do need locks.

And last thing about gc, again, gc is great, but there has to be a custom gc for a database. You need to make sure the transaction log in memory is flushed before committing. And malloc is also very slow.

I'd suggest reading more into in mem research to understand this better. But in mem db is certainly not the same as a disk db with cache or a simple Hashmat/B+tree structure.

Re:Software engineering topics I changed my mind on by sobani on Monday January 25, 2021 @05:37AM (#25901711)
> And malloc is also very slow.

Isn't one of the advantages of a GC environment that malloc is basically free? Afaik the implementation of malloc_in_gc comes down to

    result_address = first_free_address;
    first_free_address += requested_bytes;
    return result_address;
It's the actual garbage collection that might be expensive, but since that process deals with the fragmentation, there is no need to keep a data structure with available blocks of memory around.

That's also the reason why, depending on the patterns of memory usage, a GC can be faster than malloc+free.

Re:Software engineering topics I changed my mind on by xxs on Sunday January 24, 2021 @09:05AM (#25892105)
>It sounds like you're talking about toy databases which don't run at a lot of TPS.

The original talk was explicitly about SqlLite and in-memory databases, no idea where you got the rest of.

Re:Software engineering topics I changed my mind on by piggubiggu on Sunday January 24, 2021 @11:07AM (#25893101)
Correct. So we're talking about in memory databases like MongoDb, and all of the things I listed here are true about MongoDb. For example, MongoDb migrated their database memory manager away from mmap and towards a custom memory manager (point being that gc and memory management for databases is not something you can just use jvm or operating system constructs for)

https://docs.rocket.chat/installation/docker-containers/mong...

I'm happy to justify every single point I made with research papers.

Lastly I know I came off as a bit condescending. Just having a bad day, nothing personal. But you should read more about in mem dbs.

Re:Software engineering topics I changed my mind on by busterarm on Sunday January 24, 2021 @10:58AM (#25893022)
You _can_ have forms of durability if you wish to. You can get "good enough" (actually fairly impressive...) performance for most problems (vs only in-memory) with SQLite making memory the temp store, turning on synchronous and WAL. Then fsync only gets called at checkpoints and you have durability at the checkpoint.
Re:Software engineering topics I changed my mind on by earthboundkid on Sunday January 24, 2021 @03:21PM (#25895516)
Oh, that’s nothing. My company took over a contract from another company that had two DBA writing a schema to store approximately one hundred items in a database! We converted it to a JSON file.
Re:Software engineering topics I changed my mind on by jugg1es on Sunday January 24, 2021 @01:06PM (#25894139)
I've definitely had to push back on engineers wanting to use Redis for caching data they just pulled from the database. "Just store it in RAM guys..."