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

Wrapping NamedTuple in struct is no longer bitstype in 1.7 #43411

Closed
cortner opened this issue Dec 13, 2021 · 4 comments · Fixed by #44311
Closed

Wrapping NamedTuple in struct is no longer bitstype in 1.7 #43411

cortner opened this issue Dec 13, 2021 · 4 comments · Fixed by #44311
Assignees
Labels
regression Regression in behavior compared to a previous version
Milestone

Comments

@cortner
Copy link

cortner commented Dec 13, 2021

cf brief discussion on discourse

This bug(?) occurs on 1.7 but not on 1.6:

struct Wrapper{SYMS, TT}
   x::NamedTuple{SYMS, TT}
end
randnt() = Wrapper((a = randn(), b = rand(), c = rand(1:5), d = randn(SVector{3, Float64})))
X = randnt()
@allocated randnt()  # 64
isbits(X)   # false
isbits(X.x)   # true 

But if the wrapper is defined differently then the isbits == true is recovered:

struct Wrapper1{NT} 
   x::NT
end
randnt1() = Wrapper1((a = randn(), b = rand(), c = rand(1:5), d = randn(SVector{3, Float64})))
X1 = randnt1()
@allocated randnt1() # 0 
isbits(X1) # true
isbits(X1.x) # true

Because of this, it is easy enough to produce a work-around, but it feels like that shouldn't be necessary and the behaviour described above should not occur?

julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.1.0)
  CPU: Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)

(built from source)

@DilumAluthge DilumAluthge added the regression Regression in behavior compared to a previous version label Dec 13, 2021
@maleadt
Copy link
Member

maleadt commented Dec 13, 2021

Bisect points to #40947 (cc @vtjnash)

@KristofferC KristofferC added this to the 1.8 milestone Dec 13, 2021
@cortner
Copy link
Author

cortner commented Dec 16, 2021

I'm surprised this is for 1.8? It causes pretty significant performance regressions. Yes there are workarounds, but that's a lot of work for anybody who is affected now. In my case, I maybe ended up too trusting and started building 1.7 features into my codes; I can't go back to 1.6.

@KristofferC
Copy link
Sponsor Member

1.7 is already released so I don't know what putting a 1.7 milestone would mean. Of course the fix can be backported to 1.7 when available.

@cortner
Copy link
Author

cortner commented Dec 17, 2021

I see so that still goes with a 1.8 label, sorry. I’ll keep an eye on that then.

@JeffBezanson JeffBezanson self-assigned this Feb 22, 2022
staticfloat pushed a commit to JuliaCI/julia-buildkite-testing that referenced this issue Mar 2, 2022
KristofferC pushed a commit that referenced this issue Mar 3, 2022
KristofferC pushed a commit that referenced this issue Mar 7, 2022
KristofferC pushed a commit that referenced this issue Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants