-
Notifications
You must be signed in to change notification settings - Fork 42
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
Improve Skip Builds Handling on Build CLI & Disable TLS Initial on Jemalloc #2154
Improve Skip Builds Handling on Build CLI & Disable TLS Initial on Jemalloc #2154
Conversation
* Use serde for loading & saving the file instead of the manual parsing * Additional features on the last run are involved in the persisted states * Use one file for states instead of two for development and production by including the production state in the file itself * Rename the module and structs for the build records * Move additional features to thier own module * Add new build state file name to gitignore
Adjust the integration tests with the new changes on the reset command
Jemalloc combined with Node.js exceeds the default TLS memory limit on Linux.
0ac34b5
to
43cb3c7
Compare
cli/src/build_state_records.rs
Outdated
pub struct BuildStateRecords { | ||
items: Mutex<BuildStateItems>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bellow in code you are getting access to BuildStateRecords
as a ref
pub fn get(production: bool) -> anyhow::Result<&'static BuildStateRecords> {
static CHECKSUM_RECORDS: OnceLock<anyhow::Result<BuildStateRecords>> = OnceLock::new();
CHECKSUM_RECORDS
.get_or_init(|| BuildStateRecords::load(production))
.as_ref()
.map_err(|err| anyhow!("{err}"))
}
All looks good, but it's still a little bit weird. You are wrapping items
into Mutex
to have mut
access to a list, all good. But what it in some time letter you will need some new member in BuildStateRecords
, which also would need mut
access?
Would it make the solution more scalable, if in OnceLock
you will create not an instance of BuildStateRecords
, but Mutex<BuildStateRecords>
. In this case, you would not need to wrap items
into Mutex
and you will be able to get access to &mut BuildStateRecords
from everywhere. Besides that, you BuildStateRecords
can be easily extended with a new field, if it will be needed. Also good alternative might be RwLock
if not all calls of BuildStateRecords
require mut
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AmmarAbouZor to me looks good and can be merged.. "green" light to do it. I've left only one comment and leave it to your responsibility. Realization of BuildStateRecords
, looks good, but not scalable. Suggested changes will not change how the solution works, but can make it just more scalable. Maybe only one thing... If you never going to extend BuildStateRecords
, probably makes sense to declare it as TupleStruct BuildStateRecords(BuildStateItems)
to make it more transparent for a developer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very thanks @DmitryAstafyev for pointing out the issue with internal Mutex. At the start I thought that we could have other fields which doesn't need to be wrapped within the Mutex, but it ended up with more complex code. I moved the Mutex to outside of the struct itself.
This change won't remove the as_ref()
call because this call is to avoid wrapping the Mutex within an Arc
since we always need a reference of the records.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AmmarAbouZor thanks for the corrections. Let it go! You are able to merge it as well
Wrap whole checksum manager inside a mutex instead of hiding it inside
Remove inside items wrapper and set their fields directly inside the manager since we are not wrapping the inner content with a mutex anymore
This PR closes #2152
Build CLI Tool:
This PR improves tracking the state of the last build to determine which builds can be skipped by:
serde
to write and parse the file instead of the manually implementation previously, enabling adding more information to the build state without having to change the parse code.Jemalloc Memory Allocator:
This PR disable initial allocating TLS memory because it leads to Chipmunk exceeding the allowed TLS memory for a process on Linux machine when it run combined with NodeJS and Electron