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 cljam.io.util.bin #201

Merged
merged 1 commit into from
Jun 15, 2020
Merged

Refactor cljam.io.util.bin #201

merged 1 commit into from
Jun 15, 2020

Conversation

alumi
Copy link
Member

@alumi alumi commented Jun 10, 2020

Summary

Refactored cljam.io.util.bin

Changes

  • Rearrange functions
  • Add docstrings
  • Add tests

Tests

  • lein check
  • lein test :all
  • lein cloverage
  • lein eastwood
  • lein cljfmt check

@alumi alumi requested a review from niyarin June 10, 2020 03:55
@alumi alumi requested a review from a team as a code owner June 10, 2020 03:55
@alumi alumi requested review from athos and removed request for a team June 10, 2020 03:55
Copy link
Contributor

@niyarin niyarin left a comment

Choose a reason for hiding this comment

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

LGTM:+1:

@codecov
Copy link

codecov bot commented Jun 12, 2020

Codecov Report

Merging #201 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
+ Coverage   86.91%   86.94%   +0.02%     
==========================================
  Files          77       77              
  Lines        6267     6266       -1     
  Branches      520      518       -2     
==========================================
+ Hits         5447     5448       +1     
  Misses        300      300              
+ Partials      520      518       -2     
Impacted Files Coverage Δ
src/cljam/io/util/bin.clj 98.07% <100.00%> (+3.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84a535d...aa62440. Read the comment docs.

Copy link
Member

@athos athos left a comment

Choose a reason for hiding this comment

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

Thanks for refactoring! 💪

Just to confirm, memoization for reg->bins was dropped, but is it intended?
If so (probably so), could you elaborate a little more on the reason just for future reference? It messed up the performance improvement by unboxed function calls? You were concerned about its memory consumption? Or for any other reason?

src/cljam/io/util/bin.clj Outdated Show resolved Hide resolved
@alumi
Copy link
Member Author

alumi commented Jun 15, 2020

Just to confirm, memoization for reg->bins was dropped, but is it intended?
If so (probably so), could you elaborate a little more on the reason just for future reference? It messed up the performance improvement by unboxed function calls? You were concerned about its memory consumption? Or for any other reason?

Ah, sorry I forgot to mention that 🙇
The changes to reg->bins are intentional.

  • I fixed it to use transduce to speed it up by 1.5x-2x.
  • I decided to remove the memoize because it's not repeatedly called and it likely to have a high cache miss rate (not well tested). reg->bins* was fast (~10 μs) enough by itself compared to actual file I/O ops. As you said, this will benefit reducing CPU overhead and memory leak.
  • I made it public to balance with reg->bin.

@athos
Copy link
Member

athos commented Jun 15, 2020

Thank you for describing your decisions behind the refinements! They all sound reasonable to me 🙆‍♂️

I decided to remove the memoize because it's not repeatedly called and it likely to have a high cache miss rate (not well tested).

Yeah, I can imagine that. The (beg, end) space in general might be too sparse for memoization to work effectively (which depends heavily on how reg->bins is used, though). But even without built-in memoization, users can memoize the function on their own if they really need.

@athos athos merged commit 61499c8 into master Jun 15, 2020
@athos athos deleted the fix/refactor-bin branch June 15, 2020 08:17
@alumi
Copy link
Member Author

alumi commented Jun 15, 2020

Thank you for reviewing! 😸 @niyarin @athos

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.

3 participants