Skip to content

Reduce allocs in decode function#344

Merged
guelfey merged 2 commits intogodbus:masterfrom
marselester:reduce-code-allocs
Dec 4, 2022
Merged

Reduce allocs in decode function#344
guelfey merged 2 commits intogodbus:masterfrom
marselester:reduce-code-allocs

Conversation

@marselester
Copy link
Contributor

Hi! I tried to reduce memory allocations in the decode function to reduce GC pressure.

# new
BenchmarkEncodeSliceInterface-2   	  457238	      2609 ns/op	     732 B/op	      38 allocs/op
# old
BenchmarkEncodeSliceInterface-2   	  434961	      2706 ns/op	     628 B/op	      46 allocs/op

Apologies if I broke certain dbus protocol assumptions during refactoring, I am not very familiar with the codebase.

@guelfey
Copy link
Member

guelfey commented Dec 4, 2022

Thanks!

@guelfey guelfey merged commit a852926 into godbus:master Dec 4, 2022
felixonmars added a commit to felixonmars/dbus that referenced this pull request Dec 22, 2022
During refactoring in godbus#344, the newly added decodeU() function skips the
dec.align() call from the original decode("u") routine. This
unfortunately breaks parsing of boolean values with a lot of the
following errors:

```
dbus: wire format error: invalid value for boolean
```

Adding a fixed align() call here fixes the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants