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

Impl get_size::GetSize (behind feature flag) (v1 branch) #335

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

amandasaurus
Copy link
Contributor

Shows memory usage of the struct

cf. issue #331

This includes unittests, and I have briefly used this in real programmes successfully.

src/tests.rs Outdated
@@ -1023,3 +1023,51 @@ fn drain_keep_rest() {

assert_eq!(a, SmallVec::<[i32; 3]>::from_slice(&[1i32, 3, 5, 6, 7, 8]));
}

#[cfg(feature = "get-size")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this test is failing when both the "get-size" and "union" features are enabled. You can reproduce this failure by running cargo test --features get-size,union.

The test will also fail on non-64-bit platforms. You can fix both issues by changing this line to something like

#[cfg(all(feature = "get-size", target_pointer_with = "64", not(feature = "union")))]

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. & new branch (w. clean history) pushed. I've also added some tests for when the union feature is active.

Shows memory usage of the struct

cf. issue servo#331
@mbrubeck mbrubeck merged commit 38863e8 into servo:v1 Jan 18, 2024
7 checks passed
@mbrubeck
Copy link
Collaborator

Thanks! Published as smallvec 1.13.0.

@amandasaurus
Copy link
Contributor Author

Unfortunately, this has a bug.

a Cargo.toml with:

[dependencies]
get-size = { version = "0.1.4", features = ["derive"] }
smallvec = { version = "1.13.0", features = ["get-size"] }

will fail to compile with:

error: cyclic package dependency: package `attribute-derive v0.6.1` depends on itself. Cycle:
package `attribute-derive v0.6.1`
    ... which satisfies dependency `attribute-derive = "^0.6"` (locked to 0.6.1) of package `get-size-derive v0.1.3`
    ... which satisfies dependency `get-size-derive = "^0.1.3"` (locked to 0.1.3) of package `get-size v0.1.4`
    ... which satisfies dependency `get-size = "^0.1"` (locked to 0.1.4) of package `smallvec v1.13.0`
    ... which satisfies dependency `smallvec = "^1.5"` (locked to 1.13.0) of package `proc-macro-utils v0.8.0`
    ... which satisfies dependency `proc-macro-utils = "^0.8.0"` (locked to 0.8.0) of package `attribute-derive-macro v0.6.1`
    ... which satisfies dependency `attribute-derive-macro = "^0.6.1"` (locked to 0.6.1) of package `attribute-derive v0.6.1`

However these dependencies works:

[dependencies]
get-size = { version = "0.1.4", features = ["derive"] }
smallvec = { git = "https://github.com/servo/rust-smallvec.git", rev="v1.13.0", features = ["get-size"] }

😖😖 But the v1.13.0 tag should be the same as the released 1.13.0, right?

@mbrubeck
Copy link
Collaborator

Hmm, that's annoying. As a workaround you can do this:

[dependencies]
get-size = "0.1.4"
get-size-derive = "0.1"
smallvec = { version = "1.13.0", features = ["get-size"] }

and replace #[derive(GetSize)] in your code with:

#[derive(get_size_derive::GetSize)]

but things will still break if you have dependencies outside of your control that enable the "derive" feature of get-size.

Perhaps it would be better to remove these impls from the smallvec crate, and add them to the get-size crate, if the author is willing.

But the v1.13.0 tag should be the same as the released 1.13.0, right?

Using a git dependency breaks the cycle because Cargo considers it a different crate than the crates.io dependency, so it ends up building two different copies of the smallvec code.

@mbrubeck
Copy link
Collaborator

I have reverted this change and yanked version 1.13.0 for now, until we figure out the best solution. Sorry about this. :(

maxdeviant referenced this pull request in zed-industries/zed Jul 25, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [smallvec](https://github.com/servo/rust-smallvec) |
workspace.dependencies | minor | `1.11.1` -> `1.13.2` |

---

### Release Notes

<details>
<summary>servo/rust-smallvec (smallvec)</summary>

###
[`v1.13.2`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.2)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.13.1...v1.13.2)

#### What's Changed

- Add more tests for UB by
[@&#8203;workingjubilee](https://github.com/workingjubilee) in
[https://github.com/servo/rust-smallvec/pull/346](https://github.com/servo/rust-smallvec/pull/346)
- Fix UB on out-of-bounds insert() by
[@&#8203;mbrubeck](https://github.com/mbrubeck) in
[https://github.com/servo/rust-smallvec/pull/345](https://github.com/servo/rust-smallvec/pull/345)

**Full Changelog**:
servo/rust-smallvec@v1.13.1...v1.13.2

###
[`v1.13.1`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.1)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.13.0...v1.13.1)

- Remove the optional `get-size` feature, to avoid a cyclic dependency
([#&#8203;335](https://github.com/servo/rust-smallvec/issues/335)).

**Full Changelog**:
servo/rust-smallvec@v1.13.0...v1.13.1

###
[`v1.13.0`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.0)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.12.0...v1.13.0)

#### What's Changed

- Impl get_size::GetSize (behind feature flag) by
[@&#8203;amandasaurus](https://github.com/amandasaurus) in
[https://github.com/servo/rust-smallvec/pull/335](https://github.com/servo/rust-smallvec/pull/335)

**Full Changelog**:
servo/rust-smallvec@v1.12.0...v1.13.0

###
[`v1.12.0`](https://github.com/servo/rust-smallvec/releases/tag/v1.12.0)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.11.2...v1.12.0)

#### What's Changed

- Add `from_const_with_len_unchecked` by
[@&#8203;Expyron](https://github.com/Expyron) in
[https://github.com/servo/rust-smallvec/pull/329](https://github.com/servo/rust-smallvec/pull/329)

#### New Contributors

- [@&#8203;Expyron](https://github.com/Expyron) made their first
contribution in
[https://github.com/servo/rust-smallvec/pull/329](https://github.com/servo/rust-smallvec/pull/329)

**Full Changelog**:
servo/rust-smallvec@v1.11.2...v1.12.0

###
[`v1.11.2`](https://github.com/servo/rust-smallvec/releases/tag/v1.11.2)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.11.1...v1.11.2)

#### What's Changed

- Automated testing improvements by
[@&#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/322](https://github.com/servo/rust-smallvec/pull/322)
and
[https://github.com/servo/rust-smallvec/pull/326](https://github.com/servo/rust-smallvec/pull/326)
- fix: don't special-case `doc` for `feature = "const_generics"` by
[@&#8203;mkroening](https://github.com/mkroening) in
[https://github.com/servo/rust-smallvec/pull/328](https://github.com/servo/rust-smallvec/pull/328)
- Code cleanup by [@&#8203;emilio](https://github.com/emilio) in
[https://github.com/servo/rust-smallvec/pull/316](https://github.com/servo/rust-smallvec/pull/316)
and [@&#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/323](https://github.com/servo/rust-smallvec/pull/323)
- Minor tweaks to doc formatting. by
[@&#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/318](https://github.com/servo/rust-smallvec/pull/318)

#### New Contributors

- [@&#8203;mkroening](https://github.com/mkroening) made their first
contribution in
[https://github.com/servo/rust-smallvec/pull/328](https://github.com/servo/rust-smallvec/pull/328)

**Full Changelog**:
servo/rust-smallvec@v1.11.1...v1.11.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone
America/New_York, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

Release Notes:

- N/A

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
CharlesChen0823 referenced this pull request in CharlesChen0823/zed Jul 29, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [smallvec](https://github.com/servo/rust-smallvec) |
workspace.dependencies | minor | `1.11.1` -> `1.13.2` |

---

### Release Notes

<details>
<summary>servo/rust-smallvec (smallvec)</summary>

###
[`v1.13.2`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.2)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.13.1...v1.13.2)

#### What's Changed

- Add more tests for UB by
[@&zed-industries#8203;workingjubilee](https://github.com/workingjubilee) in
[https://github.com/servo/rust-smallvec/pull/346](https://github.com/servo/rust-smallvec/pull/346)
- Fix UB on out-of-bounds insert() by
[@&zed-industries#8203;mbrubeck](https://github.com/mbrubeck) in
[https://github.com/servo/rust-smallvec/pull/345](https://github.com/servo/rust-smallvec/pull/345)

**Full Changelog**:
servo/rust-smallvec@v1.13.1...v1.13.2

###
[`v1.13.1`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.1)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.13.0...v1.13.1)

- Remove the optional `get-size` feature, to avoid a cyclic dependency
([#&zed-industries#8203;335](https://github.com/servo/rust-smallvec/issues/335)).

**Full Changelog**:
servo/rust-smallvec@v1.13.0...v1.13.1

###
[`v1.13.0`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.0)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.12.0...v1.13.0)

#### What's Changed

- Impl get_size::GetSize (behind feature flag) by
[@&zed-industries#8203;amandasaurus](https://github.com/amandasaurus) in
[https://github.com/servo/rust-smallvec/pull/335](https://github.com/servo/rust-smallvec/pull/335)

**Full Changelog**:
servo/rust-smallvec@v1.12.0...v1.13.0

###
[`v1.12.0`](https://github.com/servo/rust-smallvec/releases/tag/v1.12.0)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.11.2...v1.12.0)

#### What's Changed

- Add `from_const_with_len_unchecked` by
[@&zed-industries#8203;Expyron](https://github.com/Expyron) in
[https://github.com/servo/rust-smallvec/pull/329](https://github.com/servo/rust-smallvec/pull/329)

#### New Contributors

- [@&zed-industries#8203;Expyron](https://github.com/Expyron) made their first
contribution in
[https://github.com/servo/rust-smallvec/pull/329](https://github.com/servo/rust-smallvec/pull/329)

**Full Changelog**:
servo/rust-smallvec@v1.11.2...v1.12.0

###
[`v1.11.2`](https://github.com/servo/rust-smallvec/releases/tag/v1.11.2)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.11.1...v1.11.2)

#### What's Changed

- Automated testing improvements by
[@&zed-industries#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/322](https://github.com/servo/rust-smallvec/pull/322)
and
[https://github.com/servo/rust-smallvec/pull/326](https://github.com/servo/rust-smallvec/pull/326)
- fix: don't special-case `doc` for `feature = "const_generics"` by
[@&zed-industries#8203;mkroening](https://github.com/mkroening) in
[https://github.com/servo/rust-smallvec/pull/328](https://github.com/servo/rust-smallvec/pull/328)
- Code cleanup by [@&zed-industries#8203;emilio](https://github.com/emilio) in
[https://github.com/servo/rust-smallvec/pull/316](https://github.com/servo/rust-smallvec/pull/316)
and [@&zed-industries#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/323](https://github.com/servo/rust-smallvec/pull/323)
- Minor tweaks to doc formatting. by
[@&zed-industries#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/318](https://github.com/servo/rust-smallvec/pull/318)

#### New Contributors

- [@&zed-industries#8203;mkroening](https://github.com/mkroening) made their first
contribution in
[https://github.com/servo/rust-smallvec/pull/328](https://github.com/servo/rust-smallvec/pull/328)

**Full Changelog**:
servo/rust-smallvec@v1.11.1...v1.11.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone
America/New_York, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

Release Notes:

- N/A

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
kevmo314 referenced this pull request in kevmo314/zed Jul 29, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [smallvec](https://github.com/servo/rust-smallvec) |
workspace.dependencies | minor | `1.11.1` -> `1.13.2` |

---

### Release Notes

<details>
<summary>servo/rust-smallvec (smallvec)</summary>

###
[`v1.13.2`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.2)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.13.1...v1.13.2)

#### What's Changed

- Add more tests for UB by
[@&zed-industries#8203;workingjubilee](https://github.com/workingjubilee) in
[https://github.com/servo/rust-smallvec/pull/346](https://github.com/servo/rust-smallvec/pull/346)
- Fix UB on out-of-bounds insert() by
[@&zed-industries#8203;mbrubeck](https://github.com/mbrubeck) in
[https://github.com/servo/rust-smallvec/pull/345](https://github.com/servo/rust-smallvec/pull/345)

**Full Changelog**:
servo/rust-smallvec@v1.13.1...v1.13.2

###
[`v1.13.1`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.1)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.13.0...v1.13.1)

- Remove the optional `get-size` feature, to avoid a cyclic dependency
([#&zed-industries#8203;335](https://github.com/servo/rust-smallvec/issues/335)).

**Full Changelog**:
servo/rust-smallvec@v1.13.0...v1.13.1

###
[`v1.13.0`](https://github.com/servo/rust-smallvec/releases/tag/v1.13.0)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.12.0...v1.13.0)

#### What's Changed

- Impl get_size::GetSize (behind feature flag) by
[@&zed-industries#8203;amandasaurus](https://github.com/amandasaurus) in
[https://github.com/servo/rust-smallvec/pull/335](https://github.com/servo/rust-smallvec/pull/335)

**Full Changelog**:
servo/rust-smallvec@v1.12.0...v1.13.0

###
[`v1.12.0`](https://github.com/servo/rust-smallvec/releases/tag/v1.12.0)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.11.2...v1.12.0)

#### What's Changed

- Add `from_const_with_len_unchecked` by
[@&zed-industries#8203;Expyron](https://github.com/Expyron) in
[https://github.com/servo/rust-smallvec/pull/329](https://github.com/servo/rust-smallvec/pull/329)

#### New Contributors

- [@&zed-industries#8203;Expyron](https://github.com/Expyron) made their first
contribution in
[https://github.com/servo/rust-smallvec/pull/329](https://github.com/servo/rust-smallvec/pull/329)

**Full Changelog**:
servo/rust-smallvec@v1.11.2...v1.12.0

###
[`v1.11.2`](https://github.com/servo/rust-smallvec/releases/tag/v1.11.2)

[Compare
Source](https://github.com/servo/rust-smallvec/compare/v1.11.1...v1.11.2)

#### What's Changed

- Automated testing improvements by
[@&zed-industries#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/322](https://github.com/servo/rust-smallvec/pull/322)
and
[https://github.com/servo/rust-smallvec/pull/326](https://github.com/servo/rust-smallvec/pull/326)
- fix: don't special-case `doc` for `feature = "const_generics"` by
[@&zed-industries#8203;mkroening](https://github.com/mkroening) in
[https://github.com/servo/rust-smallvec/pull/328](https://github.com/servo/rust-smallvec/pull/328)
- Code cleanup by [@&zed-industries#8203;emilio](https://github.com/emilio) in
[https://github.com/servo/rust-smallvec/pull/316](https://github.com/servo/rust-smallvec/pull/316)
and [@&zed-industries#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/323](https://github.com/servo/rust-smallvec/pull/323)
- Minor tweaks to doc formatting. by
[@&zed-industries#8203;waywardmonkeys](https://github.com/waywardmonkeys) in
[https://github.com/servo/rust-smallvec/pull/318](https://github.com/servo/rust-smallvec/pull/318)

#### New Contributors

- [@&zed-industries#8203;mkroening](https://github.com/mkroening) made their first
contribution in
[https://github.com/servo/rust-smallvec/pull/328](https://github.com/servo/rust-smallvec/pull/328)

**Full Changelog**:
servo/rust-smallvec@v1.11.1...v1.11.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone
America/New_York, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

Release Notes:

- N/A

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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