allowing performance over safety?
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #5264 di @MangelMaxime — integrata
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 18/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- fsharp, javascript, typescript
- Ambito
- compilers, performance
Direzione di ricerca
The issue asks whether Fable should offer a switch, such as an attribute or fsproj property, that drops array bounds checks in generated JavaScript. The reporter links a benchmark showing that the item(i, arr) helper defeats V8 optimisation. Starting points are the array indexing code path in the Fable compiler and the benchmark in goswinr/Euclid.Kontur. Done means a maintainer decision on the design, not a patch.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Using an invalid index on an Array, ResizeArray or String throws the same Out-Of-Bound Exception in Fable as in .NET.
This is safe and good. I actually argued for this in an older issue.
In JS, using an invalid out-of-bounds index would just return undefined.
However, Claude measured up to 8x slowdown on array indexing.
It seems item(i, arr) gets used on several types of arrays, and then V8 can't optimize it.
Do you think there could or should be a Fable attribute or fsproj property to disable bound checks for some modules or projects? So that the rest of the app still compiles with bound checks.
UndefinedInsteadOfIndexOutOfBoundsException ?
The workaround is easy; just use this on your hot path:
module internal Arr =
/// arr.[i] without a bounds check under Fable.
let inline get (arr: 'T[]) (i: int) : 'T =
#if RELEASE && (FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT)
Fable.Core.JsInterop.emitJsExpr (arr, i) "$0[$1]"
#else
arr.[i]
#endif
/// arr.[i] <- v without a bounds check under Fable.
let inline set (arr: 'T[]) (i: int) (v: 'T) : unit =
#if RELEASE && (FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT)
Fable.Core.JsInterop.emitJsStatement (arr, i, v) "$0[$1] = $2"
#else
arr.[i] <- v
#endif
- Lingua principale
- F#
- Stelle
- 3.2k
- Fork
- 335
- Merge medio
- 18h 57m
- PR unite (30g)
- 154
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fable-compiler/Fable
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
fable-compiler/Fable#5280 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows automation repo-assist
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
fable-compiler/Fable#4531 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows automation repo-assist
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
fable-compiler/Fable#4522 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
fable-compiler/Fable#5281 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
fable-compiler/Fable#5279 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di fable-compiler/Fable
Issue simili
-
[P2] Interpreter: Array.prototype.findLastIndex starts at the wrong index for long array-likesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
new issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
llvm/llvm-project#240065 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
CanadaHonk/porffor#452 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
JakeChampion/lang#14392 ·
I maintainer di solito rispondono entro 1 giorno