Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Improvements to C code that can improve performance #420

Open
nhasabni opened this issue Oct 26, 2021 · 1 comment
Open

Improvements to C code that can improve performance #420

nhasabni opened this issue Oct 26, 2021 · 1 comment

Comments

@nhasabni
Copy link

Hi,

I work at Intel, and we have developed a tool that detects anomalous programming language expressions that can possibly lead to bugs. We scanned the code repository for this project as it has considerably high number of stars!

We found a couple of places where the code/expressions are confusing and seem to implement the logic in a rather convoluted manner. We think that the expressions could be rewritten to capture the logic accurately and precisely.

Case 1) Expression at line 839 in c-blosc/internal-complibs/zstd-1.3.4/compress/zstdmt_compress.c

The if expression in the following code performs bitwise OR to check that the pointers are not NULL (if I'm correct). Bitwise OR operator in C does not go through short-circuit evaluation. As a result, all subexpressions (pointer derefs) are evaluated, leading to lost optimization opportunity. Boolean OR can help with such an optimization.

if (!mtctx->factory | !mtctx->jobs | !mtctx->bufPool | !mtctx->cctxPool | !mtctx->seqPool | initError) {
        ZSTDMT_freeCCtx(mtctx);
  return NULL;
}

Case 2) Similar case for expression (offsetCode | !litLength) at line 2890 under c-blosc/internal-complibs/zstd-1.3.4/legacy/zstd_v04.c.

Any thoughts?

@FrancescAlted
Copy link
Member

Hi. Yeah, bcolz vendors pretty old versions of ztsd (and other codecs) essentially because it is unmaintained. For more info: https://github.com/Blosc/bcolz#unmaintained-package-notice

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants