Skip to content

Conversation

Copy link

Copilot AI commented Dec 17, 2025

Several performance bottlenecks exist in request handling hot paths, particularly repeated application:get_env/3 calls and inefficient list operations.

Changes

Cache configuration lookups in nova_router.erl

  • Cache dispatch_backend in function scope for execute/2, lookup_url/3, add_routes/2, render_status_page/*, and add_plugin/1
  • Hoist global_plugins lookup from compile_paths/3 loop to compile/3, passing via Options map
  • Remove redundant lookup_url/4 helper

Cache session manager in nova_session.erl

  • Store session manager module in persistent_term during supervisor init
  • Replace application:get_env/3 with persistent_term:get/2 in get_session_module/0
%% Before: called on every session operation
get_session_module() ->
    application:get_env(nova, session_manager, nova_session_ets).

%% After: cached lookup
get_session_module() ->
    persistent_term:get(nova_session_manager, nova_session_ets).

Optimize list operations in nova_router.erl

  • Replace RouterRoutes ++ lists:append(ControllerRoutes) with single lists:append([RouterRoutes | ControllerRoutes]) in get_routes/2

Simplify module loading in nova_basic_handler.erl

  • Replace code:is_loaded/1 + code:load_file/1 pattern with direct try/catch
  • Erlang's code server auto-loads modules on first function call
  • Add stacktrace arity matching to distinguish template errors from other undef errors

Impact

Reduces overhead in:

  • Request routing (execute/2)
  • Session operations (every get/set)
  • Template rendering (render_dtl/3)
  • Route compilation (compile_paths/3 loop)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Identify and suggest improvements to slow or inefficient code


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits December 17, 2025 17:41
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Co-authored-by: burbas <159004+burbas@users.noreply.github.com>
Copilot AI changed the title [WIP] Identify and suggest improvements to slow code Optimize hot path performance: cache config lookups and streamline list operations Dec 17, 2025
Copilot AI requested a review from burbas December 17, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants