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

Fix #4885 - Rewrite MeasureManager in C++ #4920

Merged
merged 49 commits into from
Sep 28, 2023
Merged

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Jun 23, 2023

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. component - Ruby bindings component - Python bindings labels Jun 23, 2023
@jmarrec jmarrec self-assigned this Jun 23, 2023
@jmarrec jmarrec force-pushed the 4885_MeasureManager_c++ branch 5 times, most recently from 74389ce to ae9c047 Compare June 30, 2023 07:04
@kbenne
Copy link
Contributor

kbenne commented Aug 10, 2023

@jmarrec. Check it out 3c4a1c3 I think this does the trick. I thnk now we just need to do a bunch of testing to make sure the API and behavior is consistent with the original Ruby implementation.

@DavidGoldwasser

src/cli/MeasureManager.cpp Outdated Show resolved Hide resolved
@@ -634,63 +614,54 @@ void MeasureManagerServer::handle_post(web::http::http_request message) {
const std::string uri = toString(web::http::uri::decode(message.relative_uri().path()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can message be passed by reference?

Copy link
Collaborator Author

@jmarrec jmarrec Aug 14, 2023

Choose a reason for hiding this comment

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

Should it be passed by reference is the question. All of the example code passes it by value.
Digging down the source code, this is a PIMPL class. Single member, Source: https://github.com/microsoft/cpprestsdk/blob/9c654889efb6f5bda69fe8f52b3f7d3d3fb56cd8/Release/include/cpprest/http_msg.h#L1573

    std::shared_ptr<http::details::_http_request> _m_impl;

So that'd be the size of two pointers (data + control block) right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@jmarrec jmarrec Aug 14, 2023

Choose a reason for hiding this comment

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

Something trivially_copyable should be passed by val if it's < 16 bytes. The reference count needs to be +1 then -1 here since it's not a POD type, but I would reckon the effect is minimal.

TL;DR: I don't think it matters. But if you prefer passing by ref / const ref, we can do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Case closed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess it is slightly faster though. Here's a benchmark: https://quick-bench.com/q/gek5jMY8CDeiaU41SZIU30beUjM

image

Same locally on my ubuntu gcc

jmarrec added a commit to openstudiocoalition/OpenStudioApplication that referenced this pull request Aug 16, 2023
@jmarrec
Copy link
Collaborator Author

jmarrec commented Aug 24, 2023

@kbenne mac CI has the same crash as I do locally when trying to run a Python measure first THEN a Ruby measure: https://ci.openstudio.net/blue/organizations/jenkins/openstudio-incremental-osx/detail/PR-4920/21/pipeline#step-76-log-7

@kbenne
Copy link
Contributor

kbenne commented Aug 25, 2023

@kbenne mac CI has the same crash as I do locally when trying to run a Python measure first THEN a Ruby measure: https://ci.openstudio.net/blue/organizations/jenkins/openstudio-incremental-osx/detail/PR-4920/21/pipeline#step-76-log-7

I opened a new issue about this, because I think it is a separate issue from the Measure Manager itself. #4945

@jmarrec
Copy link
Collaborator Author

jmarrec commented Aug 25, 2023

Definitely not caused by this PR.
Should we merge this one then?

@kbenne
Copy link
Contributor

kbenne commented Aug 25, 2023

@kflemin is testing right now. After she is done, then I think we can merge @jmarrec

src/cli/MeasureManager.cpp Outdated Show resolved Hide resolved
kbenne and others added 5 commits September 25, 2023 13:30
Use `std::fflush(std::cout)` instead of `std::cout << std::flush`

Co-authored-by: Julien Marrec <julien.marrec@gmail.com>
This issue only pertained to Mac and was occuring when a Python Measure was run before a Ruby Measure.
The fix is to set the dlopen flags to RTLD_LOCAL prior to importing OpenStudio in Python.

Test OpenStudioCLI.Labs.Run_PythonRuby demonstrates the original issue and will now pass.

close #4945
@jmarrec jmarrec merged commit b7fb557 into develop Sep 28, 2023
5 of 6 checks passed
@jmarrec jmarrec deleted the 4885_MeasureManager_c++ branch September 28, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - CLI component - Python bindings component - Ruby bindings Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite MeasureManager in C++
4 participants