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

runtime/io.c: remove the hook machinery for channel locking #12446

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

gasche
Copy link
Member

@gasche gasche commented Jul 30, 2023

This is an alternative to #12444: instead of documenting hooks that are now unused by the compiler distribution, we remove them completely.

cc @xavierleroy

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

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

Something looks wrong in cleanup_on_raise.

@@ -1094,17 +1094,17 @@ void caml_output_val(struct channel *chan, value v, value flags)
caml_stat_free(blk);
blk = nextblk;
}
Flush_if_unbuffered(chan);
Copy link
Contributor

Choose a reason for hiding this comment

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

By moving the flush to caml_output_value, you're changing the behavior of caml_output_val, which is exported (not CAML_INTERNAL) and used by the debugger. The debugger manages its own flushing, if I remember correctly, but other potential users may not.

Copy link
Member Author

Choose a reason for hiding this comment

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

The previous code looks fairly strange -- it breaks the convention of all other users of Flush_if_unbuffered that it happens right before we unlock, which is a helpful way to ensure that it happens often enough (no output is forgotten) and yet not too often (we are done with our planned sequence of writes).

If I read things correctly:

  1. caml_output_val is in fact defined in intext.h only when CAML_INTERNALS is set, so we don't need to worry about unknown callers
  2. this call only makes a difference for unbuffered channels, and the debugger does not use unbuffered channels (and indeed, as you mention, has an explicit flush right after the call)

This gives me the impression that the change is a no-op that makes the code more regular and less surprising. (Even after the change, caml_output_val can call a GC through check_pending in io.c, which makes the implementation of safe_output_value in the debugger a bit suspicious, but I don't understand what this is supposed to do and am happy to leave it alone.)

Copy link
Member Author

Choose a reason for hiding this comment

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

(cc @nojb who wrote the original stray flush_if_unbuffered call in #10639 )

Copy link
Contributor

Choose a reason for hiding this comment

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

The mystery of the placement of this flush operation remains... But this should not block this PR. I fixed the conflicts to get a last round of testing.

runtime/io.c Outdated Show resolved Hide resolved
Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@gasche gasche merged commit 2b890ce into ocaml:trunk Aug 29, 2023
9 checks passed
@gasche
Copy link
Member Author

gasche commented Aug 29, 2023

Merged, thanks!

@Octachron
Copy link
Member

Beware that there is a conflict with the io bigarray PR which needs to be fixed.

@gasche
Copy link
Member Author

gasche commented Aug 29, 2023

On it, thanks!

(This is a non-textual conflict, so git did not detect it, but the build on trunk is currently broken.)

@gasche
Copy link
Member Author

gasche commented Aug 29, 2023

Hopefully 76c4617 fixes the build on trunk.

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.

None yet

3 participants