Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate mimalloc leaks starting with 0.1.38 #5875

Open
teh-cmc opened this issue Apr 9, 2024 · 4 comments
Open

Investigate mimalloc leaks starting with 0.1.38 #5875

teh-cmc opened this issue Apr 9, 2024 · 4 comments
Labels
🪳 bug Something isn't working dependencies concerning crates, pip packages etc 📉 performance Optimization, memory use, etc

Comments

@teh-cmc
Copy link
Member

teh-cmc commented Apr 9, 2024

Related:

@teh-cmc teh-cmc added 🪳 bug Something isn't working 📉 performance Optimization, memory use, etc dependencies concerning crates, pip packages etc labels Apr 9, 2024
@abey79
Copy link
Member

abey79 commented Sep 30, 2024

I've tried to repro the issue with 0.1.38 with main as of today, but failed so far. Given that the data store has been entirely rewritten with chunks, this is not entirely surprising that we don't trigger the leak in the same way.


For record, here is my attempt setup:

Viewer launched with:

RERUN_CHUNK_MAX_ROWS=1 cargo r -p rerun-cli --no-default-features --features native_viewer --release -- --memory-limit 256MB
This python script, executed with `RERUN_FLUSH_NUM_ROWS=0`
# %%
from numpy.typing import NDArray
import numpy as np
import rerun as rr


# %%
def gen_color_list(num_colors: int):
    """
    Generates a list of random RGB color values.

    Args:
        num_colors (int): The number of colors to generate.

    Returns:
        list: A list of RGB color values, where each value is a list of three integers between 0 and 255.
    """
    color_list = []
    for _ in range(num_colors):
        r = np.random.randint(0, 256)
        g = np.random.randint(0, 256)
        b = np.random.randint(0, 256)
        color_list.append([r, g, b])
    return color_list


def scale_tsx(tsy: NDArray, ch_count: int) -> NDArray:
    """
    Scales a time series array by adding a constant value to each channel.

    Args:
        tsy (NDArray): _description_
        ch_count (int): _description_

    Returns:
        NDArray: _description_
    """
    scale_factor = tsy.max() + (tsy.std() * 2)
    channel_scale_factor = np.arange(ch_count) * scale_factor
    tsx_scaled = tsy.T + channel_scale_factor.reshape(-1, 1)
    return tsx_scaled


# %%
# mock data

# Define sampling parameters
num_channels = 16  # Number of channels
sample_rate = 24000  # Sampling rate in Hz
duration_min = 30  # Duration in minutes

# Calculate total number of samples
total_samples = sample_rate * 60 * duration_min

# Generate random samples for each channel
random_samples = np.random.uniform(-1.0, 1.0, (total_samples, num_channels)).astype(
    np.float32
)

# Print the shape of the generated random samples array
print("Shape of random samples array:", random_samples.shape)
# %%
traces_scaled = scale_tsx(random_samples[:, :], 16)
ch_colors = gen_color_list(16)
# %%
rr.version()
rr.init("testSubject2", spawn=True)

for ch_id in np.arange(16):
    rr.log(
        f"mockdata/ch{ch_id}",
        rr.SeriesLine(color=ch_colors[ch_id], name=f"ch{ch_id}", width=0.5),
        timeless=True,
    )
# %%
# Log the data on a timeline called "step".
for t in range(0, traces_scaled.shape[1]):
    rr.set_time_sequence("step", t)
    for ch_id in np.arange(16):
        rr.log(f"mockdata/ch{ch_id}", rr.Scalar(traces_scaled[ch_id, t]))
# %%

Example run with 0.1.38 (appears stable over time):

image image

@abey79
Copy link
Member

abey79 commented Sep 30, 2024

@teh-cmc
Copy link
Member Author

teh-cmc commented Sep 30, 2024

Thanks @abey79.

Let's unpin mimalloc as soon as 0.19 ships -- that will give us a few weeks to identify any weird behavior before 0.20.

@emilk
Copy link
Member

emilk commented Oct 4, 2024

Using the old mimalloc was also the cause of the recent alignment bug:

@teh-cmc teh-cmc mentioned this issue Oct 14, 2024
6 tasks
teh-cmc added a commit that referenced this issue Oct 19, 2024
* Includes fix for
purpleprotocol/mimalloc_rust#128
* Potentially includes fix for #5875
teh-cmc added a commit that referenced this issue Oct 19, 2024
commit 0033e78
Author: Clement Rey <cr.rey.clement@gmail.com>
Date:   Sat Oct 19 18:12:39 2024 +0200

    Mimalloc 0.1.43+ (#7713)

    * Includes fix for
    purpleprotocol/mimalloc_rust#128
    * Potentially includes fix for #5875

commit d0ee720
Author: Clement Rey <cr.rey.clement@gmail.com>
Date:   Sat Oct 19 18:07:38 2024 +0200

    Dataframe v2: reference docs (#7820)

    Add a reference page for the dataframe APIs.

    It's still very barebones at this point because #7819 makes it very
    difficult to write snippets for this.

    But it is literally infinitely better than what's there right now:
    nothing.

    - DNM: requires #7817
    - Closes #7828

commit c00a9f6
Author: Andreas Reich <andreas@rerun.io>
Date:   Sat Oct 19 17:59:15 2024 +0200

    Fix Rust dna sample writing to a temporary file (#7827)

commit 31d5943
Author: Clement Rey <cr.rey.clement@gmail.com>
Date:   Sat Oct 19 17:58:48 2024 +0200

    Dataframe v2: examples (#7817)

    Full standalone Rust & Python examples for people who like to learn by
    jumping straight into the examples/ folder.

    Simpler snippets and the associated reference page are coming in a
    future PR.

commit 6d86699
Author: Kevin Reid <kpreid@switchb.org>
Date:   Sat Oct 19 08:52:31 2024 -0700

    Update "Migration Guides" redirect to point to 0.19. (#7837)

    Update "Migration Guides" redirect to point to 0.19, so visitors see the
    0.19 guide first instead of the 0.18 guide.

commit 5b66659
Author: Jeremy Leibs <jeremy@rerun.io>
Date:   Fri Oct 18 13:34:25 2024 -0400

    Remove py-tasks feature from py-docs env (#7835)

    ### What
    Fixes task ambiguity on the `py-build` task:
    ```
    ➜  pixi run py-build
    ? The task 'py-build' can be run in multiple environments.

    Please select an environment to run the task in: ›
    ❯ py
      py-docs
    ```

    ### Checklist
    * [x] I have read and agree to [Contributor
    Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
    the [Code of
    Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
    * [x] I've included a screenshot or gif (if applicable)
    * [x] I have tested the web demo (if applicable):
    * Using examples from latest `main` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7835?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
    * Using full set of examples from `nightly` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7835?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
    * [x] The PR title and labels are set such as to maximize their
    usefulness for the next release's CHANGELOG
    * [x] If applicable, add a new check to the [release
    checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
    * [x] If have noted any breaking changes to the log API in
    `CHANGELOG.md` and the migration guide

    - [PR Build Summary](https://build.rerun.io/pr/7835)
    - [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
    - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

    To run all checks from `main`, comment on the PR with `@rerun-bot
    full-check`.

commit e568694
Author: rerun-bot <132550499+rerun-bot@users.noreply.github.com>
Date:   Fri Oct 18 16:24:55 2024 +0200

    Release 0.19.0 (#7799)

    ### Next steps
    - Test the release
    - If this is an 'alpha' release, you can just merge the pull request.
    - Otherwise:
      - For any added commits, run the release workflow in 'rc' mode again
    - After testing, _ensure that this PR is mergeable to _, then run the
    release workflow in 'release' mode
    - Once the final release workflow finishes it will create a GitHub
    release for you. Then:
        - [x] Sanity check the build artifacts:
          - [x] pip install: does it install and run?
          - [x] cargo install of cli tool: does it install and run?
          - [x] C++ SDK zip: does it contain rerun_c for all platforms?
    - [x] Populate the release with the changelog and a nice header
    video/picture, check , then click .
    - [x] Update the [google colab
    notebooks](https://drive.google.com/drive/folders/0AC0q24MFKh3fUk9PVA)
    to install this version and re-execute the notebook.

    A few hours after the GitHub release is created,  will create a
    [conda feedstock
    PR](https://github.com/conda-forge/rerun-sdk-feedstock/pulls).
    Make sure Jeremy is on top of it!

    - [x] Tests
      - [x] Windows
      - [x] Linux
      - [x] MacOS

    ---------

    Co-authored-by: Jeremy Leibs <jeremy@rerun.io>
    Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
    Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>

commit fb3980b
Author: Jeremy Leibs <jeremy@rerun.io>
Date:   Fri Oct 18 07:33:15 2024 -0400

    Mike depends on setuptools (#7829)

    ### What
    Fixes regression from #7818

    ### Checklist
    * [x] I have read and agree to [Contributor
    Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
    the [Code of
    Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
    * [x] I've included a screenshot or gif (if applicable)
    * [x] I have tested the web demo (if applicable):
    * Using examples from latest `main` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7829?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
    * Using full set of examples from `nightly` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7829?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
    * [x] The PR title and labels are set such as to maximize their
    usefulness for the next release's CHANGELOG
    * [x] If applicable, add a new check to the [release
    checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
    * [x] If have noted any breaking changes to the log API in
    `CHANGELOG.md` and the migration guide

    - [PR Build Summary](https://build.rerun.io/pr/7829)
    - [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
    - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

    To run all checks from `main`, comment on the PR with `@rerun-bot
    full-check`.

commit 1cc6244
Author: Gijs de Jong <14833076+oxkitsune@users.noreply.github.com>
Date:   Fri Oct 18 13:28:20 2024 +0200

    Allow logging individual components directly (Impl `AsComponents` for all `ObjectKind::Component`) (#7756)

    <!--
    Open the PR up as a draft until you feel it is ready for a proper
    review.

    Do not make PR:s from your own `main` branch, as that makes it difficult
    for reviewers to add their own fixes.

    Add any improvements to the branch as new commits to make it easier for
    reviewers to follow the progress. All commits will be squashed to a
    single commit once the PR is merged into `main`.

    Make sure you mention any issues that this PR closes in the description,
    as well as any other related issues.

    To get an auto-generated PR description you can put "copilot:summary" or
    "copilot:walkthrough" anywhere.
    -->

    ### What

    This implements `AsComponents` for all `Component`s, which makes the
    rust api slightly more ergonomic and makes this possible:

    ```rs
    rec.log_static("my_points", &rerun::Color::from_rgb(128, 128, 128))?;
    ```

    ### Checklist
    * [x] I have read and agree to [Contributor
    Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
    the [Code of
    Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
    * [x] I've included a screenshot or gif (if applicable)
    * [x] I have tested the web demo (if applicable):
    * Using examples from latest `main` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7756?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
    * Using full set of examples from `nightly` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7756?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
    * [x] The PR title and labels are set such as to maximize their
    usefulness for the next release's CHANGELOG
    * [x] If applicable, add a new check to the [release
    checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
    * [x] If have noted any breaking changes to the log API in
    `CHANGELOG.md` and the migration guide

    - [PR Build Summary](https://build.rerun.io/pr/7756)
    - [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
    - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

    To run all checks from `main`, comment on the PR with `@rerun-bot
    full-check`.

    ---------

    Co-authored-by: Andreas Reich <r_andreas2@web.de>

commit 9773d8a
Author: Andreas Reich <andreas@rerun.io>
Date:   Fri Oct 18 12:09:11 2024 +0200

    Clarify viewport documentation and reference the type list for view classes (#7826)

    ### What

    * Fixes #3039

    ### Checklist
    * [x] I have read and agree to [Contributor
    Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
    the [Code of
    Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)

    - [PR Build Summary](https://build.rerun.io/pr/7826)
    - [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
    - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

    To run all checks from `main`, comment on the PR with `@rerun-bot
    full-check`.

commit 587cfce
Author: Jeremy Leibs <jeremy@rerun.io>
Date:   Fri Oct 18 04:34:37 2024 -0400

    Bring back the `py-docs` pixi environment (#7818)

    ### What
    - Resolves: #6060

    Pip installing things into pixi environments is always a recipe for
    pain.
    This is the way.

    Pushed this branch to `docs-latest` and confirmed it succeeded:
    - https://github.com/rerun-io/rerun/actions/runs/11390203895

    ### Checklist
    * [x] I have read and agree to [Contributor
    Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
    the [Code of
    Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
    * [x] I've included a screenshot or gif (if applicable)
    * [x] I have tested the web demo (if applicable):
    * Using examples from latest `main` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7818?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
    * Using full set of examples from `nightly` build:
    [rerun.io/viewer](https://rerun.io/viewer/pr/7818?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
    * [x] The PR title and labels are set such as to maximize their
    usefulness for the next release's CHANGELOG
    * [x] If applicable, add a new check to the [release
    checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
    * [x] If have noted any breaking changes to the log API in
    `CHANGELOG.md` and the migration guide

    - [PR Build Summary](https://build.rerun.io/pr/7818)
    - [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
    - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

    To run all checks from `main`, comment on the PR with `@rerun-bot
    full-check`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working dependencies concerning crates, pip packages etc 📉 performance Optimization, memory use, etc
Projects
None yet
Development

No branches or pull requests

3 participants