Skip to content

[bindings] Enhancement: add an optional logging callback to demi_args_t #1535

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

kyleholohan
Copy link
Contributor

This PR adds a callback function to demi_args_t. If specified by the caller, it will be invoked by flexi_logger for all logging calls, as oppose to printing to stdout.

@kyleholohan kyleholohan added the enhancement Enhancement Request on an Existing Feature label Apr 25, 2025
@kyleholohan kyleholohan self-assigned this Apr 25, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the bindings by adding an optional logging callback to demi_args_t, allowing log messages to be routed to a caller-specified C callback rather than stdout.

  • Updated the sizes macro in tests/c/sizes.c to account for the new logging callback field.
  • Added demi_log_callback_t and updated demi_args_t in src/rust/runtime/types/mod.rs.
  • Extended logging initialization in src/rust/runtime/logging.rs and demi_init in src/rust/demikernel/bindings.rs to support the new callback.
  • Updated the C header in include/demi/types.h to include the new logging callback type and related enum values.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/c/sizes.c Updated DEMI_ARGS_SIZE macro, now adding the callback size twice.
src/rust/runtime/types/mod.rs Added a new logging callback type and a field in demi_args_t.
src/rust/runtime/logging.rs Implemented a new LogWriter that routes logs to the C callback.
src/rust/demikernel/bindings.rs Modified demi_init to call custom_initialize when a callback is provided.
include/demi/types.h Added enum and typedef for the logging callback.

@kyleholohan kyleholohan force-pushed the enhancement-log-callback branch from 4d5a585 to e5cea45 Compare April 28, 2025 17:18
Copy link

libos = catpowder
commit id = e5cea45

collapsed_stack num_calls cycles_per_call nanoseconds_per_call total_duration percent_total_duration total_duration_exclusive percent_total_duration_exclusive
bgc::inetstack::poll;inetstack::layer4::poll_once 19484143 700 279 12478775747 46 12472771960 85
bgc::inetstack::poll 9742071 1618 644 14534823404 54 2056047657 14
ioc::network::libos::push 16256 2794 1138 49026013 0 49026013 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch 5310 2975 1162 6105546 0 6101794 0
bgc::inetstack::tcp::established::background;tcp::established::background::retransmitter 11086 421 167 5154576 0 5154576 0
ioc::network::libos::pop 9047 471 187 3551185 0 3551185 0
bgc::inetstack::tcp::established::background;tcp::established::background::acknowledger 11096 683 262 3173659 0 3173659 0
bgc::inetstack::tcp::established::background 11096 1832 714 12305022 0 3114080 0
ioc::network::libos::connect 42 40142 15957 1722898 0 1722898 0
ioc::network::libos::pushto 384 5365 2136 1703404 0 1703404 0
demikernel::sgaalloc 6503 202 79 1024954 0 1024954 0
bgc::inetstack::tcp::passiveopen::background 42 29625 11879 995533 0 995533 0
bgc::inetstack::tcp::established::background;tcp::established::background::sender 11042 930 357 862708 0 862708 0
demikernel::sgafree 8759 92 37 676103 0 676103 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch;udp::receive 286 271 107 73799 0 73799 0
ioc::network::libos::close 47 2911 1159 68022 0 68022 0
ioc::network::libos::accept 38 2476 996 56748 0 56748 0
bgc::inetstack::arp::background 8 3100 1238 17860 0 17860 0
bgc::inetstack::icmp::background 1 1942 772 2104 0 2104 0

Copy link

libos = catnip
commit id = e5cea45

collapsed_stack num_calls cycles_per_call nanoseconds_per_call total_duration percent_total_duration total_duration_exclusive percent_total_duration_exclusive
bgc::inetstack::poll;inetstack::layer4::poll_once;catnip::runtime::receive 29180936 200 79 5603974109 19 5603974109 43
bgc::inetstack::poll;inetstack::layer4::poll_once 29180936 376 149 10360581305 36 4751568469 36
bgc::inetstack::poll 14590468 939 371 13058813147 45 2698231842 21
ioc::network::libos::push 16185 1086 436 17548078 0 15420800 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch 2489 3622 1417 5124129 0 5104702 0
bgc::inetstack::tcp::established::background;tcp::established::background::retransmitter 11087 333 132 4515118 0 4513950 0
bgc::inetstack::tcp::established::background;tcp::established::background::acknowledger 11100 460 188 2887560 0 2860002 0
ioc::network::libos::pop 9047 375 149 2747076 0 2747076 0
bgc::inetstack::tcp::established::background 11100 1223 490 10801765 0 2729448 0
ioc::network::libos::push;catnip::runtime::transmit 8777 305 123 2309616 0 2309616 0
ioc::network::libos::connect 42 32838 13269 1359267 0 1305346 0
demikernel::sgaalloc 6503 134 54 713120 0 713120 0
bgc::inetstack::tcp::established::background;tcp::established::background::sender 11045 313 121 669639 0 658860 0
demikernel::sgafree 8759 81 32 654233 0 654233 0
bgc::inetstack::tcp::passiveopen::background 42 25469 10130 609182 0 555856 0
ioc::network::libos::pushto 384 2117 856 592799 0 458791 0
ioc::network::libos::pushto;catnip::runtime::transmit 384 776 309 134008 0 134008 0
bgc::inetstack::tcp::established::background;tcp::established::background::acknowledger;catnip::runtime::transmit 36 1318 544 118713 0 118713 0
ioc::network::libos::close 49 2601 1036 58456 0 58456 0
ioc::network::libos::connect;catnip::runtime::transmit 42 5869 2332 53921 0 53921 0
bgc::inetstack::tcp::passiveopen::background;catnip::runtime::transmit 21 15640 6249 53325 0 53325 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch;udp::receive 224 244 95 50140 0 50140 0
ioc::network::libos::accept 37 2311 925 49570 0 49570 0
bgc::inetstack::arp::background 7 3546 1402 22680 0 22680 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch;catnip::runtime::transmit 36 721 289 17782 0 17782 0
bgc::inetstack::tcp::established::background;tcp::established::background::sender;catnip::runtime::transmit 21 601 239 10779 0 10779 0
bgc::inetstack::tcp::established::background;tcp::established::background::retransmitter;catnip::runtime::transmit 14 1747 679 5948 0 5948 0
bgc::inetstack::icmp::background 1 1692 670 1877 0 1877 0

Copy link
Contributor

@iyzhang iyzhang left a comment

Choose a reason for hiding this comment

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

This looks great. thanks for doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement Request on an Existing Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants