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

make-profile-works-too-slow #31

Closed
wants to merge 1 commit into from

Conversation

frolui
Copy link
Collaborator

@frolui frolui commented Jul 2, 2024

Summary by CodeRabbit

  • Chores
    • Added detailed logging to track execution times and line numbers for debugging purposes.

Copy link

coderabbitai bot commented Jul 2, 2024

Walkthrough

The changes in the make_profiler/__main__.py file involve the addition of datetime-stamped print statements at various points in the main function. These adjustments seem to be for debugging or logging purposes, helping track the progression and specific lines executed during the program run. The core functionality and logic of the program remain unchanged.

Changes

File Summary
make_profiler/__main__.py Added multiple datetime-stamped print statements to the main function for debugging/logging purposes.

Poem

In code's embrace, where logic flows,
Debugging sparks with timely shows.
🐇 Adds print lines, dates, and time,
To trace the steps, the peak, the climb.

With timestamps clear, no bug can hide,
Profiler's path, now deftly spied. ⏰


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@frolui frolui changed the title Add ugly journalization to check the execution make-profile-works-too-slow Jul 2, 2024
@frolui frolui closed this Jul 2, 2024
Copy link

@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: 12

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between ca1c3bf and d4c8e57.

Files selected for processing (1)
  • make_profiler/main.py (3 hunks)
Additional context used
Ruff
make_profiler/__main__.py

68-68: datetime.datetime.now() called without a tz argument

(DTZ005)


80-80: datetime.datetime.now() called without a tz argument

(DTZ005)


85-85: datetime.datetime.now() called without a tz argument

(DTZ005)


90-90: datetime.datetime.now() called without a tz argument

(DTZ005)


92-92: Consider iterable unpacking instead of concatenation

Replace with iterable unpacking

(RUF005)


94-94: subprocess call: check for execution of untrusted input

(S603)


96-96: datetime.datetime.now() called without a tz argument

(DTZ005)


97-100: Unnecessary list comprehension (rewrite as a dict comprehension)

Rewrite as a dict comprehension

(C404)


101-101: datetime.datetime.now() called without a tz argument

(DTZ005)


103-103: datetime.datetime.now() called without a tz argument

(DTZ005)


108-108: datetime.datetime.now() called without a tz argument

(DTZ005)


120-120: datetime.datetime.now() called without a tz argument

(DTZ005)


123-123: Trailing comma missing

Add trailing comma

(COM812)


126-126: datetime.datetime.now() called without a tz argument

(DTZ005)

Additional comments not posted (2)
make_profiler/__main__.py (2)

94-94: Check for execution of untrusted input in subprocess call.

Ensure that the input to subprocess.call is trusted to avoid security vulnerabilities.

Is the unknown_args list sanitized or validated before being passed to subprocess.call?

Tools
Ruff

94-94: subprocess call: check for execution of untrusted input

(S603)


123-123: Add trailing comma.

Add a trailing comma for better readability and to avoid potential syntax errors when adding new elements to the list in the future.

-        docs
+        docs,
Tools
Ruff

123-123: Trailing comma missing

Add trailing comma

(COM812)

if args.preprocess_only:
print(out_file.getvalue())
return

print(datetime.now(), 90)
if args.target is not None:
cmd = ['make'] + unknown_args + ['-f', out_file.name, args.target]
Copy link

Choose a reason for hiding this comment

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

Consider iterable unpacking instead of concatenation.

Replace with iterable unpacking for better readability and performance.

-        cmd = ['make'] + unknown_args + ['-f', out_file.name, args.target]
+        cmd = ['make', *unknown_args, '-f', out_file.name, args.target]
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cmd = ['make'] + unknown_args + ['-f', out_file.name, args.target]
cmd = ['make', *unknown_args, '-f', out_file.name, args.target]
Tools
Ruff

92-92: Consider iterable unpacking instead of concatenation

Replace with iterable unpacking

(RUF005)

if args.preprocess_only:
print(out_file.getvalue())
return

print(datetime.now(), 90)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 90)
+    print(datetime.now(tz=timezone.utc), 90)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(datetime.now(), 90)
print(datetime.now(tz=timezone.utc), 90)
Tools
Ruff

90-90: datetime.datetime.now() called without a tz argument

(DTZ005)

if args.target is not None:
cmd = ['make'] + unknown_args + ['-f', out_file.name, args.target]
logger.info(' '.join(cmd))
subprocess.call(cmd)

print(datetime.now(), 96)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 96)
+    print(datetime.now(tz=timezone.utc), 96)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(datetime.now(), 96)
print(datetime.now(tz=timezone.utc), 96)
Tools
Ruff

96-96: datetime.datetime.now() called without a tz argument

(DTZ005)

deps, influences, order_only, indirect_influences = get_dependencies_influences(ast)

dot_file = io.StringIO()

print(datetime.now(), 108)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 108)
+    print(datetime.now(tz=timezone.utc), 108)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(datetime.now(), 108)
print(datetime.now(tz=timezone.utc), 108)
Tools
Ruff

108-108: datetime.datetime.now() called without a tz argument

(DTZ005)

@@ -108,11 +117,13 @@ def main(argv=sys.argv[1:]):
)
dot_file.seek(0)

print(datetime.now(), 120)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 120)
+    print(datetime.now(tz=timezone.utc), 120)

Committable suggestion was skipped due to low confidence.

Tools
Ruff

120-120: datetime.datetime.now() called without a tz argument

(DTZ005)

docs = dict([
(i[1]['target'], i[1]['docs'])
for i in ast if i[0] == 'target'
])
print(datetime.now(), 101)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 101)
+    print(datetime.now(tz=timezone.utc), 101)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(datetime.now(), 101)
print(datetime.now(tz=timezone.utc), 101)
Tools
Ruff

101-101: datetime.datetime.now() called without a tz argument

(DTZ005)

@@ -64,6 +64,8 @@ def main(argv=sys.argv[1:]):
type=int,
default=20,
help='Depth of the nesting includes')

print(datetime.now(), 68)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 68)
+    print(datetime.now(tz=timezone.utc), 68)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(datetime.now(), 68)
print(datetime.now(tz=timezone.utc), 68)
Tools
Ruff

68-68: datetime.datetime.now() called without a tz argument

(DTZ005)

ast = parse(in_file, args.disable_loop_detection, args.include_depth)
generate_makefile(ast, out_file, args.db_filename)
out_file.flush()

print(datetime.now(), 85)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 85)
+    print(datetime.now(tz=timezone.utc), 85)

Committable suggestion was skipped due to low confidence.

Tools
Ruff

85-85: datetime.datetime.now() called without a tz argument

(DTZ005)

Comment on lines 97 to 100
docs = dict([
(i[1]['target'], i[1]['docs'])
for i in ast if i[0] == 'target'
])
Copy link

Choose a reason for hiding this comment

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

Rewrite as a dict comprehension.

The list comprehension can be simplified to a dictionary comprehension for better readability and performance.

-    docs = dict([
-        (i[1]['target'], i[1]['docs'])
-        for i in ast if i[0] == 'target'
-    ])
+    docs = {i[1]['target']: i[1]['docs'] for i in ast if i[0] == 'target'}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docs = dict([
(i[1]['target'], i[1]['docs'])
for i in ast if i[0] == 'target'
])
docs = {i[1]['target']: i[1]['docs'] for i in ast if i[0] == 'target'}
Tools
Ruff

97-100: Unnecessary list comprehension (rewrite as a dict comprehension)

Rewrite as a dict comprehension

(C404)

@@ -75,28 +77,35 @@ def main(argv=sys.argv[1:]):
else:
out_file = tempfile.NamedTemporaryFile(mode='w+')

print(datetime.now(), 80)
Copy link

Choose a reason for hiding this comment

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

Use timezone-aware datetime.now().

The datetime.now() function is called without a tz argument, which can lead to timezone issues. Consider using datetime.now(tz=timezone.utc) or another appropriate timezone.

-    print(datetime.now(), 80)
+    print(datetime.now(tz=timezone.utc), 80)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(datetime.now(), 80)
print(datetime.now(tz=timezone.utc), 80)
Tools
Ruff

80-80: datetime.datetime.now() called without a tz argument

(DTZ005)

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.

1 participant