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

[LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer in SiPixelFakeGenErrorDBObjectESSource::produce and SiPixelTemplateDBObjectReader::analyze #46181

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

iarspider
Copy link
Contributor

PR description:

LLVM report: link

PR validation:

Bot tests

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 1, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 1, 2024

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 1, 2024

A new Pull Request was created by @iarspider for master.

It involves the following packages:

  • CalibTracker/SiPixelESProducers (alca)

@atpathak, @cmsbuild, @consuegs, @perrotta can you please review it and eventually sign? Thanks.
@dkotlins, @ferencek, @mmusich, @mroguljic, @rsreds, @tocheng, @tsusa, @tvami, @yuanchao this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

@@ -35,9 +34,9 @@ std::unique_ptr<SiPixelGenErrorDBObject> SiPixelFakeGenErrorDBObjectESSource::pr
// open the GenError file(s)
for (m = 0; m < obj->numOfTempl(); ++m) {
edm::FileInPath file(GenErrorCalibrations_[m].c_str());
tempfile = (file.fullPath()).c_str();
std::string tempfile = file.fullPath();
Copy link
Contributor

Choose a reason for hiding this comment

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

@iarspider , isn't it better/faster to create std::string tempfile outside the for loop?

Copy link
Contributor

@smuzaffar smuzaffar Oct 1, 2024

Choose a reason for hiding this comment

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

@Dr15Jones @makortel , is it intentional that FileInPath::fullPath returns a copy and not a const string&?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. If we really care about repeated (de)allocation of memory, maybe change fullPath to return reference?

Copy link
Contributor

Choose a reason for hiding this comment

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

is it intentional that FileInPath::fullPath returns a copy and not a const string&?

I'd guess "not intentional". Or, I can't think of any good reason why it returns a copy and not a const reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@makortel can you prepare a PR, or should I make one?

Copy link
Contributor

Choose a reason for hiding this comment

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

@iarspider It would be great if you could do it. On the same go I'd suggest to change relativePath() to return const string& as well, and remove the explicit definitions of copy constructor and assignment operator, and destructor.


std::ifstream in_file(tempfile, std::ios::in);
std::ifstream in_file(tempfile.c_str(), std::ios::in);
Copy link
Contributor

Choose a reason for hiding this comment

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

will it work if we pass file.fullPath().c_str() directly here (without create tempfile string)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tempfile is used also in else branch

Copy link
Contributor

Choose a reason for hiding this comment

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

frequency of hitting else is very low. So one can just use file.fullPath() there too ... right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

frequency of hitting else is very low. So one can just use file.fullPath() there too ... right?

I would think so.

@mmusich
Copy link
Contributor

mmusich commented Oct 1, 2024

@iarspider can the title of the PR reflect the name of the changed class?

@iarspider iarspider changed the title [LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer [LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer in SiPixelFakeGenErrorDBObjectESSource::produce Oct 1, 2024
@iarspider iarspider force-pushed the iarspider-patch-20241001-2 branch from 94fac8c to ce52df2 Compare October 11, 2024 20:56
@iarspider
Copy link
Contributor Author

please test with #46200

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Pull request #46181 was updated. @atpathak, @consuegs, @perrotta can you please check and sign again.

@iarspider
Copy link
Contributor Author

please abort

@iarspider iarspider changed the title [LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer in SiPixelFakeGenErrorDBObjectESSource::produce [LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer in SiPixelFakeGenErrorDBObjectESSource::produce and SiPixelTemplateDBObjectReader::analyze Oct 11, 2024
@iarspider
Copy link
Contributor Author

please test with #46200

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Pull request #46181 was updated. @atpathak, @consuegs, @francescobrivio, @perrotta can you please check and sign again.

@cmsbuild
Copy link
Contributor

-1

Failed Tests: RelVals-INPUT
Size: This PR adds an extra 24KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-85a4d0/42141/summary.html
COMMIT: 19c25e2
CMSSW: CMSSW_14_2_X_2024-10-11-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/46181/42141/install.sh to create a dev area with all the needed externals and cmssw changes.

RelVals-INPUT

  • 2022.1010012022.101001_RunEGamma2022C_10k/step1_dasquery.log
  • 2022.101001DAS Error

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 40 differences found in the comparisons
  • DQMHistoTests: Total files compared: 44
  • DQMHistoTests: Total histograms compared: 3331066
  • DQMHistoTests: Total failures: 3445
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3327601
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 43 files compared)
  • Checked 193 log files, 163 edm output root files, 44 DQM output files
  • TriggerResults: no differences found

@iarspider
Copy link
Contributor Author

iarspider commented Oct 12, 2024

@cmsbuild ignore tests-rejected with external-failure
DAS query error is clearly not related to this PR, also happens in IBs

@perrotta
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (test failures were overridden). This pull request will now be reviewed by the release team before it's merged. @antoniovilela, @sextonkennedy, @mandrenguyen, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@mandrenguyen
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 32c7e17 into cms-sw:master Oct 12, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants