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

Rust Port: Part 2 - Dependencies #750

Merged
merged 18 commits into from
May 20, 2022
Merged

Rust Port: Part 2 - Dependencies #750

merged 18 commits into from
May 20, 2022

Conversation

fosskers
Copy link
Owner

@fosskers fosskers commented Feb 17, 2022

This PR expands on #671 by rounding off much of the internals of -A.

This is a vast improvement over the Dependencies.hs Haskell version in both performance and accuracy.

Just checking for the package name isn't enough, since sometimes
dependency names don't actually exist as real packages, only as the
"provides" of others.
@Morganamilo
Copy link
Contributor

Keep in mind there's https://docs.rs/aur-depends/1.0.3/aur_depends/ I'm still waiting for if you're okay with this library's API before making an asyncless version.

The library is very high level so I could see you maybe not wanting to use it to do stuff your self/

@fosskers
Copy link
Owner Author

fosskers commented Feb 17, 2022

I'm not against it - I haven't looked through it yet actually. Forgive me if that's caused you a delay.

The current code I'm working through now in the resolve and resolve_one functions is an effort to outdo my past self's Haskell version of similar logic. It's also part experiment, attempting to answer the question "If I code in the obvious way using mostly std, does it come out alright?" (say compared to what the Haskell does).

@Morganamilo
Copy link
Contributor

say compared to what the Haskell does

What does haskell do?

@fosskers
Copy link
Owner Author

I meant the Haskell version of dep resolution found here: https://github.com/fosskers/aura/blob/master/aura/lib/Aura/Dependencies.hs

@fosskers
Copy link
Owner Author

fosskers commented Feb 19, 2022

Side note: The AUR RPC really needs to support searching by provides. It's too bad that we need to resort to workarounds like what aur-depends does (and what I'm writing code for right now too). For pkgbase it just "does the right thing". Why not provides too?

I just hit the stupid edge-case introduced by this depending on this but with a slightly different name.

@fosskers
Copy link
Owner Author

fosskers commented Feb 19, 2022

And am I right that the AUR site itself supports multiple search terms, but the RPC does not?

@fosskers
Copy link
Owner Author

This patch got my hopes up, but I don't see an actual v6 supported here https://gitlab.archlinux.org/archlinux/aurweb/-/blob/master/doc/rpc.txt

@fosskers
Copy link
Owner Author

@fosskers
Copy link
Owner Author

@Morganamilo
Copy link
Contributor

I've given up on searching for provides because I find my hack to be sufficient to be honest. Do note though that I only do the provider search for targets and missing packages. Doing it at every level is not ideal.

@Morganamilo
Copy link
Contributor

Also I pushed a threaded version of aur-fetch using crossbeam https://github.com/Morganamilo/aur-fetch.rs/blob/master/src/fetch.rs#L121

@fosskers
Copy link
Owner Author

This is now comically fast and handles provides correctly.

@Morganamilo
Copy link
Contributor

Running your own aur mirror? Seems a bit fragile.

@fosskers
Copy link
Owner Author

fosskers commented May 20, 2022

Luckily it's just a data mirror of the RPC specifically. Otherwise yes, that would be a nightmare. The benefit is that it's extremely fast, and gives me multi-term search and O(logn) "provides" lookups out of the box.

Go nuts: https://git.sr.ht/~fosskers/faur

I haven't announced it anywhere yet. I'll likely do so as a side-note when I release Aura 4.

@fosskers fosskers merged commit 5b4e231 into master May 20, 2022
@fosskers fosskers deleted the colin/rust-dep-resolution branch May 20, 2022 22:05
@Morganamilo
Copy link
Contributor

How does it work as a speedup then? Can it handle the traffic of many users?

@fosskers
Copy link
Owner Author

fosskers commented May 20, 2022

Because it doesn't use a database and holds all package data in memory, using Rust ref tricks to store HashMaps of &Package data for each kind of lookup you'd want to do (info, search, and provides). So you get O(logn) lookups for everything right out of RAM. This way my own tool can pound its API as hard as I want, without burdening the actual AUR.

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