• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaIO / VideoIO.jl / 1006
34%

Build:
DEFAULT BRANCH: master
Ran 03 Aug 2020 07:16PM UTC
Jobs 6
Files 105
Run time 5min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
1006

push

travis-ci

web-flow
Make accessing members of structs through pointers more efficient (#252)

As part of #250 I benchmarked the performance of `av_setfield`, and observed
that it currently takes ~380 ns. While this is fast, it's not as fast as I would
expect for what should boil down to a few machine instructions. This is
primarily due to the seemingly inherent type instability of accessing a field by
its name. However, upon further reflection, this didn't make sense to me, as
this should happen every time you access a field in Julia (e.g. `foo.a` which is
translated to `getproperty(foo, sym)`, which is in turn translated to
`getfield(foo, sym)` where `sym = :a`). Unlike in the generic case, where you
don't know ahead of time which field will be accessed, if the call occurs inside
of a function, the field name is a constant which can be utilized by the
compiler. I therefore wondered if my benchmarks in #250 were unnecessarily slow,
and that calls to `av_setfield` inside of a function would be more performant
because the symbol would be constant, and the data type of the field could then
in principle be known by compiler. Simple testing of this idea revealed that it
was not the case. However, the problematic line of `av_setfield`, `S =
fieldtype(T, name)`, could be made type stable in other functions. Why wasn't
the compiler using the data type of the field in this case, when it can in other
cases?

I realized that it was because `av_setfield` was not being inlined by the
compiler, so that the constant field name inside a function could not being
utilized to eliminate type instability. By adding the `@inline` compiler hint to
`av_setfield`, the compiler now knows what c type the arguments must be cast to
before storing it in the c struct, although this is only true if you use
`av_setfield` inside of a function. This minimal change successfully eliminates
type instability, and simple benchmarking shows that the original 383 ns run
time of `av_setf... (continued)

508 of 1443 relevant lines covered (35.2%)

347681.97 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1006.1 03 Aug 2020 07:17PM UTC 0
33.26
Travis Job 1006.1
2 1006.2 03 Aug 2020 07:21PM UTC 0
34.44
Travis Job 1006.2
3 1006.3 03 Aug 2020 07:19PM UTC 0
33.96
Travis Job 1006.3
4 1006.4 03 Aug 2020 07:16PM UTC 0
21.31
Travis Job 1006.4
5 1006.5 03 Aug 2020 07:19PM UTC 0
22.14
Travis Job 1006.5
6 1006.6 03 Aug 2020 07:20PM UTC 0
21.75
Travis Job 1006.6
Source Files on build 1006
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1006
  • 12122118 on github
  • Prev Build on master (#1004)
  • Next Build on master (#1010)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc