-
Notifications
You must be signed in to change notification settings - Fork 311
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
Using F# List and Seq types #2348
Conversation
ncave
commented
Jan 17, 2021
•
edited
Loading
edited
- Replaces JS List type with F# List type.
- Replaces JS Seq type with F# Seq type.
- Performance is on par (or slightly faster) than the main branch.
Hmm, if we rule out the overhead of inheriting from Record, the only thing I can think of now is the transformation from IEnumerator to JS Iterator (as we've seen several times small changes in iteration make big performance difference). Right now the [Symbol.iterator]() {
return toIterator(this.GetEnumerator());
} This calls the following code: Fable/src/fable-library/Seq.ts Lines 57 to 66 in 10cb7d4
A way to test if this, could be to compiler fable-library with your changes first, then manually replace [Symbol.iterator]() {
let cur = this;
return {
next: () => {
const value = cur === null || cur === void 0 ? void 0 : cur.head;
const done = (cur === null || cur === void 0 ? void 0 : cur.tail) == null;
cur = cur === null || cur === void 0 ? void 0 : cur.tail;
return { done, value };
},
};
} And after that, running the benchmark to see if there's any difference. If there is, it would make sense to transform Seq.ts into F# and use |
@alfonsogarciacaro Iteration doesn't seem to be a problem in micro-benchmarks, but I'll try that. |
@alfonsogarciacaro I stand corrected, just replacing the iterator (as you suggested above) improves the FCS-JS benchmark performance by 20%. |
10dcd15
to
fb508f7
Compare
Done :)
|
Performance of generated code is now at the same level as the main branch (or slightly better), so this is ready for merging. |
Awesome @ncave! Fantastic work as always 👏 👏 👏 Looking at the code, it seems classes implementing |