PerlDancer / PerlDancer/Dancer2

Dispatcher::dispatch copies the app list on every request

Open Beginner friendly
#1,819 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.