Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormData high CPU usage #2

Open
codebien opened this issue Jan 4, 2022 · 1 comment
Open

FormData high CPU usage #2

codebien opened this issue Jan 4, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@codebien
Copy link

codebien commented Jan 4, 2022

The following test uses a lot of CPU, some basic analysis spots that the resources are used from the FormData polyfill's body method and specifically the line where the data are pushed into the raw Array used for joining the various parts. The same high consumption can be also observed invoking body from the init context.

Previously mentioned also in the FormData PR grafana/jslib.k6.io#21 (review).

import http from 'k6/http';
import { sleep } from 'k6';
import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';

export const options = {
  stages: [
    { duration: '30s', target: 50 },
  ],
};

const f = open('./1mb.bin', 'b');

export default function () {
  const fd = new FormData();
  fd.append('file', http.file(f, '1mb.bin'))
  fd.body()

  sleep(2);
}

The suggestion is to try to use directly a unique final TypedArray and the relative set method to make it more efficient (to be verified).
BTW, what will be decided in grafana/k6#2311 and the relative vision will impact for sure this issue so we have to keep them aligned.

@codebien codebien added the enhancement New feature or request label Jan 4, 2022
@codebien codebien transferred this issue from grafana/jslib.k6.io Sep 13, 2023
@Codex-
Copy link

Codex- commented Aug 13, 2024

I encountered this issue, was heavily CPU bound for a test with a rather small image involved, write up and workaround here: grafana/k6#3888

Hope this helps anyone that comes across this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants