Skip to content

Loading assets from the cache is significantly slower than from the binary #1753

@Enselic

Description

@Enselic

Step-by-step:

  1. Measure the time it takes bat to highlight examples/simple.rs without cached assets, i.e. when the assets integrated into the binary are used:
% rm -rf ~/.cache/bat
% hyperfine --export-markdown /dev/tty 'bat --color always examples/simple.rs'
Command Mean [ms] Min [ms] Max [ms] Relative
bat --color always examples/simple.rs 107.4 ± 2.1 104.1 112.5 1.00
  1. Create cached assets that are identical to the integrated assets:
% mkdir -p ~/.cache/bat
% echo "---\nbat_version: 0.18.2" > ~/.cache/bat/metadata.yaml
% cp assets/syntaxes.bin ~/.cache/bat/syntaxes.bin
% cp assets/themes.bin ~/.cache/bat/themes.bin
  1. Measure again
% hyperfine --export-markdown /dev/tty 'bat --color always examples/simple.rs'
Command Mean [ms] Min [ms] Max [ms] Relative
bat --color always examples/simple.rs 115.0 ± 2.1 111.9 120.1 1.00

Expected result

There is no significant difference.

Actual result

There is a significant difference.

I will soon create a PR with a proposed fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions