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

--Add State Value flags for ConfigValues #2382

Closed
wants to merge 29 commits into from
Closed

Conversation

jturner65
Copy link
Contributor

@jturner65 jturner65 commented May 1, 2024

Motivation and Context

This PR is intended to expand the capabilities of the Configurations without incurring much cost by providing status flags for each ConfigValue that reside within the 4 byte gap the current _type field causes due to 8 byte alignment.

  • Modifies the ConfigValType (int) _type field to be u_int64_t _typeAndFlags, where the lower 32 bits correspond to the previous _type value and the higher 32 bits are used to record state of the ConfigValue, along with necessary plumbing to consume the type value in the same way as before.

  • Adds ConfigValStatus enum (u_int64_t) to hold bit flags representing state of the ConfigValue. Currently 2 flags are supported, ConfigValStatus::isDefault and ConfigVaalStatus::isHidden.

    • isDefault : represents programmatic initialization of a value, as opposed to it being set intentionally from a file or user input.
    • isHidden : represents a value being used internally and not part of the actual Configuration data hierarchy. These values we never want to write to file or expose to a user unless for debugging purposes.
  • Adds "init" setters that set the ConfigValStatus::isDefault bit of the ConfigValue's _typeAndFlags variable to 1, while the legacy "set" setters set it to 0.

  • All existing Attributes constructors have their default value setting changed from using variants of "set" to using the new "init"

  • A check on the "isDefault" flag is added when before writing to JSON.

Not only will these features prevent the unnecessary writing to disk of default fields, but they can also be used to prevent configurations being written in a potentially damaging or indeterminant state due to modifications done internally as part of the program's flow.

How Has This Been Tested

Local c++ and python tests pass

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 1, 2024
@jturner65 jturner65 force-pushed the ConfigVals_addFlags branch 3 times, most recently from 73c8bf9 to 2ec5aa4 Compare May 2, 2024 14:12
@jturner65 jturner65 requested a review from aclegg3 May 2, 2024 16:26
@jturner65 jturner65 force-pushed the ConfigVals_addFlags branch 5 times, most recently from caff304 to a0d2ae2 Compare May 3, 2024 13:36
@jturner65 jturner65 marked this pull request as ready for review May 6, 2024 14:25
@jturner65 jturner65 changed the title --[WIP]Add State Value flags for ConfigValues --Add State Value flags for ConfigValues May 6, 2024
@jturner65 jturner65 force-pushed the ConfigVals_addFlags branch 5 times, most recently from 1a3ea4e to 87b2fc9 Compare May 13, 2024 10:58
If ConfigVal values are set programmatically to defaults, the process should use "init" instead of "set". This will make sure the isDefaultVal flag is set to true, and consequently not writing those values to file when requested to.
Values set by the existing "set" methods will always be written to file.
Nearly all the values set in the constructors of the various attributes are defaults that are expected to be overwritten only if necessary.  Writing these to file is redundant and can, in certain circumstances,  cause written JSONs to be in an inappropriate state.
A hidden value would be a pertinent configuration value that is set programmatically and only used internally. These values should not be written to file or exposed to the user except perhaps for debugging.
Not sure if this could even happen (a situation could arise where two different instances could have their _data arrays both be pointers to the same memory location, but just in case.
Hidden fields are set and used internally and will generally not be written to file or exposed to the user except in a debugging capacity. Their labels in Configurations should be camel-case with 2 leading underscores, to help differentiate them from non-hidden fields.
binding value should not have lost "orient_" prefix
'Force_flat_shading should be considered a hidden value, only used internally.
This means a config value is translated by consuming code to some other representation, (i.e. an enum) before it is consumed. These values are stored internally and in files as strings, but require the implementation of custom read functionality to make sure the value read is within the acceptable bounds supported by the program.
These fields will hold the fully qualified file paths that we wish to consume internally but do not wish to write to disk.
Remove the path and have only relative filepath in primary handle attribute; put fully qualified version in hidden handle attribute.

Still fails in some edge cases
This will obviate the need for registering a template before it can be used. Mainly going to be consumed by tests, which often bypass internal control-flow branches that would otherwise automatically register these modified templates.
@jturner65
Copy link
Contributor Author

This PR is being broken into 2 PRs. The first of which is here #2396

@jturner65 jturner65 closed this May 16, 2024
@jturner65 jturner65 deleted the ConfigVals_addFlags branch May 16, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants