https://slatedb.io logo
@Rohan So... I've been digging a bit
# general
p
@Rohan So... I've been digging a bit and it seems that you are right, I've been spoiled by ZFS I guess 🙂 What was the rationale for using 4mb part sizes? It seems that this issue would mostly go away if the default was higher
r
I'm not totally sure about where 4MB comes from. It might be arbitrary. @flaneur233 probably knows (he implemented the disk cache)
> It seems that this issue would mostly go away if the default was higher why does using a larger part size help?
p
less fsyncs
Wait
I got tangled there
This is actually not an issue, because this is the temp file
Hence the rename
let tmp_path = path.with_extension(format!("_tmp{}", self.make_rand_suffix()));
So who cares if it gets corrutped
🫨
r
The temp file is there so we can do an atomic rename to the part file. So we don’t want it to become corrupted after the the rename (eg by an unclean restart)
p
Yes but if this already got journaled, this cannot really happen on a sane filesystem
Eg. the default for ext4 > ordered mode > > In data=ordered mode, ext4 only officially journals metadata, but it logically groups metadata information related to data changes with the data blocks into a single unit called a transaction. When it’s time to write the new metadata out to disk, the associated data blocks are written first. In general, this mode performs slightly slower than writeback but significantly faster than journal mode.
It's an issue if the crash happens while the part is written but not after the rename
But as it's a temp part...
r
Interesting. But then why not just fsync since that’s what’s happening under the hood anyway
p
The default is write ordered
fsync is destroying performance on anything not enterprise ssd 🤷‍♂️
I need to look for xfs, but I wouldn't be surprised that it would be the same
When you think about it, it would be quite broken to have the rename succeed, but the file write to be torn
For ext4: > in the default data=ordered > mode, the data blocks of the new file are forced > to disk before the rename() operation is > committed But yeah, doesn't seem too strong of a guarantee, and possibly flismy for other filesystems
c
So are we landing on closing the PR then?
r
the so link above points to the ext4 docs which say:
Copy code
Many broken applications don't use fsync() when replacing existing files via patterns such as fd = open("foo.new")/write(fd,..)/close(fd)/ rename("foo.new", "foo"), or worse yet, fd = open("foo", O_TRUNC)/write(fd,..)/close(fd). If auto_da_alloc is enabled, ext4 will detect the replace-via-rename and replace-via-truncate patterns and force that any delayed allocation blocks are allocated such that at the next journal commit, in the default data=ordered mode, the data blocks of the new file are forced to disk before the rename() operation is committed.  This provides roughly the same level of guarantees as ext3, and avoids the "zero-length" problem that can happen when a system crashes before the delayed allocation blocks are forced to disk.
It sounds like its safe for ext4. But I don't really see how it will improve performance then. Isn't it basically doing the equivalent of fsync under the hood? I think maybe a safer approach would be to try to bypass the cache if it detects any corruption when doing checksum.
p
I think something should address this because it makes things pretty bad esp with the new cache puts option
I saw severe performance degradation from this, that's why I was poking around
c
What new cache puts option? WriteOptions and PutOptions both seem unchanged afaict..
(sorry lots goin on)
p
Copy code
rust

    /// Whether to cache PUT operations to disk. When enabled, data written via PUT operations
    /// will be cached locally for faster subsequent reads. Default is false.
    pub cache_puts: bool,
Oh yeah doesn't look that new from the history 😄
c
ahh haha
I wasn't looking at the ObjectStoreCacheOptions
f
oh, sorry I forgot why we set it to 4MB, maybe stolen from juicefs? 🥹 i think it should be a configurable option though... and it should be safe to change, but it will invalidate the existing cache. yeah, 16MB seems like a reasonable default for most use cases, it also has benefit of having fewer small files.
c
I kinda prefer we be opinionated about this rather than making it configurable if we can avoid it. (clean _slate).
Let’s just bump it up the default up. If someone complains, then I’m ok with making it configurable
p
Unless I am missing something, doesn't that mean we'd also hammer less the object store?
I didn't check in details how is the integration with the iterators