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

chore: fix test_snapshot #4607

Merged
merged 5 commits into from
Feb 13, 2025
Merged

chore: fix test_snapshot #4607

merged 5 commits into from
Feb 13, 2025

Conversation

kostasrim
Copy link
Contributor

@kostasrim kostasrim commented Feb 13, 2025

The issue is the STREAM data type consumes way less memory after the snapshot load and triggers the assertion assert memory_after[counter] >= 0.5 * value. The solution is to assert that the counter is non zero (that is that after loading the snapshot, df properly incremented the counters).

Resolves #4606

@kostasrim kostasrim self-assigned this Feb 13, 2025

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso

types = ["STRING", "LIST", "SET", "HASH", "ZSET", "JSON"]
# If we add stream type, assert memory_after[counter] >= 0.5 * value fails
seeder = StaticSeeder(**self.SEEDER_ARGS, types=types)
Copy link
Contributor Author

@kostasrim kostasrim Feb 13, 2025

Choose a reason for hiding this comment

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

I am not really happy with this nor do I think it's the best solution. Read the above 1, 2, 3 items from the list.

Both (1) and (3) make sense but I am trying to wrap my head around why (2) is useful ? Specifically:

  1. Memory counters after loading from snapshot is similar to before creating a snapshot

And then if you look on what we assert:

            # Unfortunately memory usage sometimes depends on order of insertion / deletion, so
            # it's usually not exactly the same. For the test to be stable we check that it's
            # at least 50% that of the original value.
            assert memory_after[counter] >= 0.5 * value

Why do we consider this test "stable" at 50% and not 60% or 20% ? It seems like a made up number. Furthermore, I don't really see the value of it? Let's take for instance the failure that we see here, because streams seem to consume less size after they loaded from the snapshot. Is this really a regerssion ?

In other words, is there a golden ration that we are aiming ? If so why ? Otherwise maybe we should consider removing (2) alltogether from this test ?

@adiholden Any comments ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree its not stable, but I do want to make sure we do not miss counting when we load from sanpshot.
I would change this to > 0 instead > 0.5 * value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh so it's there for correctness. Why this is not a unit test then ? 😄

I will 1) change this to >0 2) at some point when I get some free bandwidth I will replace that part with a unit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adiholden done

@kostasrim kostasrim requested a review from adiholden February 13, 2025 13:32

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
# at least 50% that of the original value.
assert memory_after[counter] >= 0.5 * value
# Counters should be non zero.
assert memory_after[counter] >= 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert memory_after[counter] >= 0
assert memory_after[counter] > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤣

fix
@kostasrim kostasrim requested a review from adiholden February 13, 2025 14:20
# at least 50% that of the original value.
assert memory_after[counter] >= 0.5 * value
# Counters should be non zero.
assert memory_after[counter] > 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

please update the comment of step 2 of checks

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
@kostasrim kostasrim requested a review from adiholden February 13, 2025 14:24
@kostasrim kostasrim merged commit 59cd931 into main Feb 13, 2025
10 checks passed
@kostasrim kostasrim deleted the kpr17 branch February 13, 2025 15:29
adiholden pushed a commit that referenced this pull request Mar 26, 2025

Verified

This commit was signed with the committer’s verified signature.
richardlau Richard Lau
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.

test_snapshot
2 participants