https://slatedb.io logo
I’m using s3. I cannot upgrade yet, because I will...
# general
c
Also .. are you using the InMemory object store?
K, mind sharing your configs?
And if possible, the go code where you construct the Db
v
settings={"flush_interval":"250ms","manifest_poll_interval":"1s","manifest_update_timeout":"300s","min_filter_keys":1000,"filter_bits_per_key":10,"l0_sst_size_bytes":268435456,"l0_max_ssts":256,"max_unflushed_bytes":1073741824,"compactor_options":{"poll_interval":"5s","manifest_update_timeout":"300s","max_sst_size":268435456,"max_concurrent_compactions":4},"compression_codec":null,"object_store_cache_options":{"root_folder":"/data/cache","max_cache_size_bytes":384000000000,"part_size_bytes":4194304,"cache_puts":false,"preload_disk_cache_on_startup":null,"scan_interval":"3600s"},"garbage_collector_options":{"manifest_options":{"interval":"60s","min_age":"86400s"},"wal_options":{"interval":"60s","min_age":"60s"},"compacted_options":{"interval":"60s","min_age":"86400s"}},"default_ttl":null}]
is it possible that it will cache all l0 sst in memory?
l0 sst table size is 256MiB
c
Looks reasonable. Can you show the URI/environment variables/.env/whatever you're using to instantiate the object store?
l0_max_ssts
is pretty large, but shouldn't impact memory 🤔
I am suspicious if you're not accidentally using InMemory object storage
v
I'm not using env
I'm passing directly configs
I'm certain that I'm not using in memory because I see requests to s3
c
Do you see the data in S3?
v
yes
c
K
How much memory are you seeing get used
Are you seeing data show up in
/data/cache
on your local disk? (this is the on-disk object store cache)
v
All 64GiB
I'm currently doing only writes
I can double check disk as well
c
hmmm
What if you drop l0_max_ssts back to 8? Do you still see the memory blow up?
v
I will try to reduce it to 128
c
Why do you have it so high?
128 is very high
8 should suffice
v
I'm trying to do 50MiB/s writes
c
8 * 256MiB = 2GiB. Default
CompactorOptions::poll_interval
is 5s. So it will offload from L0 into lower levels at about 400MiB/s (2GiB every 5s)
You can also drop the poll_interval much lower if you like, like 1s, or 500ms or something. It's a relatively cheap poll.
That will increase throughput even more. But we're already talking about 8x what you are trying to write.
the high l0 max setting shouldn't cause memory issues, but it's a peculiar setting.. so I'm kinda curious if it is creating some weird interaction
v
good point thanks. So compactor will attempt to compact all l0 sst, right?
c
ya it favors l0:
Copy code
rs
    fn pick_next_compaction(
        &self,
        l0: &[CompactionSource],
        srs: &[CompactionSource],
        checker: &CompactionChecker,
    ) -> Option<CompactionSpec> {
        // compact l0s if required
        let l0_candidates: VecDeque<_> = l0.iter().cloned().collect();
        if let Some(mut l0_candidates) = self.clamp_min(l0_candidates) {
            l0_candidates = self.clamp_max(l0_candidates);
            let dst = srs
                .first()
                .map_or(0, |sr| sr.source.unwrap_sorted_run() + 1);
            let next_sr = srs.first();
            if checker.check_compaction(&l0_candidates, dst, next_sr) {
                return Some(self.create_compaction(l0_candidates, dst));
            }
        }
//...
v
I think that motivation for high number was to avoid backpressure
c
note that it has a self.options.min_compaction_sources check (clamp_min) which IIRC starts at 4?
Ya I figured. You should be able to tune the compactor though
Still, like I said, this shouldn't cause memory issues. But perhaps it's masking some other problem. Best to sort it out, IMO.
Fyi:
Copy code
rs
#[derive(Clone, Debug)]
pub struct SizeTieredCompactionSchedulerOptions {
    /// The minimum number of sources to include together in a single compaction step.
    pub min_compaction_sources: usize,

    /// The maximum number of sources to include together in a single compaction step.
    pub max_compaction_sources: usize,

    /// The size threshold that the scheduler will use to determine if a sorted run should
    /// be included in a given compaction. A sorted run S will be added to a compaction C if S's
    /// size is less than this value times the min size of the runs currently included in C.
    pub include_size_threshold: f32,
}

impl Default for SizeTieredCompactionSchedulerOptions {
    fn default() -> Self {
        Self {
            min_compaction_sources: 4,
            max_compaction_sources: 8,
            include_size_threshold: 4.0,
        }
    }
}
@Pierre You ever seen any significant memory issues like this? ^
v
I could see that it's a function of requests, during backpressure memory doesn't go up. Thank you for your help.
c
Interesting
Let me know how it goes. Happy to help if I can.
I wonder if something isn't getting freed?
v
btw, what is your recommendation regarding max_unflushed_bytes, how should I compute value for it ?
c
And backpressure is just preventing new leakage
You kinda have to do the test/math to figure out how long it takes for the compactor to move your stuff out of L0 at your write rate
So if you are writing at 50MiB/s and the compactor picks up 8 L0's to move out every 1 seconds (with a 1 second poll) and it takes it 5 seconds to write the L0 data back to a lower level, then you need to sustain about 50 mib/s * 8 l0's * 6 seconds = ~2.4Gib of buffer
That's very back of the envelope and probably not exactly mathematically correct, but should give you a feel
(yea I can already see I did some errors in the logic of that equation, but you get the idea)
the max_unflusehd_bytes should be a function of your write throughput
p
Not really, only with mimalloc where it goes out of control
What’s the allocator that go uses?
(ai)
p
Ah yeah tcmalloc
There must be some allocation pattern that’s messed up
For both mimalloc and tcmalloc to perform that badly
It’s weird
I think it’s something we should probably investigate
c
Yea it seems odd
🤔
p
There’s probably some very inefficient allocation pattern somewhere
c
The odd thing is this would be Go's allocator right? i.e. the Rust side of things is still allocating using whatever it normally does
(my allocator knowledge is near 0)
If so, maybe @Victor Ordaz can try building the go bindings with a different allocator for the Rust part
p
Default is glibc malloc
You cannot really do that I think
There’s only a single global allocator
Unless there’s some magic go side but I’d be surprised
c
🤔
dang
So we're stuck with Go's TCMalloc then
p
I saw such behavior before when allocating large slices that I would throw away and reallocate too quickly
Instead of reusing
c
What was "large" in that ?
256 mib? 1 gib? 10 gib?
p
Large can be small, even something like 4-20K
c
hmm
p
That’s going to be a bitch to diagnose but I think if we use a problematic allocator
And with something like Valgrind see where the waste is
That could be helpful
I can sacrifice myself to dig if you want
🥲
When I use mimalloc with zerofs I always have 10G+ of waste
I suspect this might be somewhere in iterators
/ in object_store
It’s probably where there’s the most churn
c
That would be amazing.. I'm so far under water right now lol .. and i'm honestly clueless with allocator stuff
JVM has rotted my brain 😛
p
@criccomini You were a java guy? 😄
c
Yep. LinkedIn was Java and a smidge of Python/Ruby/JS, and WePay was PHP, Python, Java
v
I’ve realized that I need to rule out other processes in container. It might be something else that uses all memory.
c
(unrelated to memory issue, but wanted to point you at it)
That would be great news.. for us at least 😅 Plz keep us posted.