Skip to content

Added memory consumption test - #567

Draft
rafie wants to merge 21 commits into
masterfrom
rafi-memtest1
Draft

rafie wants to merge 21 commits into
masterfrom
rafi-memtest1

Conversation

@rafie

@rafie rafie commented Dec 8, 2021

Copy link
Copy Markdown
Contributor

No description provided.

@rafie
rafie requested review from gkorland and oshadmi December 8, 2021 17:07
Comment thread Makefile Resolved
Comment thread tests/pytest/test_mem.py

CHECK_MEMRECLAIM = os.getenv('MEMRECLAIM', '0') == '1'

JSON_FILES = [

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.

@rafie I think it's better to copy these files so it won't change without us knowing about it.

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.

They can become quite big and I don't want to introduce git-lfs. When it breaks, we'll fix it.

Comment thread tests/pytest/test_mem.py Resolved
Comment thread tests/pytest/test_mem.py Resolved
Comment thread tests/pytest/tests.sh Resolved
@rafie
rafie requested a review from gkorland December 19, 2021 14:21
Comment thread tests/pytest/common.py
if title is not None:
print(f"--- {title}")
pid = env.envRunner.masterProcess.pid
print(paella.sh(f'cat /proc/{pid}/status | grep ^Vm', join=False))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we always want to print? Maybe use env.debugPrint?

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.

This runs only with MEMINFO=1.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agree with @oshadmi

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.

Well, I tried env.debugPrint() (with RLTest --debug-print) and got such a load of irrelevant garbage that I immediately reverted to print() (with MEMINFO=1). This is what happens when Truth (c) collides with user experience.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still its better to us debugPrint, debug prints should be verbose, you only enable it when you want better logging for debug. Also if you use debugPrint you will get those prints when you run with -vv.

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.

ok.

Comment thread tests/pytest/test_mem.py
for i in range(0, 100):
env.execute_command('json.set', f'json{i}', '$', jfile['doc'])
title += f" t={datetime.timedelta(seconds=time.monotonic() - t0)}"
checkEnvMem(env, expected_vsz=jfile['vsz'], vsz0=vsz0, title=title)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also here and other print - do we always want to print?
What is vsz0 in right-hand-side of vsz0=vsz0 ?

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.

This is a named argument.

Comment thread tests/pytest/test_mem.py
delete()
add_and_check(f"add after del (keys {fi})")
env.execute_command('flushall')
env.stop()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we also check mem here? Should be the initial mem before adding any key?

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.

Redis does not give memory back that easily. It's hard to get a consistent behavior (not like with fields, where we manage memory ourselves).

@gkorland
gkorland requested a review from oshadmi December 21, 2021 12:51
Comment thread tests/pytest/common.py
print(f"--- {title}")
pid = env.envRunner.masterProcess.pid
print(paella.sh(f'cat /proc/{pid}/status | grep ^Vm', join=False))
mem = envMem(env)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not use info memory?

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.

Do you prefer redis-server internal indications over system ones when investigating memory issues?
In most cases you'll be measuring vsz anyway so why not use it in the first place?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

info memory gives you both RSS and the memory Redis think it consumes so I do not see why not use it instead of using env.envRunner.masterProcess.pid which is internal to RLTest and might change someday and break this test.

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.

Ok.

Comment thread tests/pytest/test_mem.py
def add_and_check(title):
t0 = time.monotonic()
for i in range(0, 100):
env.execute_command('json.set', f'json{i}', '$', jfile['doc'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would make jfile as an argument to the function, its not clear where it is coming from..

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.

it's coming from the closure, but I can add.

Comment thread tests/pytest/test_mem.py
t0 = time.monotonic()
for i in range(0, 100):
env.execute_command('json.del', f'json{i}')
print(f"--- del: t={datetime.timedelta(seconds=time.monotonic() - t0)}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

env.debug_print maybe?

Comment thread tests/pytest/test_mem.py Outdated
fi = 0
for jfile in JSON_FILES:
fi += 1
env = Env()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should not create more than one env inside a test, either use the same env or make multiple tests.

Comment thread tests/pytest/test_mem.py Outdated
fi = 0
for jfile in JSON_FILES:
fi += 1
env = Env()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do not create more than one env inside a test

Comment thread tests/pytest/test_mem.py Outdated
t0 = time.monotonic()
for i in range(0, 100):
env.execute_command('json.del', 'json', f'json{i}')
print(f"--- del: t={datetime.timedelta(seconds=time.monotonic() - t0)}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

debugPrint

Comment thread tests/pytest/test_mem.py
{'file': 'https://raw.githubusercontent.com/mloskot/json_benchmark/master/data/canada.json',
'vsz': 2880000 if SERDE_JSON else 598000},
{'file': 'https://raw.githubusercontent.com/RichardHightower/json-parsers-benchmark/master/data/citm_catalog.json',
'vsz': 847000 if SERDE_JSON else 200000},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not run the tests both with serde_json and ijson?

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.

but they do. when we run with serde_json, SERDE_JSON env var is 1.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I meant why you want to control it from outside and not just run on both here?

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.

There's a full cycle of tests running with JSON_BACKEND SERDE_JSON, and when this is the case, we'll be testing it's memory usage. Otherwise, we'll be doing both backends on each cycle, which is redundant and somewhat confusing.

@MeirShpilraien MeirShpilraien left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Only review the tests part without the build changes.

@CLAassistant

CLAassistant commented Sep 22, 2022 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

5 participants