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

Change existing symbol_namespace::iterate to return all data instead of invoking a callback #3072

Merged
merged 2 commits into from
Dec 14, 2017

Conversation

hkaiser
Copy link
Member

@hkaiser hkaiser commented Dec 12, 2017

This API was never used anywhere and required some face-lifting after being half-way abandoned. It is now needed on one of our projects.

@hkaiser hkaiser added this to the 1.1.0 milestone Dec 12, 2017
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 12, 2017
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 12, 2017
// Reuse functionaliy from perf-counters
namespace hpx { namespace performance_counters { namespace detail
{
HPX_EXPORT std::string regex_from_pattern(std::string const& pattern,
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense to move this into hpx::util?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah, may make sense to do that - but that's unrelated to the current PR.

Copy link
Member

Choose a reason for hiding this comment

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

Someone once told me that nothing is more permanent than a temporary solution ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have not added any temporary solutions. I used what was there for years already.

Copy link
Member

Choose a reason for hiding this comment

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

What I meant is the temporary solution of pulling in the performance counters here for a utility function that is in itself unrelated to both performance counters and symbol namespace.

return ids;
}
}

/// Invoke the supplied hpx::function for every registered global name
Copy link
Member

Choose a reason for hiding this comment

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

This comment should be fixed. There is no function involved there anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, will fix.

hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 12, 2017
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
@hkaiser
Copy link
Member Author

hkaiser commented Dec 13, 2017

@sithhell could we go ahead with this, please?

hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 13, 2017
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 13, 2017
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 13, 2017
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Dec 13, 2017
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
Copy link
Member

@sithhell sithhell left a comment

Choose a reason for hiding this comment

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

In principle the code is ok. After thinking a while about it, I'm sceptical about scalability since all symbols are now collected into a single place. This sounds like quite some overhead for just iterating the registered names.
When looking at the use case in phylanx, I think this might be solved more efficiently by calculating the symbolic names from the ast, and use those to resolve the gids. This has the additional advantage that the number of localities to broadcast to is reduced.

if (!boost::regex_match(it->first, rx))
continue;
found[it->first] =
naming::detail::split_gid_if_needed(*(it->second)).get();
Copy link
Member

Choose a reason for hiding this comment

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

The lock needs to be unlocked here due to a potential remote operation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

if (!pattern.empty() && pattern != it->first)
continue;
found[it->first] =
naming::detail::split_gid_if_needed(*(it->second)).get();
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@hkaiser
Copy link
Member Author

hkaiser commented Dec 13, 2017

In principle the code is ok. After thinking a while about it, I'm sceptical about scalability since all symbols are now collected into a single place. This sounds like quite some overhead for just iterating the registered names.

Well, if you need all symbols in one place you should collect them there, no?

When looking at the use case in phylanx, I think this might be solved more efficiently by calculating the symbolic names from the ast, and use those to resolve the gids. This has the additional advantage that the number of localities to broadcast to is reduced.

Could you elaborate? I don't think I understand what you're after.

@sithhell
Copy link
Member

In principle the code is ok. After thinking a while about it, I'm sceptical about scalability since all symbols are now collected into a single place. This sounds like quite some overhead for just iterating the registered names.

Well, if you need all symbols in one place you should collect them there, no?

Sure, what I am questioning though is if you really need all in one place.

When looking at the use case in phylanx, I think this might be solved more efficiently by calculating the symbolic names from the ast, and use those to resolve the gids. This has the additional advantage that the number of localities to broadcast to is reduced.

Could you elaborate? I don't think I understand what you're after.

The parser is creating the AST nodes with specific names which are then registered in the symbolic namespace. Giving that you have the AST, it should be trivial to extract the names of the different nodes by a simple tree traversal. Once you have a list of the names, you can calculate which service instance is responsible for the each name and send out bulk requests to only those instances of the symbolic namespace server to resolve the GID. That is, you shouldn't need the symbolic namespace service to get all names associated with the AST.


namespace hpx { namespace util
{
HPX_EXPORT std::string regex_from_pattern(std::string const& pattern,
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Much appreciated!

// now, split gids, if needed
for (auto& e : found)
{
e.second = naming::detail::split_gid_if_needed(e.second).get();
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if that is correct. The above lines (394 and 405) copy the gid_type. This means that we also copy the credit, that means that we always split from the same initial credit count, without asking for more credit in the primary namespace. This will lead to a negative credit count when all credits are returned back to AGAS.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point, not sure what I was thinking :/

f(key, gid);

found[it->first] =
naming::detail::split_gid_if_needed(*current_gid).get();
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this will work. While going through the PR I was really wondering why we don't reuse hpx::naming::id_type here instead of std::shared_ptr<gid_type>. But that's unrelated to that PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

AGAS stores gid_type instances only by design. For all intents and purposes this is sufficient and avoids problems with reference counting etc. The symbol namespace is special in that regard that it actually has to maintain reference counts (for some of its functionality). I'm impartial to changing this - it wouldn't make the code so much more readable, however.

Copy link
Member

@sithhell sithhell left a comment

Choose a reason for hiding this comment

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

LGTM now.
I'm still skeptical though if this is really a better approach than the callback based solution.

@hkaiser
Copy link
Member Author

hkaiser commented Dec 14, 2017

I'm still skeptical though if this is really a better approach than the callback based solution.

I'd be happy to add back the old callback-based solution as an alternate API. For my use case it would be much more expensive at runtime to use the old API, however.

@hkaiser hkaiser merged commit c76e60a into master Dec 14, 2017
@hkaiser hkaiser deleted the find_symbols branch December 14, 2017 18:53
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Jan 4, 2018
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Jan 4, 2018
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
hkaiser added a commit to STEllAR-GROUP/phylanx that referenced this pull request Jan 4, 2018
…th AGAS

- this depends on STEllAR-GROUP/hpx#3072
- add an example demonstrating adding and accessing debug information to
  primitive instances
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.

2 participants