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

Resolved Bytes vtable #1057

Closed

Conversation

aleksdmladenovic
Copy link
Contributor

@aleksdmladenovic aleksdmladenovic commented Jun 26, 2024

Description

I exposed the drop function of Bytes for resolving the memory fragmentation issues because Bytes are often very small (~50% of the data is less than 500 bytes). I invoked the drop function by using std::mem::drop().

#437

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Tests added/amended
  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

For testing, I added one test script for evicting items when there is not enough space.

Script: cargo test --test memory_store_test insert_drop_test -- --nocapture

Output:

  • Printed Evicting item when the items should be evicted because there is no enough space.
  • Printed BytesWrapper dropped and the Bytes data when the Bytes are dropped.

This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented Jun 26, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ aleksdmladenovic
❌ aleksandarmladenovic0330
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

This won't work for what we are trying to do. Hyper/Tonic/S3 takes a Bytes when sending http requests and we don't want to force a copy every time someone reads something. We need the drop to be called when Hyper/Tonic/S3 is done with it, not when we are done with it.

Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), license/cla, macos-13, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable

@allada allada closed this Jul 27, 2024
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.

4 participants