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

SoA improvments part 2 #7163

Merged
merged 20 commits into from
Oct 22, 2024
Merged

SoA improvments part 2 #7163

merged 20 commits into from
Oct 22, 2024

Conversation

rtfeldman
Copy link
Contributor

Follow-up to #7156

smores56
smores56 previously approved these changes Oct 21, 2024
Copy link
Collaborator

@smores56 smores56 left a comment

Choose a reason for hiding this comment

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

I suggested some improvements, but nothing that changes the behavior, so you're good to merge, and/or ignore any comments.

crates/compiler/test_derive/src/util.rs Outdated Show resolved Hide resolved
/// Push to a std::vec::Vec<T> and then return an index to that new element's
/// position in the Vec.
///
/// This is not a method on soa::Index because the `soa` is `no_std` by design.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we want to incentivize low-allocation collection usage and soa is no_std, we should consider making this a method on soa::Index for bumpalo::Vec since bumpalo is no_std by default and should be a good long-term standard to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a custom bumpalo alternative I want to use with this, but haven't gotten it ready for PR yet!

crates/soa/src/lib.rs Show resolved Hide resolved
crates/soa/src/soa_slice.rs Show resolved Hide resolved
@@ -540,6 +540,7 @@ pub fn try_run_lib_function<T>(
}
}

#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the plan to use this code later, so we are avoiding removing it even if it's dead? This seems like a recipe for dead code falling through the cracks, though I'm sure it would get cleaned up eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of these test helpers are considered dead code when they get imported by tests in a tests/ directory (which are treated as their own crates) but the test doesn't use all of them. So they aren't dead in the sense that if you take them out, some tests (but not others) will no longer compile, but depending on the test that's running, they can generate annoying warnings about dead code.

There's probably a better way to do this, but until we know what it is, this is the quick fix. 😄

Copy link
Member

Choose a reason for hiding this comment

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

#[cfg(test)]?

@@ -1,5 +1,9 @@
#![cfg_attr(not(any(debug_assertions, test)), no_std)]
Copy link
Member

Choose a reason for hiding this comment

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

Why no std? Are you going to pass an allocator in explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for new things I'm trying to use no_std as much as possible because for the caching strategy to work properly, it's crucial that all allocations happen in the arena so they can be serialized to/from disk trivially. no_std is an effective way to make sure the various passes aren't accidentally using the global allocator.

],
space_after: [
Slice(start = 0, length = 1),
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
Copy link
Member

Choose a reason for hiding this comment

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

Not directly related to this PR, but I see a couple problems with the snapshot in this way:

  1. Marking indexes/slices doesn't tell you much other than how the implementation works. I don't think this is useful for snapshot tests. It's probably better to print a debug representation of the AST that is materialized, or just print back the program fully and make sure it looks reasonable. (If there's ever a source of non-determinism in the parsing, e.g. parallel parsing, the indexes are also going to be non deterministic)
  2. Embedding the type names is going to create a big diff every time there's a refactor, like is done here. Probably worth avoiding that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's fair - I took the type name back out 👍

@@ -1054,8 +1051,7 @@ fn insert_tags_fast_path(
let variable_slice =
register_tag_arguments(env, rank, arena, types, stack, arguments_slice);

let new_variable_slices =
SubsSlice::extend_new(&mut env.subs.variable_slices, [variable_slice]);
let new_variable_slices = slice_extend_new(&mut env.subs.variable_slices, [variable_slice]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

super nitpick: this should use slice_push_new

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't actually have that in the API, but maybe we should!

@rtfeldman rtfeldman merged commit 71e68f9 into main Oct 22, 2024
18 checks passed
@rtfeldman rtfeldman deleted the soa-part-2 branch October 22, 2024 11:56
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.

3 participants