-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
abstraction above the file system for the compiler. #4053
Conversation
739b6db
to
7bf4ca7
Compare
A wild Move coverage report has appeared! New coverage report
Baseline coverage report
If these two differ, you should look at updating the baseline, or adding more tests. You can get more details here |
A wild Move coverage report has appeared! New coverage report
Baseline coverage report
If these two differ, you should look at updating the baseline, or adding more tests. You can get more details here |
Fixed memory leak.
7bf4ca7
to
3a708df
Compare
A wild Move coverage report has appeared! New coverage report
Baseline coverage report
If these two differ, you should look at updating the baseline, or adding more tests. You can get more details here |
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.
Thanks the PR! We definitely want to do something like this eventually.
We will try to hash out if this is the right solution at this time, but I want to make sure we don't kick the can down the road into having to find another solution if anything around the source language changes in the future
thread_local! { | ||
static DESCRIPTORS: RefCell<Option<Descriptors>> = RefCell::new(None); | ||
} |
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.
Before I go too deep into the PR. I'd like to hammer out some details in this file.
The reason I didn't initially do something like this is that at some point in the future, the Move source language compiler will want to be parallel/multi-threaded. At that time, I was worried any such implementation for interned file strings would fall apart.
How will this work if the Move source language were to become multithreaded?
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.
Now the implementation cannot work in a multithreaded environment. But it is quite easy to fix,
we can do something like that.
static DESCRIPTORS: Lazy<RwLock<Option<Descriptors>>> = Lazy::new(|| RwLock::new(None));
#[derive(Debug)]
struct Descriptors {
/// Context counter.
fs_counter: usize,
/// Path table.
paths: Vec<String>,
}
The table will be created together with the context at the beginning of compilation and destroyed at the end.
This will avoid memory leaks.
This is the main goal of our PR.
I would like to discuss ways to solve this problem.
// Copyright (c) The Libra Core Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use serde::{de, export::Formatter, Deserialize, Deserializer, Serialize, Serializer}; |
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.
I would like to avoid adding this file to move-core
. The reason is that it sits relatively low in libra's dependency tree, meaning that all crates in libra
will basically depend on this crate. I would argue that moving this to move-lang
seems to be a better location.
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.
The source language and the IR use the same spanned information. So maybe in the IR types, move-ir/types
?
Taking a longer look at this, I don't think this is the right change at this time. Quick summarized thoughts:
I appreciate the PR in that it addresses a known issue in the compiler, but it is not the solution we want to take. |
Implements the abstraction above the file system for the compiler.
Fixed memory leak.
Motivation
We use the compiler as a service. For distributed compilation purposes. We are prevented by leak_str and the fact that the compiler uses files as a source. It would be nice to have abstraction above the file system.
Have you read the Contributing Guidelines on pull requests?
yes.
Test Plan
Unit test.
Related PRs
--