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

small cleanups #2062

Merged
merged 1 commit into from Aug 31, 2022
Merged

small cleanups #2062

merged 1 commit into from Aug 31, 2022

Conversation

icristescu
Copy link
Contributor

@icristescu icristescu commented Aug 30, 2022

IIRC, we used to reload the mapping file in the dispatcher, and for that we needed a register_mapping_consumers. Now the dispatcher gets the updated mapping from the file manager at every read, so there is no need for mapping_consumers.

Part of #2039.

@icristescu icristescu added the no-changelog-needed No changelog is needed here label Aug 30, 2022
@@ -593,7 +593,8 @@ module Maker (Config : Conf.S) = struct
implementation detail. This is safe since the callback
[f] is attached to [t.running_gc.promise], which is
referenced for the lifetime of a GC process. *)
let _ = Lwt.bind x.promise f in
let p = Lwt.bind x.promise f in
Lwt.on_success p Fun.id;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@metanivek what do you think about this change? or we could instead use on_failure to log a message.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is unnecessary -- what is this line gaining for us? We could log a message on failure, but I don't see a reason to do so at this call site.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're probably right its unnecessary, I removed it

Copy link
Member

Choose a reason for hiding this comment

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

👍 To explain my reasoning (which is open to critique if it is not accurate!): x.promise (and x.resolver) exist just so that users can run code when a GC finalizes. The call to Lwt.bind attaches f to x.promise which means f will execute when we call Lwt.wakeup_later x.resolver. Lwt.on_success p Fun.id just adds Fun.id to create this promise chain: x.promise -> f -> Fun.id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the explanation, makes sense. It was a "tentative" suggestion, I agree that adding a Fun.id is useless. I'm just not used on not waiting on lwt promises, in case something goes wrong. But in this case, f can add logs messages if it needs to.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'll admit that it's a bit of an atypical usage of Lwt in that it is only using the promise part. Logging (and/or event reporting) is exactly how this callback is used in the Tezos integration.

@codecov-commenter
Copy link

Codecov Report

Merging #2062 (5bcec24) into main (5374885) will increase coverage by 0.00%.
The diff coverage is 66.66%.

@@           Coverage Diff           @@
##             main    #2062   +/-   ##
=======================================
  Coverage   64.34%   64.35%           
=======================================
  Files         131      131           
  Lines       15584    15577    -7     
=======================================
- Hits        10028    10024    -4     
+ Misses       5556     5553    -3     
Impacted Files Coverage Δ
src/irmin-pack/unix/ext.ml 66.47% <0.00%> (-0.19%) ⬇️
src/irmin-pack/unix/file_manager.ml 83.90% <100.00%> (+1.23%) ⬆️
src/irmin-test/store.ml 94.82% <0.00%> (-0.06%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@icristescu icristescu merged commit 8965036 into mirage:main Aug 31, 2022
@icristescu icristescu deleted the small_clean branch August 31, 2022 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-needed No changelog is needed here
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants