canonical / canonical/stdlibc.dart
Performance issues when using with isolates
- Dominant language
- Dart
- Stars
- 58
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
When using with isolates, I am seeing performance issues, more prevalent on (GNU) Linux than on MacOS.
**Explanation**
- Starting isolates causes class references and such to be loaded into separate memory heap. This is inline with Dartlang design.
- With stdlibc library included, this causes the code from gnu.dart and bsd.dart to loaded into memory of each isolate.
- Because, of this line: https://github.com/canonical/stdlibc.dart/blob/768035861b06945d80754a32f2ea45d655aba872/lib/src/gnu/gnu.dart#L16 and this line: https://github.com/canonical/stdlibc.dart/blob/768035861b06945d80754a32f2ea45d655aba872/lib/src/gnu/gnu.dart#L16
libc library is loaded in every isolate whether the isolate uses libc functions or not.
**Possible Solution**
- Load libc on-demand.
- Do not define loading libc in a final variable of a dart file, instead tuck this into a function.
**Anecdotal Observations**
I was able to notice 10% of the CPU time is utilized on loading libc library when launching isolates in my application.
I can provide more insight into profiling data and cpu spikes related to this issue upon request. But the issue can be easily reproduced by launching a bunch of isolates in a short span and profiling the application.
Contributor guide
Assessment
This issue has not been assessed yet.