temporalio / temporalio/sdk-typescript
extractSourceMap takes a huge amount of RAM on boot
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 917
- Forks
- 224
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 43
Description
I run a series of workers on my Temporal pod bootup. They sometimes take up over 2GB of RAM simply from parsing the source maps. I've confirmed this using clinic.js.
I am curious if there is a way to optionally allow turning off source maps? I can do so via the builder
const { code } = await bundleWorkflowCode({
workflowsPath: worker.workflowsPath,
// Remove source maps
webpackConfigHook: config => {
config.devtool = false;
return config;
}
});
But then the extractSourceMap throws, and if I patch it I see further failures down the line in addWorkflowBundle > SourceMapConsumer
I managed to patch it (in a dirty way)
return [code, JSON.stringify({
version: 3,
file: '',
sources: [],
mappings: '',
})];
// throw new Error("Can't extract inlined source map from the provided Workflow Bundle");
Which results in significantly lower bootup + IDLE ram usage
Before
After
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at packages/worker/src/worker.ts around line 1868 and trace extractSourceMap through addWorkflowBundle and SourceMapConsumer. Compare the normal source-map path with the webpackConfigHook configuration that sets devtool to false, using the reported clinic.js memory behavior as context. Done means source maps can be disabled without the later failures and worker boot and idle memory are substantially reduced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, webpack
- Domain
- build-system, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100