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

anki: 24.06.2 -> 24.06.3, rust 1.80 fix #333602

Merged
merged 4 commits into from
Aug 13, 2024
Merged

Conversation

martinetd
Copy link
Member

Description of changes

  • update the time dependency to fix rust 1.80 build (not easily testable, but build with 1.79 passes) ; see Rust 1.80.0 breaks some packages #332957
  • while here also update anki itself to the latest release, see release notes https://github.com/ankitects/anki/releases -- nothing stands out to me, but if we're going to rebuild it anyway might as well update.
  • my new vim config automatically runs rustfmt so I've included it as a separate commit last; happy to remove it if you're rather not have it but if it's going to become the official style I guess there's no harm? No opinion on that; I don't particularly like churn so will drop the commit without discussing if requested.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

This doesn't have anything too interesting that I can see but might as well
update to latest release if we're going to rebuild
rust 1.80 requires updating the 'time' crate to at least 0.3.35.

That update is already in anki's master branch but it isn't anywhere
close to time for a new release, so just bump time and only time
manually for our tree.

(This also fixes anki-sync-server which usese the same sources/Cargo
deps, when removing the patch during the next update it will need to be
removed from both files as written in comment)

Link: NixOS#332957
@emilazy
Copy link
Member

emilazy commented Aug 10, 2024

It seems the anki-sync-server tests aren’t happy.

(It’s funny to me that this is under pkgs/games.)

@martinetd
Copy link
Member Author

It seems the anki-sync-server tests aren’t happy.

hmm...

failures:

---- scheduler::answering::test::state_application stdout ----
thread 'scheduler::answering::test::state_application' panicked at rslib/src/scheduler/answering/mod.rs:593:9:
assertion `left == right` failed
  left: Normal(Learning(LearnState { remaining_steps: 2, scheduled_secs: 60, elapsed_secs: 0, memory_state: None }))
 right: Normal(Learning(LearnState { remaining_steps: 2, scheduled_secs: 60, elapsed_secs: 1, memory_state: None }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    scheduler::answering::test::state_application

test result: FAILED. 290 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.35s

For the tests while building the package... But it passes locally (I could build the package when submitting this); so the problem doesn't look like related to the time crate update but perhaps actual CPU perf (ofborg is too fast?!)

Looking at the test it's checking answering the same card twice yields the same result but it looks like on ofborg one test ran in under 1s and not the other...
If it was just the passthru tests I'd be tempted to ignore but I guess the package won't build without this, right?

I'll have a closer look tomorrow.

@emilazy
Copy link
Member

emilazy commented Aug 10, 2024

It might be an ofborg‐specific problem, if Hydra has managed to build this package successfully in the past. I’ll try on the community builders.

@emilazy
Copy link
Member

emilazy commented Aug 10, 2024

Result of nixpkgs-review pr 333602 run on aarch64-linux 1

9 packages built:
  • anki
  • anki-sync-server
  • anki.dist
  • anki.doc
  • anki.man
  • ki
  • ki.dist
  • mnemosyne
  • mnemosyne.dist

Two things that stick out to me:

  1. Did the Cargo.lock really not change at all for 24.06.3?

  2. Since we already vendor the Cargo.lock, we don’t need to also have a patch for it. You can just add ln -sf ${./Cargo.lock} Cargo.lock to postPatch.

@martinetd
Copy link
Member Author

Did the Cargo.lock really not change at all for 24.06.3?

Yes, there's only a handful of patches between 24.06.2 and 24.06.3

$ git diff 24.06.2..24.06.3 Cargo.lock
<empty>

Since we already vendor the Cargo.lock, we don’t need to also have a patch for it. You can just add ln -sf ${./Cargo.lock} Cargo.lock to postPatch.

Hmm, good point, but I prefer the patch for two reasons:

  • copying the Cargo.lock from the repo would mean nix build won't catch if we later forget to update the Cargo.lock in the repo whereas the patch will fail the build and will have to be removed on next update
  • having the patch proves we only updated "time" compared with upstream (but I guess we have that info from the diff of Cargo.lock within our repo as well, so that's not a really good argument)

If you think it's better to re-use our Cargo.lock as you suggest I'll update the patch.

failing test

I've tried locally and that particular test passes whatever I do :/ it only runs in 0.02s on a fairly old laptop so I doubt my theory that something took over a second, unless there was some hiccup somewhere that froze everything for a while...

Copy link
Member

@emilazy emilazy left a comment

Choose a reason for hiding this comment

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

I think we can ignore the failing test unless it breaks on Hydra; it’s probably just flakiness that ofborg happened to stumble upon. The patch doesn’t meaningfully increase repository size, and it’s temporary, so I’m fine with keeping it. Thanks for working on this!

@martinetd
Copy link
Member Author

Thanks for the review! (and thanks for clearing up my misunderstanding with staging and staging-next in the other thread; I was thinking of the two the other way around...)

@emilazy
Copy link
Member

emilazy commented Aug 10, 2024

I’m just waiting on the x86-64 community builder to get through the build to make sure it’ll go through okay, and I’ll merge.

(staging and staging-next are confusing names and I wonder if there’s something better we could use. staging-current?)

@emilazy
Copy link
Member

emilazy commented Aug 10, 2024

Alas, anki-sync-server is not happy on the community x86_64-linux builder either:

failures:

---- media::check::test::unicode_normalization stdout ----
thread 'media::check::test::unicode_normalization' panicked at rslib/src/media/check.rs:723:13:
assertion `left == right` failed
  left: MediaCheckOutput { unused: ["ぱぱ.jpg"], missing: ["foo[.jpg", "normal.jpg"], missing_media_notes: [NoteId(1581236386334)], renamed: {"は\u{309a}は\u{309a}.jp>
 right: MediaCheckOutput { unused: [], missing: ["foo[.jpg", "normal.jpg"], missing_media_notes: [NoteId(1581236386334)], renamed: {"は\u{309a}は\u{309a}.jpg": "ぱぱ.>
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    media::check::test::unicode_normalization

test result: FAILED. 290 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 6.22s

@martinetd
Copy link
Member Author

Eh, and that's another test...

So, I managed to reproduce the first one:

# get exact test command to save time
$ cargo test state_application -vv
[..]
     Running `BUILDHASH='' CARGO=/home/me/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/shared/anki/rslib CARGO_PKG_AUTHORS='Ankitects Pty Ltd and contributors <https://help.ankiweb.net>' CARGO_PKG_DESCRIPTION='Anki'\''s Rust library code' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=AGPL-3.0-or-later CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=anki CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION=1.65 CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' DESCRIPTORS_BIN=/home/shared/anki/out/rslib/proto/descriptors.bin LD_LIBRARY_PATH='/home/shared/anki/target/debug/build/blake3-e1c2eaa3ea1353d6/out:/home/shared/anki/target/debug/build/libsqlite3-sys-d858c897463bfc3e/out:/home/shared/anki/target/debug/build/ring-121d92ec416d412f/out:/home/shared/anki/target/debug/build/ring-becd1effa347c194/out:/home/shared/anki/target/debug/build/zstd-sys-a552024e16331816/out:/home/shared/anki/target/debug/deps:/home/shared/anki/target/debug:/home/me/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/me/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/lib:/opt/wayland/lib64' MACOSX_DEPLOYMENT_TARGET=10.13.4 OUT_DIR=/home/shared/anki/target/debug/build/anki-ecad133eca790a53/out PROTOC=/home/shared/anki/out/extracted/protoc/bin/protoc PYO3_NO_PYTHON=1 STRINGS_PY=/home/shared/anki/out/pylib/anki/_fluent.py STRINGS_TS=/home/shared/anki/out/ts/lib/generated/ftl.ts /home/shared/anki/target/debug/deps/anki-8332ed472bc6ea15 state_appli`

running 1 test
test scheduler::answering::test::state_application ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 290 filtered out; finished in 0.03s
[...]
$ date; while a=$(BUILDHASH='' CARGO=/home/me/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/shared/anki/rslib CARGO_PKG_AUTHORS='Ankitects Pty Ltd and contributors <https://help.ankiweb.net>' CARGO_PKG_DESCRIPTION='Anki'\''s Rust library code' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=AGPL-3.0-or-later CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=anki CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION=1.65 CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' DESCRIPTORS_BIN=/home/shared/anki/out/rslib/proto/descriptors.bin LD_LIBRARY_PATH='/home/shared/anki/target/debug/build/blake3-e1c2eaa3ea1353d6/out:/home/shared/anki/target/debug/build/libsqlite3-sys-d858c897463bfc3e/out:/home/shared/anki/target/debug/build/ring-121d92ec416d412f/out:/home/shared/anki/target/debug/build/ring-becd1effa347c194/out:/home/shared/anki/target/debug/build/zstd-sys-a552024e16331816/out:/home/shared/anki/target/debug/deps:/home/shared/anki/target/debug:/home/me/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/me/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/lib:/opt/wayland/lib64' MACOSX_DEPLOYMENT_TARGET=10.13.4 OUT_DIR=/home/shared/anki/target/debug/build/anki-ecad133eca790a53/out PROTOC=/home/shared/anki/out/extracted/protoc/bin/protoc PYO3_NO_PYTHON=1 STRINGS_PY=/home/shared/anki/out/pylib/anki/_fluent.py STRINGS_TS=/home/shared/anki/out/ts/lib/generated/ftl.ts /home/shared/anki/target/debug/deps/anki-8332ed472bc6ea15 unicode_norm state_appli); do :; done; date; echo "$a"
Sun 11 Aug 10:37:29 JST 2024
Sun 11 Aug 10:37:43 JST 2024

running 2 tests
test media::check::test::unicode_normalization ... ok
test scheduler::answering::test::state_application ... FAILED

failures:

---- scheduler::answering::test::state_application stdout ----
thread 'scheduler::answering::test::state_application' panicked at rslib/src/scheduler/answering/mod.rs:672:9:
assertion `left == right` failed
  left: Normal(Relearning(RelearnState { learning: LearnState { remaining_steps: 1, scheduled_secs: 600, elapsed_secs: 0, memory_state: None }, review: ReviewState { scheduled_days: 1, elapsed_days: 1, ease_factor: 2.45, lapses: 1, leeched: false, memory_state: None } }))
 right: Normal(Relearning(RelearnState { learning: LearnState { remaining_steps: 1, scheduled_secs: 600, elapsed_secs: 1, memory_state: None }, review: ReviewState { scheduled_days: 1, elapsed_days: 1, ease_factor: 2.45, lapses: 1, leeched: false, memory_state: None } }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    scheduler::answering::test::state_application

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 289 filtered out; finished in 0.03s

This fails in anywhere from 10s to a bit over 1min

I thought I couldn't get it to run without adding the unicode_normalization test but I apparently can, so it's not something we can fix by just slapping a -j 1 :/

So for this one, we could just patch the test out (or fuzz the time), and I wouldn't loose sleep over it.

For the unicode normalization test however I couldn't reproduce it and I have honestly no idea at this point; I couldn't get a similar loop to reproduce it, even running all the media checks in case tests interfere with each other (they each get their own tempdir but you never know...)

Long term, I've opened ankitects/anki#3353 to report both problems

Short term I don't know, since ofborg didn't hit it I assume the unicode error also is a race, just one I can't hit on my weak laptop (or perhaps something with the rust version? I've left the project's rust-toolchain.toml forcing 1.75 here); but I don't even know how to properly skip specific tests in rust so I'll give it a few days for upstream to react first...

@martinetd
Copy link
Member Author

@emilazy would you happen to you know or be able to check what filesystem the community builder uses for /tmp (or whatever directory the build happens in)?

In particular I'm curious about the file timestamp granularity, some filesystems have a one second granularity and that'd lead to these kinds of failures.
Something like for _ in 1 2; do touch /tmp/test; stat /tmp/test; done; rm /tmp/test would do.

@martinetd
Copy link
Member Author

ignore me, I tried with such a second-level filesystem and that didn't help.

Copy link
Member

@euank euank left a comment

Choose a reason for hiding this comment

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

I'm not sure if the flaky tests are new/related to this change or not, but regardless, the update itself seems fine to me.

I verified it launches and works as I expected off this PR, and the diff makes sense to me.

Thanks for updating it!

@martinetd
Copy link
Member Author

Thanks for the review!
I'm pretty sure they're not related to either the update or the change unfortunately :(

I've had a second look at the second failed test and it looks like they're using millisecond timestamps in the database, so if the test creation and update all happened within the same millisecond on the server that'd fail the test. I think that's what the community builder has hit here, and that'd explain why my slower machine cannot reproduce as the test takes ~10-20ms to runs here that laptop is an order of magnitude slower than recent hardware (since it's just part of the test probably a couple times faster might be enough, I don't know)

Anyway, I feel no responsibility to actually try to figure out how to best fix these tests; especially since I'm afraid the later "test runs in less than 1ms" might affect other tests (all tests in media check?), so I'll leave that to upstream...

And for now, I've just disabled these two tests through checkFlags... We can add more if any pop up.

anki-sync-server> test result: ok. 289 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 1.07s

By the way, this made me notice both anki and anki-sync-server run the same (lib) tests as most of the tests are there; anki-sync-server itself has no (cargo) test:

     Running unittests main.rs (target/debug/deps/anki_sync_server-6fe8ec7a9a27965e)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

That's probably not a problem (more chance to notice flaky tests, yay?), and if anki-sync-server ever does adds tests it's probably overkill to disable them here as I definitely won't notice, so leaving it at that.

And now, back to work; enough getting side-tracked for today. Will reply tomorrow if there is anything else to fix, that'll leave ofborg time to run the test.

@ofborg ofborg bot requested a review from euank August 13, 2024 06:48
Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

LGTM

@emilazy
Copy link
Member

emilazy commented Aug 13, 2024

Yeah, the timing test seems eminently skippable. The Unicode normalization thing worries me because of the different results, but if it’s not because of this update I guess it shouldn’t matter.

@emilazy
Copy link
Member

emilazy commented Aug 13, 2024

Well, let’s just merge and worry about the tests some other day; it couldn’t get more broken than it would after staging-next anyway. Thanks for your work on this!

@emilazy emilazy merged commit 5301a08 into NixOS:master Aug 13, 2024
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants