and then run dune build --profile release for it to run optimized. I wonder though, if I just run dune build without adding any env or flags, does it do any optimization whatsover then?
When running dune build, Dune uses the default profile, which is dev by deafult (but can be changed using the (profile <name>) stanza in dune-workspace). The difference between dev and release is that 1) warnings are not hard errors in the release profile, and 2) dev disables inlining across modules by passing -opaque, which speeds up recompilation.
Those are the defaults. One can then add/change flags as you did above to customize each profile to your liking.