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

Add init once memory (#3528) #3529

Merged
merged 3 commits into from
Mar 13, 2023
Merged

Conversation

yoniko
Copy link
Contributor

@yoniko yoniko commented Mar 7, 2023

Part 1 of #3528

  • Adds memory type that is guaranteed to have been initialized at least once in the workspace's lifetime.
  • Changes tag space in row hash to be based on init once memory.
  • Unaligned buffers are now allocated after aligned buffers to allow aligned init once buffers to be allocated at the end of the workspace.

Update: now maintains the usage of unaligned buffers

@yoniko
Copy link
Contributor Author

yoniko commented Mar 7, 2023

Note: I explore reducing the scope of changes in this path by maintaining the buffer space.
Update: PR update to maintain buffer space.

@yoniko yoniko linked an issue Mar 8, 2023 that may be closed by this pull request
@@ -310,7 +331,7 @@ ZSTD_cwksp_internal_advance_phase(ZSTD_cwksp* ws, ZSTD_cwksp_alloc_phase_e phase
ws->tableEnd = objectEnd; /* table area starts being empty */
if (ws->tableValidEnd < ws->tableEnd) {
ws->tableValidEnd = ws->tableEnd;
} } }
} } }
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: doesn't seem to be the proper bracket alignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

* 2. Another initOnce buffer that has been allocated before (and so was previously memset)
* 3. An ASAN redzone, in which case we don't want to write on it
* For these reasons it should be fine to not explicitly zero every byte up to ws->initOnceStart.
* Note that we assume here tha MSAN and ASAN cannot run in the same time. */
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we assume here that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -1932,6 +1932,17 @@ ZSTD_reset_matchState(ZSTD_matchState_t* ms,
ZSTD_cwksp_clean_tables(ws);
}

if (ZSTD_rowMatchFinderUsed(cParams->strategy, useRowMatchFinder)) {
/* Row match finder needs an additional table of hashes ("tags") */
size_t const tagTableSize = hSize * sizeof(U16);
Copy link
Contributor

Choose a reason for hiding this comment

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

Investigate if we really need U16 space for the tags table.

Copy link
Contributor Author

@yoniko yoniko Mar 9, 2023

Choose a reason for hiding this comment

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

For now we need it

@yoniko
Copy link
Contributor Author

yoniko commented Mar 9, 2023

@Cyan4973 - see CR fixes

@yoniko yoniko force-pushed the init-once-memory-3528-part1 branch from baefad5 to 70d69dc Compare March 10, 2023 22:19
- Adds memory type that is guaranteed to have been initialized at least once in the workspace's lifetime.
- Changes tag space in row hash to be based on init once memory.
- Moves buffers to aligned memory and removes the buffer memory type.
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.

Row hash tag space initialization speed regression
3 participants