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

Enhance String ValStore Python speed #262

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

weiliw-amz
Copy link
Contributor

@weiliw-amz weiliw-amz commented Oct 10, 2023

Issue #, if available:
N/A

Description of changes:
Accelerate String ValueStore batch get.

For 66M rows, 10 cols string store, batch get of sub-matrix time cost is reduced by 60%:

  • 500 x 5: 6.0 ms -> 2.5 ms
  • 100 x 5: 1.22 ms -> 0.48 ms

Also for Float32 ValueStore, return Numpy view instead of Python MemoryView to connect with Torch tensor.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

# Pre-calculated memory view of each string
# For str decoding, from memory view is faster than from Numpy view
bytes_start_loc = (
np.arange(max_row_size * max_col_size, dtype=np.int64) * self.trunc_val_len
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall the dtype be np.uint64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out, modified.

Copy link
Contributor

@hallogameboy hallogameboy left a comment

Choose a reason for hiding this comment

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

I had a pass and left a comment about data type.

@weiliw-amz weiliw-amz merged commit 6bad2af into amzn:mainline Oct 11, 2023
25 checks passed
@weiliw-amz weiliw-amz deleted the enhance-valstore branch October 12, 2023 18:02
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.

2 participants