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

upgrade changed struct fields, cvt values, use NT for field_info #41

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

zot
Copy link

@zot zot commented Jul 17, 2024

Fixes #40

This PR removes / adds / converts fields in existing structs when the struct definition changes. It does this by

  1. Changing properties to be a ref so it can be reassigned
  2. Removing the NT type parameter so that assigning a new properties NT can work
  3. Adding info to each proto struct that tracks the current shape, world counter, and type params at creation time
  4. Placing an updateproto call at the top of the generated methods to check for updates based on the world field

Also, this adds type conversion to the generated constructors.

@zot
Copy link
Author

zot commented Jul 17, 2024

Hmm -- slight change to the type handling. Will push shortly...

Also need to add some updating test cases

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 88.59060% with 17 lines in your changes missing coverage. Please review.

Project coverage is 88.13%. Comparing base (df875e2) to head (a3fa771).
Report is 5 commits behind head on master.

Files Patch % Lines
src/ProtoStruct.jl 88.59% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
- Coverage   97.50%   88.13%   -9.37%     
==========================================
  Files           2        2              
  Lines         120      236     +116     
==========================================
+ Hits          117      208      +91     
- Misses          3       28      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zot
Copy link
Author

zot commented Jul 18, 2024

Not sure why the nightly version of Julia makes so many methods with the same signature but it's the only oddball. I cased-out those method checks for 1.11.

@BeastyBlacksmith
Copy link
Owner

Can you check what the performance implication of this are? Doing an update before every operation seems quite costly to me.

@zot
Copy link
Author

zot commented Jul 18, 2024 via email

@BeastyBlacksmith
Copy link
Owner

Its really hard to make a judgement without having some numbers to compare

@zot
Copy link
Author

zot commented Jul 18, 2024

Honestly I didn't really consider performance because I imagined using @proto for prototyping and changing code, not for production.

Since it's a concern I think I'll make it an option. I can add something like @dynproto (for dyamic) and factor the macro a bit so it can be part of the package and benefit from code improvements but it won't change what @proto does.

@BeastyBlacksmith
Copy link
Owner

BeastyBlacksmith commented Jul 19, 2024

I imagined using @proto for prototyping and changing code, not for production.

Thats true and its fine to be slower than normal structs, my concern is just to not make code using ProtoStructs unreasonable slow, at some point you wouldn't use it otherwise.

@zot
Copy link
Author

zot commented Jul 19, 2024

Well, a friend mentioned that since people use Julia for intense computation like solvers, a significant slowdown during prototyping might have a large impact as well. Since I changed the structs to morph, they're no longer type stable and that could seriously impact tight loop performance -- I had to remove the NT from the type parameters.

So I think it's better just to keep @proto behaving as-is (with the type conversion fix) add another macro, like @dynproto, factoring out common code from the implementation of @proto.

If someone only wants to use @dynproto, they can even import it as @proto if they want to.

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.

Doesn't seem to convert constructor arguments
2 participants