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

refactor!: Restore full copy-on-write tree snapshots, now using immutable-chunkmap #365

Merged
merged 5 commits into from
May 13, 2024

Conversation

mwcampbell
Copy link
Contributor

To avoid semver-breaking version increases on the adapter crates, I think we'll have to split this into two PRs: one for the changes to accesskit_consumer, and the other for the changes to the adapters. This will require us to merge the first PR with broken CI, and briefly break the main branch. But I can't think of a better way.

@DataTriny
Copy link
Member

Looks good to me! I don't see another way to avoid a breaking version increase either.

The CI passes here, so you can go ahead and extract changes to the adapters.

@mwcampbell
Copy link
Contributor Author

Looking closer at the immutable-chunkmap project, I'm concerned about depending on it. First, it adds several indirect dependencies, including the heavy proc-macro-related dependencies (syn and quote), across all platforms. All of the transitive dependencies of immutable-chunkmap, except for arrayvec (which is ubiquitous across the Rust ecosystem), are for the sake of conveniently defining a packed struct (HeightAndSize in src/avl.rs). If it's even really worthwhile for that struct to be packed, it would be easy enough to hand-write packing and unpacking in safe Rust.

Speaking of safety, the README says the project is written entirely in safe Rust, yet there are several instances of unsafe, again in src/avl.rs. The library used to forbid unsafe code, but I don't see any explanation about why that practice was dropped.

And in terms of process, the project doesn't have CI (that I can see) or tagged releases.

@DataTriny
Copy link
Member

Thanks for digging deeper into this. Not having tagged releases is unacceptable.

All of the issues you listed can probably be solved fairly easily, assuming the maintainer is willing to accept PRs. But depending on this crate right now is probably not a good idea...

This would bump into our short-term goals though...

@mwcampbell
Copy link
Contributor Author

Well, we could fork immutable-chunkmap. I have already been considering that option. The easiest way to eliminate the unsafe code, after all, is to simply drop the few functions that require it; these are the mutable iterator, get_or_insert_cow, and get_or_default_cow, none of which we need. As for the packed struct, which is the source of most of the dependencies, my preference is to eliminate the packing altogether. But the original author may disagree about the value of minimizing dependency count versus winning at benchmarks; given the size of the bench directory, they seem to care a lot about the latter.

AccessKit would be the first popular public project depending on immutable-chunkmap, so we wouldn't be causing a significant division in the Rust ecosystem by forking.

What do you think?

@DataTriny
Copy link
Member

Let's wait and see how the author reacts to the PRs you've open.

To be exhaustive, I should mention that the crates isn't no_std compatible, but a quick look at its code seem to indicate that it would be feasible to implement. This is not a priority for us at the moment, but we should have it in our minds nonetheless.

@mwcampbell
Copy link
Contributor Author

I'm going to bring this up to date. Then I'd like to go ahead and merge it, even though immutable-chunkmap still depends on packed_struct. I've just submitted a PR to immutable-chunkmap with my own implementation of packing the height and size. If Eric accepts that, as he said he'd be open to doing if it passes review, then that will eliminate all of the transitive dependencies of immutable-chunkmap except for arrayvec, which is widespread. Anyway, this PR, and the work on AT-SPI text support, have been stuck long enough.

@mwcampbell mwcampbell force-pushed the immutable-chunkmap branch from f52b649 to 6718324 Compare May 12, 2024 12:54
… support for intervening generic containers in both cases, as we did when we were using `im`.
@mwcampbell
Copy link
Contributor Author

I'm done bringing this PR up to date. Maybe it could use another review now. Also, we were planning to actually merge this as two PRs, a refactor! for accesskit_consumer since we're making a breaking change to that crate, and a fix for the other crates to avoid a semver-breaking version bump for those.

@DataTriny
Copy link
Member

In consumer/src/tree.rs you use ChunkMap::get to check for the presence or absence of a node. You could use get_key instead, which might have slightly less work to do?

Otherwise this looks good to me. So please split this PR in two.

@mwcampbell
Copy link
Contributor Author

OK, now this branch only has the changes to the consumer crate. Of course, this breaks CI. But we'll fix that in the next PR.

@mwcampbell mwcampbell merged commit 441bf5f into main May 13, 2024
3 of 10 checks passed
@mwcampbell mwcampbell deleted the immutable-chunkmap branch May 13, 2024 20:21
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.

2 participants