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

[lib] Move some ZSTD_CCtx_params off the stack #2615

Merged
merged 2 commits into from
May 6, 2021

Conversation

terrelln
Copy link
Contributor

@terrelln terrelln commented May 5, 2021

  • Take params by const reference in ZSTD_resetCCtx_internal().
  • Add simpleApiParams to the CCtx and use them in the simple API
    functions, instead of creating those parameters on the stack.
  • Set DEBUGLEVEL=2 by default in tests/Makefile to catch compiler
    errors in DEBUGLOG() statements.

I think this is a good direction to move in, because we shouldn't need
to worry about adding parameters to ZSTD_CCtx_params, since it should
always be on the heap (unless they become absoultely gigantic).

Some ZSTD_CCtx_params are still on the stack in the CDict functions,
but I've left them for now, because it was a little more complex, and we
don't use those functions in stack-constrained currently.

* Take `params` by const reference in `ZSTD_resetCCtx_internal()`.
* Add `simpleApiParams` to the CCtx and use them in the simple API
  functions, instead of creating those parameters on the stack.

I think this is a good direction to move in, because we shouldn't need
to worry about adding parameters to `ZSTD_CCtx_params`, since it should
always be on the heap (unless they become absoultely gigantic).

Some `ZSTD_CCtx_params` are still on the stack in the CDict functions,
but I've left them for now, because it was a little more complex, and we
don't use those functions in stack-constrained currently.
This allows us to quickly check for compile errors in debug log
messages, which are compiled out when `DEBUGLEVEL < 2`.
@@ -24,7 +24,7 @@ PRGDIR = ../programs
PYTHON ?= python3
TESTARTEFACT := versionsTest

DEBUGLEVEL ?= 1
DEBUGLEVEL ?= 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Set DEBUGLEVEL=2 by default in tests/Makefile to catch compiler errors in DEBUGLOG() statements.

There (is ? / used to be ?) a CI test with DEBUGLEVEL set to 2 specifically for this purpose (check DEBUGLOG() statements).

The question is :
should checking validity of DEBUGLOG() statement be the purpose of a specific CI test,
rather than default for any compilation within tests/ ?

My concern is that traces from DEBUGLEVEL = 2 could impact the generated binary layout more than just assert().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There (is ? / used to be ?) a CI test with DEBUGLEVEL set to 2 specifically for this purpose (check DEBUGLOG() statements).

I added this because only Appveyor caught it.

My concern is that traces from DEBUGLEVEL = 2 could impact the generated binary layout more than just assert().

Does it matter for test cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it matter for test cases?

I'm not sure.
I was concerned that it could make a sensible performance difference,
reducing the nb of fuzzer tests performed within a given timeframe.

It could also be that the difference is not that large.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I went ahead and tested the performance difference between DEBUGLEVEL=1 and DEBUGLEVEL=2 on a given test workload : time ./fuzzer -v -i1000 -t1 -s7653

There was a performance impact, but I believe it's small enough, < 5% (time went up from 22.3s to 23.2s).

@terrelln terrelln merged commit d2925de into facebook:dev May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants