Skip to content

[Feature] Log Communication overhead #671

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

Merged
merged 6 commits into from
Jun 14, 2025
Merged

Conversation

jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Jun 9, 2025

Example:

from executorlib import SingleNodeExecutor

with SingleNodeExecutor(log_obj_size=True) as exe:
    future = exe.submit(sum, [1, 1])
    print(future.result())

log warnings:

Send dictionary of size: 101
Received dictionary of size: 59
Send dictionary of size: 69
Received dictionary of size: 58

Result:

2

Summary by CodeRabbit

  • New Features
    • Added an option to enable logging of object sizes during communication for various executors and interfaces. This can be activated with a new parameter in relevant constructors and functions.
  • Documentation
    • Updated docstrings to describe the new logging parameter.
  • Tests
    • Enhanced tests to cover scenarios with and without object size logging enabled.

@jan-janssen jan-janssen marked this pull request as draft June 9, 2025 23:31
Copy link
Contributor

coderabbitai bot commented Jun 9, 2025

Walkthrough

A new log_obj_size boolean parameter was introduced across multiple executor classes, functions, and communication interfaces to enable optional logging of the size of serialized objects during communication. This parameter is now propagated through constructors, factory functions, and internal calls, and is reflected in both implementation and test code.

Changes

File(s) Change Summary
executorlib/executor/flux.py, executorlib/executor/single.py, executorlib/executor/slurm.py Added log_obj_size parameter to executor classes and their factory functions; updated docstrings.
executorlib/standalone/interactive/communication.py Extended SocketInterface and interface_bootup to accept and use log_obj_size for logging object sizes.
executorlib/task_scheduler/interactive/shared.py Added log_obj_size to execute_tasks function and propagated to interface_bootup.
tests/test_singlenodeexecutor_dependencies.py Added 'log_obj_size': False to expected executor info in test setup.
tests/test_standalone_interactive_communication.py Refactored and split test to cover both log_obj_size=False and log_obj_size=True interface scenarios.

Poem

In a warren of code, a new flag appears,
To measure our bytes and quiet our fears.
Now rabbits can log, with a hop and a cheer,
The size of each object, both far and near.
Debugging made simple, with just one more trace—
Hooray for the flag in our code’s cozy place!
🐇💻📏

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.85%. Comparing base (2133af3) to head (89b2ad2).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #671      +/-   ##
==========================================
+ Coverage   96.82%   96.85%   +0.03%     
==========================================
  Files          29       29              
  Lines        1292     1305      +13     
==========================================
+ Hits         1251     1264      +13     
  Misses         41       41              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jan-janssen jan-janssen marked this pull request as ready for review June 10, 2025 03:04
@jan-janssen jan-janssen changed the title [Debug] Log Communication overhead [Feature] Log Communication overhead Jun 10, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
executorlib/standalone/interactive/communication.py (2)

43-46: Consider using more efficient logging practices.

The logging implementation works correctly but could be improved for better performance and consistency with Python logging best practices.

Consider using f-strings or logger formatting instead of string concatenation:

-        if self._logger is not None:
-            self._logger.warning("Send dictionary of size: " + str(sys.getsizeof(data)))
+        if self._logger is not None:
+            self._logger.warning("Send dictionary of size: %d", sys.getsizeof(data))

55-60: Apply consistent logging formatting.

Similar to the send_dict method, the logging here could benefit from more efficient formatting.

Apply the same formatting improvement:

-        if self._logger is not None:
-            self._logger.warning(
-                "Received dictionary of size: " + str(sys.getsizeof(data))
-            )
+        if self._logger is not None:
+            self._logger.warning("Received dictionary of size: %d", sys.getsizeof(data))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 609d185 and 89b2ad2.

📒 Files selected for processing (7)
  • executorlib/executor/flux.py (8 hunks)
  • executorlib/executor/single.py (7 hunks)
  • executorlib/executor/slurm.py (8 hunks)
  • executorlib/standalone/interactive/communication.py (8 hunks)
  • executorlib/task_scheduler/interactive/shared.py (2 hunks)
  • tests/test_singlenodeexecutor_dependencies.py (1 hunks)
  • tests/test_standalone_interactive_communication.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
executorlib/task_scheduler/interactive/shared.py (1)
executorlib/standalone/interactive/communication.py (1)
  • interface_bootup (134-179)
tests/test_standalone_interactive_communication.py (10)
executorlib/standalone/serialize.py (1)
  • cloudpickle_register (9-28)
tests/test_fluxjobexecutor.py (1)
  • calc (19-20)
tests/test_fluxpythonspawner.py (1)
  • calc (23-24)
tests/test_interactive_dependencies.py (1)
  • calc (15-16)
tests/test_mpiexecspawner.py (1)
  • calc (28-29)
tests/test_backend_interactive_serial.py (1)
  • calc (10-11)
tests/test_singlenodeexecutor_mpi.py (1)
  • calc (14-15)
tests/test_singlenodeexecutor_noblock.py (1)
  • calc (7-8)
executorlib/standalone/interactive/communication.py (5)
  • SocketInterface (10-131)
  • bootup (90-102)
  • bind_to_random_port (80-88)
  • send_and_receive_dict (66-78)
  • shutdown (104-124)
executorlib/standalone/interactive/spawner.py (1)
  • MpiExecSpawner (138-155)
🔇 Additional comments (11)
tests/test_singlenodeexecutor_dependencies.py (1)

344-344: LGTM! Test coverage properly updated.

The addition of 'log_obj_size': False to the expected info dictionary correctly reflects the new parameter in the SingleNodeExecutor and maintains test coverage.

executorlib/task_scheduler/interactive/shared.py (1)

26-27: LGTM! Parameter integration is well-implemented.

The log_obj_size parameter is properly added with:

  • Appropriate default value (False) for a debug feature
  • Clear documentation explaining its purpose
  • Correct propagation to the interface_bootup function

This change effectively integrates the debug logging capability into the task execution flow.

Also applies to: 46-47, 54-54

executorlib/executor/single.py (1)

94-95: LGTM! Comprehensive and consistent parameter integration.

The log_obj_size parameter is thoroughly integrated throughout the SingleNodeExecutor implementation:

  • Added to both class constructor and factory function with proper defaults
  • Well-documented in docstrings
  • Correctly propagated through both dependency and non-dependency execution paths
  • Properly included in resource_dict for downstream consumption

The systematic approach ensures the debug feature is available regardless of the execution mode chosen.

Also applies to: 135-136, 162-163, 182-183, 195-196, 227-228, 237-238

executorlib/executor/slurm.py (1)

239-240: LGTM! Consistent implementation for interactive SLURM execution.

The log_obj_size parameter is properly integrated into SlurmJobExecutor:

  • Systematic addition to constructor and factory function with appropriate defaults
  • Comprehensive documentation updates
  • Correct propagation through both dependency execution paths
  • Proper inclusion in resource_dict

Note: The parameter is intentionally not added to SlurmClusterExecutor, which uses file-based execution that likely doesn't support communication logging.

Also applies to: 275-276, 320-321, 347-348, 367-368, 380-381, 416-417, 426-427

executorlib/executor/flux.py (1)

64-65: LGTM! Consistent implementation following established patterns.

The log_obj_size parameter is properly integrated into FluxJobExecutor:

  • Complete parameter addition with appropriate defaults and documentation
  • Systematic propagation through dependency and non-dependency execution paths
  • Correct inclusion in resource_dict for downstream usage

The implementation follows the same pattern as other executors, where only the "Job" variants (interactive execution) receive the parameter, while "Cluster" variants (file-based execution) do not.

Also applies to: 104-105, 149-150, 180-181, 204-205, 400-401, 436-437, 451-452

tests/test_standalone_interactive_communication.py (2)

59-87: Good test structure for the new logging feature.

The test renaming and expansion appropriately covers the existing functionality while explicitly setting log_obj_size=False to test the disabled state. The explicit bootup/shutdown calls improve test clarity.


88-115: Well-structured test for the debug logging feature.

The new test method correctly verifies that the interface functions properly with log_obj_size=True enabled. The test structure mirrors the non-debug version, ensuring consistent behavior across both modes.

executorlib/standalone/interactive/communication.py (4)

1-1: Appropriate import addition for the logging functionality.

The logging import is correctly added to support the new debug logging feature.


16-16: Well-documented parameter addition.

The docstring clearly explains the purpose of the new log_obj_size parameter, and the constructor signature includes an appropriate default value of False.

Also applies to: 19-19


29-33: Clean conditional logger initialization.

The logger is appropriately created only when needed, using a reasonable logger name "executorlib". Setting _logger to None when disabled provides a clean way to check if logging is active.


138-138: Proper parameter propagation through the interface.

The log_obj_size parameter is correctly added to the interface_bootup function signature, documented appropriately, and properly passed to the SocketInterface constructor. This ensures the feature works consistently across the entire communication stack.

Also applies to: 154-154, 168-171

@jan-janssen jan-janssen mentioned this pull request Jun 13, 2025
@jan-janssen jan-janssen merged commit 09a61b7 into main Jun 14, 2025
94 of 99 checks passed
@jan-janssen jan-janssen deleted the log_communication_overhead branch June 14, 2025 04:16
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