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

Python Driver : Antlr4ResultHandler Initialization Optimization #1106

Closed
Munmud opened this issue Jul 27, 2023 · 3 comments
Closed

Python Driver : Antlr4ResultHandler Initialization Optimization #1106

Munmud opened this issue Jul 27, 2023 · 3 comments
Labels
enhancement New request

Comments

@Munmud
Copy link
Contributor

Munmud commented Jul 27, 2023

Issue Summary:
Currently, in our python driver codebase, the Antlr4ResultHandler is being initialized afresh for every query made. This leads to unnecessary overhead as the handler's initialization process is repeated needlessly. To improve the overall performance and reduce execution time, we should explore the possibility of initializing the Antlr4ResultHandler only once and then reusing it for subsequent queries.

Issue Details:
The Antlr4ResultHandler plays a crucial role in processing and handling query results using the ANTLR (ANother Tool for Language Recognition) library. However, the current implementation initializes a new handler instance each time a query is executed. This approach proves to be suboptimal, especially in scenarios where multiple queries are processed in succession or in a short timeframe.

Expected Behavior:
The ideal behavior we aim to achieve is to initialize the Antlr4ResultHandler only once during the application's lifecycle or upon the first query execution. Subsequently, we can reuse this pre-initialized handler for all subsequent queries, avoiding redundant instantiation.

Potential Benefits

  • Reduced Overhead: Avoiding repeated initialization of the handler will significantly reduce overhead and improve the efficiency of query processing.
  • Improved Performance: Reusing the pre-initialized handler will result in faster response times for subsequent queries, providing a smoother user experience.
  • Resource Efficiency: Conserving resources by reusing the handler will lead to better resource utilization and overall system stability.
  • Code Readability and Maintainability: Implementing a shared, initialized handler will result in cleaner and more maintainable code, as it reduces redundant code blocks and promotes modularization.
@Munmud Munmud added the enhancement New request label Jul 27, 2023
@Munmud
Copy link
Contributor Author

Munmud commented Jul 27, 2023

Please assign me to the task

@M4rcxs
Copy link
Contributor

M4rcxs commented Jul 27, 2023

the singleton pattern sounds a good way to solve this.

resultHandler = None

good job!

@Munmud
Copy link
Contributor Author

Munmud commented Sep 11, 2023

Closing the issue as Fixed

@Munmud Munmud closed this as completed Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New request
Projects
None yet
Development

No branches or pull requests

2 participants