PerlDancer / PerlDancer/Dancer2
Dispatcher::dispatch copies the app list on every request
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 604
- Forks
- 288
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
Status: reasoned from code
lib/Dancer2/Core/Dispatcher.pm:30:
my @apps = @{ $self->apps_psgi };
Flattens the arrayref into a fresh list on every dispatch. Trivial, but it is the hottest line in the file, and the loop below already indexes numerically ($apps[$i], $apps[$i+1]), so it can read through the reference directly:
my $apps = $self->apps_psgi;
...
for ( my $i = 0; $i < @{$apps}; $i += 2 ) {
my ( $app_name, $app ) = @{$apps}[ $i, $i + 1 ];
Benchmark before and after; the gain will be small and scales with the number of mounted apps.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read lib/Dancer2/Core/Dispatcher.pm:30 and follow the dispatch loop that indexes the mounted apps. Benchmark the current and changed behavior before and after, checking that dispatching remains unchanged while the per-request list copy is avoided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- backend, performance
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100