Skip to content

Use mimalloc to prevent OOM in docker environments. - #139

Draft
rijos wants to merge 2 commits into
3DGI:masterfrom
rijos:feat/geo-superblocks-clean
Draft

Use mimalloc to prevent OOM in docker environments.#139
rijos wants to merge 2 commits into
3DGI:masterfrom
rijos:feat/geo-superblocks-clean

Conversation

@rijos

@rijos rijos commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I noticed our tyler workers being killed by docker while processing the terrain dataset, by switching the allocator to mimalloc we prevent this behavior by releasing the pages earlier to the OS. Under normal circumstances the glibc allocator is fine.

Before
image

After
image

This is part one of a two-part fix, this fixes going OOM while generating the glb's. The second place where we probably go OOM is indexing all generated glb's. I'll keep you posted.

Created part two: 3DGI/cityjson-rs#15

Additional note, a lot of rework has been done in cityjson-rs to prevent tyler going OOM. the new streaming reindex works for terrain, so I've decided to incorporate the public cityjson-rs api changes in this pull request for tyler so we can make use of these changes.

Comment thread src/main.rs
}
// The grid z-extent comes from the geometry while indexed_bounds comes
// from the index; they agree to float-path precision.
assert!((world.grid.bbox[2] - indexed_bounds.min_z).abs() < 1e-6);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New f32 arithmetic causes a very small deviation, perhaps we should add a new default epsilon to validate against.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, yes, we could add a const with the epsilon, like DEFAULT_FLOAT_EPSILON, and use that

@rijos
rijos marked this pull request as draft June 9, 2026 12:28
@balazsdukai

Copy link
Copy Markdown
Contributor

@rijos thanks for this, I didn't realise that memory usage would be this bad. You are using regular CityJSON files (not cityjsonseq etc) as input, right?
Using mimalloc is a good call. I remember from roofer's parallelisation work that glibc was a bit too slow in releasing memory.

Comment thread src/main.rs
let filtered = feature_filter.apply(&model)?;
model = filtered.model;
// A package with no retained geometry yields `model: None`.
let Some(model) = filtered.model else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike this silent edge case, either log or abort.

@rijos

rijos commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@rijos thanks for this, I didn't realise that memory usage would be this bad. You are using regular CityJSON files (not cityjsonseq etc) as input, right? Using mimalloc is a good call. I remember from roofer's parallelisation work that glibc was a bit too slow in releasing memory.

We're using regular CityJSON files as input.

@ymoisan ymoisan mentioned this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants