Skip to content

Conversation

@dpiparo
Copy link
Member

@dpiparo dpiparo commented Jul 27, 2023

Add yet another fence in TClass::GetClass to avoid lookups and memory consumption. This PR aims to fix #9029. Give the sophisticated implementation of TClass::GetClass, perhaps it would be good to collect some feedback, especially by @pcanal .

This Pull request:

This PR avoids lookups and parsing in some cases.
One of the principles of the TClass::GetClass method implementation is to avoid as much as possible.

Changes or fixes:

This commit adds yet another fence in TClass::GetClass, checking if the name in input is the name of a known fundamental type or typedef to it.
In order to avoid code duplication, a routine previously available within the implementation of TClassEdit has been made available with a public API.

Checklist:

  • [v ] tested changes locally
  • [v ] updated the docs (if necessary)

This PR fixes #9029

@sonatype-lift
Copy link

sonatype-lift bot commented Jul 27, 2023

Sonatype Lift is retiring

Sonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console.
We are extremely grateful and thank you for your support over the years.

📖 Read about the impacts and timeline

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/cxx14
How to customize builds

std::string name_no_std = name;
TClassEdit::RemoveStd(name_no_std);
auto lot = gROOT->GetListOfTypes();
if(lot->Contains(name_no_std.c_str()))
Copy link
Member

Choose a reason for hiding this comment

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

The list of type contains not only raw types but also typedefs to class/struct or anything else that points to the typedefs

root [1] using MyTObject = TObject;
root [2] gROOT->GetListOfTypes()->FindObject("MyTObject")
(TObject *) 0x60000173d290

We can still save some cycles in this case:

auto dt = (TDataType*)gROOT->GetListOfTypes()->FindObject(name);
if (dt) {
	if (dt->GetType() >=0)
	   // We have a fundamental type (or a typedef to)
           return nullptr;
	else
	   // We have a non fundamental, we can still use the information
	   name = dt->GetFullTypeName();
           // we could check here if there is any trailings stars or trailing paranthesis to excluded pointers and functions (non trailing star/paranthesis might be template parameter)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for the feedback! I am proposing a new version of the code, also considering the failing tests.

@github-actions
Copy link

github-actions bot commented Jul 27, 2023

Test Results

       3 files         3 suites   15h 46m 33s ⏱️
2 452 tests 2 442 ✔️ 1 💤 9
6 755 runs  6 746 ✔️ 0 💤 9

For more details on these failures, see this check.

Results for commit 5690885.

♻️ This comment has been updated with latest results.

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2204/nortcxxmod.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/cxx17.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on mac11/noimt.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on mac12arm/cxx20.
Running on macphsft26.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/soversion.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

@phsft-bot
Copy link

Build failed on mac11/noimt.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2204/nortcxxmod.
Running on root-ubuntu-2204-2.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on mac12arm/cxx20.
Running on macphsft26.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

This commit solves issue root-project#9029 and, more in general, avoid lookups
and parsing in some cases.
One of the principles of the TClass::GetClass method implementation
is to avoid as much as possible. This commit adds yet another fence
in TClass::GetClass, checking if the name in input is the name of a
known fundamental type or typedef to it.
In order to avoid code duplication, a routine previously available
within the implementation of TClassEdit has been made available with
a public API.
@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@dpiparo
Copy link
Member Author

dpiparo commented Aug 14, 2023

Hello @phsft-bot build just on ROOT-fedora37, ROOT-fedora38, ROOT-ubuntu2204

TClassEdit::GetNormalizedName(normalizedName, name);
}
std::string name_no_std = name;
TClassEdit::RemoveStd(name_no_std);
Copy link
Member

Choose a reason for hiding this comment

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

What is the advantage of using this name_no_std rather than the normalizedName?

@dpiparo
Copy link
Member Author

dpiparo commented Aug 19, 2023

@phsft-bot build

@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@dpiparo
Copy link
Member Author

dpiparo commented Aug 21, 2023

@phsft-bot build , still too many missing containers...

@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@dpiparo
Copy link
Member Author

dpiparo commented Dec 19, 2023

Thanks for all the feedback. A more comprehensive solution to avoid spurious lookups triggered by TClass::GetClass will be proposed.

@dpiparo dpiparo closed this Dec 19, 2023
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.

Repeated calls to TClass::GetClass/TClassEdit::ResolveTypedef hoard memory

4 participants