Skip to content

Commit

Permalink
Merge branch 'master' into veb/free
Browse files Browse the repository at this point in the history
  • Loading branch information
esquerbatua committed Sep 6, 2024
2 parents a8da7f3 + 6160945 commit 4091dd0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
25 changes: 21 additions & 4 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6725,15 +6725,16 @@ performance, memory usage, or size.
| Tuning Operation | Benefits | Drawbacks |
|--------------------------|---------------------------------|---------------------------------------------------|
| `@[inline]` | Performance | Increased executable size |
| `@[direct_array_access]` | Performance | Safety risks |
| `@[packed]` | Memory usage | Potential performance loss |
| `@[minify]` | Performance, Memory usage | May break binary serialization/reflection |
| `@[inline]` | Performance | Increased executable size |
| `@[direct_array_access]` | Performance | Safety risks |
| `@[packed]` | Memory usage | Potential performance loss |
| `@[minify]` | Performance, Memory usage | May break binary serialization/reflection |
| `_likely_/_unlikely_` | Performance | Risk of negative performance impact |
| `-skip-unused` | Performance, Compile time, Size | Potential instability |
| `-fast-math` | Performance | Risk of incorrect mathematical operations results |
| `-d no_segfault_handler` | Compile time, Size | Loss of segfault trace |
| `-cflags -march=native` | Performance | Risk of reduced CPU compatibility |
| `-compress` | Size | Harder to debug, extra dependency `upx` |
| `PGO` | Performance, Size | Usage complexity |
### Tuning operations details
Expand Down Expand Up @@ -6920,6 +6921,22 @@ with identical hardware.
- When distributing the software to users with potentially older CPUs.
#### `-compress`
This flag executes `upx` to compress the resultant executable,
reducing its size by around 50%-70%.
**When to Use**
- For really tiny environments, where the size of the executable on the file system,
or when deploying is important. The executable will be uncompressed at runtime,
so it will take a bit more time to start.
**When to Avoid**
- When you need to debug the application, or when your app's startup time
is extremely important (where 1-2ms can be meaningful for you).
#### PGO (Profile-Guided Optimization)
PGO allows the compiler to optimize code based on its behavior during sample runs. This can improve
Expand Down
2 changes: 1 addition & 1 deletion vlib/sync/stdatomic/atomic_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mut:
counter u64
}

// without proper syncronization this would fail
// without proper synchronization this would fail
fn test_count_10_times_1_cycle_should_result_10_cycles_with_sync() {
desired_iterations := 10 * iterations_per_cycle
mut wg := sync.new_waitgroup()
Expand Down
8 changes: 8 additions & 0 deletions vlib/v/gen/c/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,14 @@ fn (mut g Gen) zero_struct_field(field ast.StructField) bool {
g.struct_init(default_init)
}
return true
} else if sym.language == .v && !field.typ.is_ptr() && sym.mod != 'builtin'
&& !sym.info.is_empty_struct() {
default_init := ast.StructInit{
typ: field.typ
}
g.write('.${field_name} = ')
g.struct_init(default_init)
return true
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions vlib/v/tests/structs/struct_field_default_value_optional_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import regex

struct RegexCache {
mut:
tag_script_start regex.RE = regex.regex_opt(r'^script.*>') or { panic(err) }
}

pub struct Tokenizer {
mut:
regex_cache RegexCache = RegexCache{}
}

fn new_parser() &Parser {
mut parser := &Parser{}
return parser
}

pub struct Parser {
mut:
tnzr Tokenizer
}

fn test_struct_field_default_value_optional() {
p := new_parser()
println(p)
assert true
}

0 comments on commit 4091dd0

Please sign in to comment.