Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Calyx-utils] Overhaul GlobalPositionTable + a bunch of CI nonsense #2377

Merged
merged 20 commits into from
Dec 17, 2024

Conversation

EclecticGriffin
Copy link
Collaborator

A quick touch up of the GlobalPositionTable to avoid UB without getting too fancy. Main changes are use of boxcar::Vec instead of the standard library Vec, so that we can now have lock-free concurrent appends and accesses. This fits our use-case since we never de-allocate files & positions and frees us from all the issues associated with using locks. Since we're not using locks, we also don't need any unsafe to extend lifetimes, and since boxcar::Vec doesn't reallocate stored elements, we don't need to box the stored stuff.

I also use LazyLock instead of lazy_static! which is easier to deal with.

The end result is a global position table that can be accessed through associated functions on the GlobalPositionTable type, rather than methods on an instance. I also changed the Strings stored by File to Box<str>, because we don't ever mutate them.


In the process of this, I ran face first in CI issues. Turns out that because some of the tests run in the docker container, they aren't actually building using the version of rust in rust-toolchain.toml and instead were using the version of rust from the container (1.76). This broke things since LazyLock was only stabilized in 1.80. I had a real fight with the CI because it turns out that using the standard actions in the docker container is not a straightforward as one would like. I'll skip a recount of the entire ordeal---peruse the commits to witness my pain---but I resolved things and made these tests consistent with the rest of CI by specifically pulling the toolchain file before running the rust install action. The end result is that even the docker container tests do respect the indicated rust version, and we should be able to bump the version of rust used by EVERYTHING (if this isn't true I may scream) by updating the file.

@EclecticGriffin EclecticGriffin linked an issue Dec 17, 2024 that may be closed by this pull request
Copy link
Contributor

@ekiwi ekiwi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty elegant!

Couple of small nits, then you can just go ahead and merge it.

rust-toolchain.toml
sparse-checkout-cone-mode: false

- name: Install Rust stable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it stable rust or the rust version from rust-toolchain.toml?

@@ -226,6 +240,16 @@ jobs:
git checkout -f $GITHUB_SHA
git clean -fd

- name: Checkout toolchain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually checking out the toolchain, tough, correct? Only the toolchain configuration.

@@ -57,16 +57,17 @@ impl CalyxParser {
})?;
// Add a new file to the position table
let string_content = std::str::from_utf8(content)?.to_string();
let file = GlobalPositionTable::as_mut()
.add_file(path.to_string_lossy().to_string(), string_content);
let file = GlobalPositionTable::add_file(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

Copy link
Contributor

@ekiwi ekiwi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! Do you want to merge it or wait for Adrian's review?

@EclecticGriffin
Copy link
Collaborator Author

I think it's fine to merge probably!

@EclecticGriffin EclecticGriffin merged commit 37d90d9 into main Dec 17, 2024
18 checks passed
@EclecticGriffin EclecticGriffin deleted the calyx-comp/position-table branch December 17, 2024 17:55
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No More Global Symbol Table
2 participants