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

HPCC-31548 Improve qualifyMethodName in HIDL generated code for ESP services #18727

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

kenrowland
Copy link
Contributor

@kenrowland kenrowland commented Jun 4, 2024

Added a map for method name lookup to speed up qualification

Signed-Off-By: Kenneth Rowland [email protected]

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Copy link

github-actions bot commented Jun 4, 2024

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-31548

Jirabot Action Result:
Workflow Transition: Merge Pending
Updated PR

@kenrowland kenrowland requested a review from asselitx June 4, 2024 14:47
Copy link
Contributor

@asselitx asselitx 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 like a good improvement. It seems likely to benefit runtime efficiency (especially in the case you outlined in the ticket) in addition to removing hundreds of lines of code from the hidl-generated output. Just don't forget to take out your commented code before the final push.

@kenrowland
Copy link
Contributor Author

@ghalliday please merge

@kenrowland kenrowland changed the title HPCC-31548 Improve qualifyMethodName in HIDL genreated code for ESP services HPCC-31548 Improve qualifyMethodName in HIDL generated code for ESP services Jun 5, 2024
Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

I think worth moving the bulk of this code out of the generated code.

@@ -4060,6 +4062,8 @@ void EspServInfo::write_esp_binding_ipp()
outf("#endif\n");
}

outs("\tstd::map<std::string, std::string> m_qualifiedMethodNames;\n");
Copy link
Member

Choose a reason for hiding this comment

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

This would be better off in CHttpSoapBinding, along with the function qualifyMethodName().

It would avoid duplication, and make the code easier to review - since it would be compiled.

for (mthi=methods; mthi!= nullptr; mthi=mthi->next)
{
std::string methodNameKey(mthi->getName());
std::transform(methodNameKey.cbegin(), methodNameKey.cend(), methodNameKey.begin(), tolower);
Copy link
Member

Choose a reason for hiding this comment

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

A helper function could also be added to make this code cleaner/simpler.

outf("\taddMethod("%s");\n", mthi->getName());

Even better would be

CHttpSoapBinding::registerMethods(std::initializer_list<const char *> methods)
...
init_maps()
{
registerMethods({"a","b","c","d"});
}

@kenrowland
Copy link
Contributor Author

@ghalliday Had a discussion with Terrance on moving this functionality to the parent class as mentioned above. I wanted to get a point of view from ESDL services. Currently their implementation provides an implementation for the qualify method name, but doesn't do anything. Generally, the implementation optimized by this PR is for HIDL generated services. If this is still something you think we should move, let me know and we'll move it to the parent class.

@ghalliday
Copy link
Member

@ghalliday Had a discussion with Terrance on moving this functionality to the parent class as mentioned above. I wanted to get a point of view from ESDL services. Currently their implementation provides an implementation for the qualify method name, but doesn't do anything. Generally, the implementation optimized by this PR is for HIDL generated services. If this is still something you think we should move, let me know and we'll move it to the parent class.

So if this was moved to the base class it would be ignored by ESDL services because they override the function? I don't think that is a problem. Or are you saying that the this would override the implementation in a further base class?

I think we should be moving the code so it is not being generated lots of times. If necessary you could introduce a new intermediate base class. If you want to talk through the details (particularly if I have missed the main point) please IM me, or arrange a meeting to talk it through.

@kenrowland
Copy link
Contributor Author

I will move the functionality into the parent class.

@kenrowland kenrowland force-pushed the HPCC-31548 branch 2 times, most recently from 2831bc0 to fbdd963 Compare July 1, 2024 14:40
@kenrowland kenrowland requested a review from asselitx July 1, 2024 14:41
Copy link
Contributor

@asselitx asselitx left a comment

Choose a reason for hiding this comment

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

Aside from the one comment/question I had this looks good.

@@ -4060,6 +4059,8 @@ void EspServInfo::write_esp_binding_ipp()
outf("#endif\n");
}

outs("\tstd::map<std::string, std::string> m_qualifiedMethodNames;\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you remove this from here since you have the member in the new CHttpSoapHidlBinding base class?

@kenrowland kenrowland requested review from ghalliday and asselitx July 8, 2024 14:08
Copy link
Member

@ghalliday ghalliday 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. Please squash. Do you have any idea of the impact on generated code size?

@kenrowland
Copy link
Contributor Author

@ghalliday Please merge.

As far as size impact, I don't think it is that much. The greater impact is the optimization of qualifying the method name using a map as opposed to sequential if statements until there is a match.

@ghalliday
Copy link
Member

@kenrowland this is failing to build on windows (see the failing test above).

@kenrowland kenrowland force-pushed the HPCC-31548 branch 2 times, most recently from afa32c5 to f0a43ce Compare August 29, 2024 12:57
…ervices

Added a map for method name lookup to speed up qualification

Signed-Off-By: Kenneth Rowland [email protected]
@kenrowland
Copy link
Contributor Author

@ghalliday Passes windows build now

@ghalliday ghalliday merged commit d99fbf0 into hpcc-systems:master Aug 29, 2024
48 checks passed
@ghalliday
Copy link
Member

@kenrowland there reallly should be a tolower function in jlib that can be called instead of replicating the code.

@kenrowland
Copy link
Contributor Author

@ghalliday Based on your previous comment, would you like me to look into adding a tolower function to jlib?

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.

3 participants