Skip to content

oxfmt: Unexpected high CPU and RAM usage after configuring sortTailwindcss #19994

Description

@HowieHz

When loading the @iconify/tailwind4 plugin, it causes unexpected CPU and memory usage. Below are the details.

details

Windows 11 25H2 (reproduced by @HowieHz)
(To prevent the computer from freezing, I interrupted the formatting process.)

Image

Compared to when this configuration option is not set.

Image

Ubuntu 26.04.03 LTS (reproduced by @xingwangzhe)
Image

By the way, this also leads to longer execution times in GitHub CI than Prettier.

Upon investigation, it was found that loading the @plugin "@iconify/tailwind4" plugin like this:

@plugin "@iconify/tailwind4" {
  prefixes:
    mdi, heroicons-outline, fa-solid, fluent, material-symbols, ic, typcn, simple-icons, ant-design, ri, ph,
    icomoon-free, entypo-social, uil, cib, tabler, pepicons-pencil;
}

causes CPU usage to max out, even without any prefixes. Then, as more prefixes are added, memory usage grows at an alarming rate.

The image below shows the memory usage when prefixes are added one by one.

Image

Steps to Reproduce

# The default branch has set --threads 2 to avoid memory exhaustion. 
# You need to go to package.json and remove this configuration.
git clone https://github.com/HowieHz/halo-theme-higan-hz
pnpm i
pnpm fmt:oxfmt

I've created a similar but smaller reproduction case.

git clone https://github.com/HowieHz/test-oxfmt-bug
pnpm i
pnpm fmt:oxfmt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions