Skip to content

Optimize kixi.stats.core/proportion#53

Merged
henrygarner merged 1 commit intoMastodonC:mainfrom
alexander-yakushev:alexander-yakushev-patch-1
Mar 10, 2025
Merged

Optimize kixi.stats.core/proportion#53
henrygarner merged 1 commit intoMastodonC:mainfrom
alexander-yakushev:alexander-yakushev-patch-1

Conversation

@alexander-yakushev
Copy link
Copy Markdown
Contributor

Current implementation uses vectors to keep the transitive state which allocates new vectors on each step. The proposed implementation uses a mutable array instead. Volatile is added to ensure that changes are visible between threads if somebody decides to uses this reducing function in a multi-threaded context.

@alexander-yakushev alexander-yakushev force-pushed the alexander-yakushev-patch-1 branch from 28b037b to e341daa Compare March 8, 2025 16:44
@henrygarner
Copy link
Copy Markdown
Collaborator

Thanks for this! I'm seeing a failing proportion-test when running locally: java.lang.ClassCastException: class clojure.lang.Volatile cannot be cast to class clojure.lang.IAtom

I've updated main to bump a deprecated actions cache version, so test actions should run remotely if you rebase onto main and force push.

@alexander-yakushev alexander-yakushev force-pushed the alexander-yakushev-patch-1 branch 2 times, most recently from 5c2be2d to 6dc6472 Compare March 9, 2025 21:27
@alexander-yakushev
Copy link
Copy Markdown
Contributor Author

Thank you! I've fixed the bad line and rebased onto the upstream main but tests still don't run for some reason.

@henrygarner
Copy link
Copy Markdown
Collaborator

Apologies, I thought the tests would re-run for you!

We still have a failing proportion-test:

clj:

ERROR in (proportion-test) (core.clj:2315)
expected: (=ish (transduce identity (kixi/proportion neg?) [1 -1 3 5]) 0.25)
  actual: java.lang.ClassCastException: class [J cannot be cast to class java.util.concurrent.Future ([J and java.util.concurrent.Future are in module java.base of loader 'bootstrap')

cljs:

ERROR in (proportion-test) (kixi/stats/core_test.cljc:648:7)
expected: (=ish (transduce identity (kixi/proportion neg?) [1 -1 3 5]) 0.25)
  actual: #object[Error Error: No protocol method IDeref.-deref defined for type array: ,1]

@alexander-yakushev alexander-yakushev force-pushed the alexander-yakushev-patch-1 branch from 6dc6472 to d8c751c Compare March 10, 2025 17:21
@alexander-yakushev
Copy link
Copy Markdown
Contributor Author

Sorry about that! It should pass the tests now.

@henrygarner henrygarner merged commit 693dab5 into MastodonC:main Mar 10, 2025
3 checks passed
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