3 ms·
You can find some in Debian benchmark game. In general FPC generated code is around 1.5 to 2 times slower the fastest entry (often C++). Note though that this i
by badsectoracula 3y ago
You can find some in Debian benchmark game. In general FPC generated code is around 1.5 to 2 times slower the fastest entry (often C++). Note though that this is with FPC's own code generator and there is a new LLVM backend in the development version (FPC's own code generator is the default and will always be, the LLVM backend is for those who really want it and is much slower).
I'd expect synthetic benchmarks like those in the Debian benchmark game to be closer to C++'s performance with the LLVM backend.
- Rochus 3y agoWhen I had a look at the CLBG results last time the code generated by FreePascal was even about three to four times slower than C/C++; but the benchmark rules are not particularly well suited for fair comparison (some code is obviously written with inside knowledge of the particular compiler/version and not what you usually see for the given language, and the Pascal code likely includes range and overflow checks which make it slower compared to a language without these, etc.). The LLVM backend is not officially supported by FP and doesn't support all platforms as far as I know; and unfortunately micro benchmarks are usually not representative for the daily overall performance of an application; the Are-we-fast-yet benchmark suite would be better in this regard. Anyway, I would be interested in why FP benchmarked as fast as C++ in the past, but no longer today.
- badsectoracula 3y ago> The LLVM backend is not officially supported by FP It used to be a separate project but these days is part of the main development branch. Though indeed the OS and CPU support is very limited. Also i agree about the micro benchmark comparison, they tend to exaggerate differences. FWIW in my own programs i never found Free Pascal's code generator to be inadequate. I do not remember the exact difference but last year i did compile my 3D game engine with the LLVM backend and the difference was small enough for me to decide that i don't want to bother with the much slower compile times.
- Rochus 3y agoI read other comments of people claiming the code generated by the LLVM backend was less than factor 1.5 faster than the one generated by the original backend, which is not worth the effort (and the humongous overhead and additional dependencies) from my point of view; but I'm still trying to find information about the specific optimizations done in the current FP compiler.
- badsectoracula 3y ago> I'm still trying to find information about the specific optimizations done in the current FP compiler. AFAIK there isn't any explicit documentation but the "toptimizerswitch" and "twpoptimizerswitch" (the latter is for whole program optimizations) types in the compiler define the available optimizations in globtype.pas and have the following values: cs_opt_level1,cs_opt_level2,cs_opt_level3,cs_opt_level4, cs_opt_regvar,cs_opt_uncertain,cs_opt_size,cs_opt_stackframe, cs_opt_peephole,cs_opt_loopunroll,cs_opt_tailrecursion,cs_opt_nodecse, cs_opt_nodedfa,cs_opt_loopstrength,cs_opt_scheduler,cs_opt_autoinline, cs_useebp,cs_userbp,cs_opt_reorder_fields,cs_opt_fastmath, cs_opt_dead_values,cs_opt_remove_empty_proc,cs_opt_constant_propagate, cs_opt_dead_store_eliminate,cs_opt_forcenostackframe, cs_opt_use_load_modify_store,cs_opt_unused_para,cs_opt_consts, cs_opt_forloop cs_wpo_devirtualize_calls,cs_wpo_optimize_vmts,cs_wpo_symbol_liveness level1/2/3/4 are basically collections for some of the above and are enabled for -On where n is 1 to 4. You can enable optimizations explicitly with the -OoXXX (for per-module optimizations) and -OwXXX (for whole program optimizations). The -io and -iw parameters can be used to obtain the available names for these. I think the names are more or less self-explanatory, at least for the most part (not sure what "uncertain" does... which i think is appropriate :-P). Some brief documentation (though very brief) is available in the programmer's guide: https://www.freepascal.org/docs-html/current/prog/progch11.html#x235-24900011 https://www.freepascal.org/docs-html/current/prog/progch11.h...
- Rochus 3y agoThanks for the hints. I was already concerned that I would have to analyze the source code directly myself, and so I started to build tools for this purpose (https://github.com/rochus-keller/FreePascal https://github.com/rochus-keller/FreePascal). I read somewhere that there are issues with higher optimization levels. Can you confirm that?