On Mar 5, 2007, at 3:59 AM, Lars Skjærlund wrote:
Unfortunately, I have huge performance problems :-(.
Basically, here's what I want to do (in pseudocode):
A little more detail in the code might help us help you. While
Net::LDAP has some performance hit for doing everything in perl. I
suspect in your case the main issue is the network overhead.
@entries = LDAP->Search(Projects)
How many attributes does a project entry have? Do you only ask for
the attributes you need?
If, there are many projects, it will probably be worth using a
callback here so you can fire
off the other searches as you get your entries back.
foreach my $entry (@entries) {
LDAP->Search($entry->{Project_Manager})
...
}
Let me try and give an outline as to how to put these in parallel.
$ldap->async(0);
$result = $ldap->search(
@project_search_args,
attrs => [qw(attrs needed to fetch manager)],
callback => \&get_project_manager
);
$ldap->sync;
$ldap->async(1);
sub get_project_manager {
my ($mesg, $entry) = @_;
return unless $entry; # We are done
if ($entry->isa('Net::LDAP::Entry')) {
$mesg->shift_entry;
my $managerDN = $entry->get_value(Project_Manager);
$mesg->parent->search(
@manager_search_args,
attrs => [qw(attrs needed)],
callback => sub { process_manager($entry, @_) }, # must pass
project first as @_ is variable length
);
}
if ($entry->isa('Net::LDAP::Reference')) {
# Handle references
}
}
sub process_manager {
my ($project, $mesg, $entry) = @_;
return unless $entry; # We are done, probably should check $mesg-
>code
if ($entry->isa('Net::LDAP::Entry')) {
....
}
if ($entry->isa('Net::LDAP::Reference')) {
# Handle references
}
}
Graham.