summaryrefslogtreecommitdiff
path: root/perf/cairo-perf-trace.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid misuse of ctype(3) functionsTaylor R Campbell2023-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ctype(3) character classification and mapping functions have a peculiarly limited definition (C11, Sec. 7.4 `Character handling <ctype.h>', p. 200): `The header <ctype.h> declares several functions useful for classifying and mapping characters. In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined.' In other words, in the most common case of 8-bit char and EOF = -1, the domain of the 257 allowed arguments is: -1, 0, 1, 2, ..., 254, 255 The ctype(3) functions are designed for use with stdio functions like getchar and fgetc which return int values in the same domain. In an ABI where char is signed (e.g., x86 SysV ABI used by most Unixish operating systems), passing an argument of type char as is can go wrong in two ways: 1. The value of a non-EOF input octet interpreted as `char' may coincide, as an integer, with the value of EOF, leading to wrong answers for some non-EOF inputs. E.g., if EOF = 1, and an input octet has all bits set, i.e., 255 as an unsigned char, then as a char the value is -1, which will be confused with EOF. In the ISO-8859-1 locale, the code point 255 is (in Unicode terminology) LATIN SMALL LETTER Y WITH DIAERESIS, for which isprint, isalpha, &c., are true. But isprint, isalpha, &c., are false for EOF. So if char *s points to a string with that character, isprint(*s) will return false when it should return true. 2. Passing a negative char whose value does not coincide with EOF is undefined behaviour. This isn't purely theoretical: often the functions are implemented by an array lookup, #define isprint(c) (ctypetab[c] & ISPRINT). If c is out of range (e.g., 192, ISO-8859-1 for LATIN CAPITAL LETTER A WITH GRAVE, which convers to (signed) char as -64), then you can get garbage answers by reading uninitialized memory or application crashes with SIGSEGV if the page preceding the table is unmapped. If what you have is an arbitrary char (e.g., from a char * string pointing at user input), then the only correct way to use the ctype(3) functions is by converting to unsigned char first -- e.g., isprint((unsigned char)*s). (If the functions were defined as macros that convert to unsigned char first, they would then spuriously interpret EOF as a non-EOF, so they can't do that themselves.) It is possible, in some cases, to prove that the input always actually lies in {0, 1, 2, ..., 127}, so the conversion to unsigned char is not necessary. I didn't check whether this was the case -- it's safer to just adopt the habit of always casting char to unsigned char first before using the ctype(3) macros, which satisfies a compiler warning on some systems designed to detect this class of application errors at compile-time.
* Remove stray _GNU_SOURCE definitionsEmmanuele Bassi2021-05-011-1/+1
| | | | | | We define _GNU_SOURCE globally in both the Autotools build, through the use of the AC_USE_SYSTEM_EXTENSIONS macro; and in the Meson build, with add_project_arguments().
* Retire dummy cairo-version.h header to fix meson subproject buildTim-Philipp Müller2020-09-291-2/+0
| | | | | | | | | | | | | | It was originally added to make bisecting easier, but has outlived its usefuleness now. Going forward we'll have just a single cairo-version.h header file, the one with the real version numbers. This is needed to fix the case where cairo is being built as a Meson subproject, but also simplifies things in general. Fixes #421
* Misc. typosluz.paz2019-01-311-1/+1
| | | | | | | Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint` Follow up of 12cb59be7da Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
* perf: Refactor some common macros to cairo-perf.hBryce Harrington2014-04-181-3/+2
| | | | | | | | These macros are standard in src's cairoint.h and test's cairo-test.h internal header files, so for consistency do the same thing with perf's cairo-perf.h. Reviewed-by: Uli Schlachter <psychon@znc.in>
* perf; Do not allow the backends to optimize away the clear before syncChris Wilson2013-01-281-3/+7
| | | | | | | | | | The importance of writing to the scratch surface before retrieving an image is that it makes that the write lands in the server queue, as well as the GetImage, in order to serialise the timer against all the operations. Reported-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Attempt to decompress images in placeChris Wilson2013-01-081-1/+15
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* boilerplate: Remove unused thread id parameterAndrea Canciani2011-11-121-1/+0
| | | | | The thread id is not used anymore (it is always == 0), so it can be removed.
* Improve the documentation of the flagsAndrea Canciani2011-11-121-6/+7
| | | | | Some utilities were providing incorrect or incomplete usage information.
* Sort option flagsAndrea Canciani2011-11-121-12/+12
| | | | | | | | Keep the option flags in alphabetical order. This makes it easier to check for collisions or missing handlers. Avoids an internal error when passing flags -c, -r or -v to cairo-analyse-trace.
* Introduce a new compositor architectureChris Wilson2011-09-121-24/+112
| | | | | | | | | | | | | | | | | | Having spent the last dev cycle looking at how we could specialize the compositors for various backends, we once again look for the commonalities in order to reduce the duplication. In part this is motivated by the idea that spans is a good interface for both the existent GL backend and pixman, and so they deserve a dedicated compositor. xcb/xlib target an identical rendering system and so they should be using the same compositor, and it should be possible to run that same compositor locally against pixman to generate reference tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> P.S. This brings massive upheaval (read breakage) I've tried delaying in order to fix as many things as possible but now this one patch does far, far, far too much. Apologies in advance for breaking your favourite backend, but trust me in that the end result will be much better. :)
* cairo-missing: Fix and cleanup ssize_t type definitionAndrea Canciani2011-09-041-2/+0
| | | | | The definition of ssize_t is needed in cairo-missing.h and can be dropped from files which include it.
* perf: Get rid of cairo_perf_ticks_per_second()Andrea Canciani2011-09-021-23/+23
| | | | | The cairo_time_from_s() and cairo_time_to_s() functions should be used instead.
* perf: Drop cairo_perf_ticks_t in favor of cairo_time_tAndrea Canciani2011-09-021-2/+2
| | | | | cairo_time_t offers a superset of the functions provided by cairo_perf_ticks_t.
* Introduce the cairo-missing libraryAndrea Canciani2011-09-021-51/+1
| | | | | | | | | | | | | | The cairo-missing library provides the functions which are needed in order to correctly compile cairo (or its utilities) and which were not found during configuration. Fixes the build on MacOS X Lion, which failed because of collisons between the cairo internal getline and strndup and those in libc: cairo-analyse-trace.c:282: error: static declaration of ‘getline’ follows non-static declaration /usr/include/stdio.h:449: error: previous declaration of ‘getline’ was here cairo-analyse-trace.c:307: error: static declaration of ‘strndup’ follows non-static declaration ...
* perf: Print a summary of each operation for a trace (using '-s')Chris Wilson2011-08-301-21/+96
| | | | | | | In order for this to be effective on small system we also need to disable the recording of the long traces which exhaust all memory... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* observe: Provide the sum of the elapsed time of the individual operationsChris Wilson2011-08-231-6/+30
| | | | | | | | We can use the elapsed time of the indiividual operations to profile the synchronous throughput of a trace and eliminate all replay overhead. At the cost of running the trace synchronously of course. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* perf: Cleanup target after each runChris Wilson2011-08-191-179/+172
| | | | | | | As the trace may leak surfaces over its lifetime, we are forced to teardown the connection between runs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Remove useless checks for NULL before freeingAndrea Canciani2011-07-311-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch has been generated by the following Coccinelle semantic patch: // Remove useless checks for NULL before freeing // // free (NULL) is a no-op, so there is no need to avoid it @@ expression E; @@ + free (E); + E = NULL; - if (unlikely (E != NULL)) { - free(E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; @@ + free (E); - if (unlikely (E != NULL)) { - free (E); - }
* perf: Fix build on win32Andrea Canciani2011-06-241-8/+45
| | | | | | | The performance tools build system for Win32 hasn't been maintained for some time. The makefiles are now structured as in other directories (Makefile.sources used by both Makefile.am and Makefile.win32) and some additional code hides os-specific parts.
* error: Do not define _cairo_error twiceAndrea Canciani2011-06-241-6/+0
| | | | | | | | | | | | cairo-perf-trace uses cairo-hash.c, which calls _cairo_error. Instead of redefining it in cairo-perf-trace.c it can be abstracted in a separate source which is directly included in the build of cairo-perf-trace. This avoids visibility issues when compiling cairo-perf-trace with a statically linked cairo library on architectures which do not support hidden visibility (example: win32).
* perfChris Wilson2011-06-021-24/+30
|
* perf: Only print description once per backendChris Wilson2010-10-201-0/+5
| | | | | | | | Currently we print the backend description before every time, which is overly verbose. As the information doesn't^Wshouldn't change, simply print it before running the first test of each target. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* perf: print comment describing backendBenjamin Otte2010-07-031-1/+30
| | | | | Use the descibe string to output information about the backend we're testing.
* whitespace: Fixup formal arguments and tabs in boilerplate/ and perf/.M Joonas Pihlaja2010-06-241-36/+46
| | | | | Ran a script to align the formal parameters of functions and collapse spaces to tabs in code.
* boilerplate: Create an image16 targetChris Wilson2010-03-271-66/+1
| | | | | | In order to exercise the newly restored r5g6g5 support, we need to create an appropriate surface and feed it through the test and performance suites.
* boilerplate: Cleanup the list of backends upon shutdown.Chris Wilson2010-03-231-0/+2
|
* perf: Check for and include unistd.hChris Wilson2010-03-041-0/+8
| | | | isatty() and access() require unistd.h, so include it!
* perf: Enable a surface cache for perf-traceChris Wilson2010-01-221-4/+137
| | | | | | | | | | | | | | | | | | | | Real applications that control their Drawable externally to Cairo are 'disadvantaged' by cairo-perf-trace when it creates a similar surface for each new instance of the same Drawable. The difficulty in maintaining one perf surface for every application surface is that the traces do not track lifetimes for the application surfaces, so we would just accumulate stale surfaces. The surface cache takes a different approach and returns the same surface for each active Drawable, and maintains a hold-over of the MRU 16 surfaces. This achieves 60-80% hit rate with firefox, which is probably as good as can be expected. Obviously for double-buffered applications we only every draw to freshly created surfaces (and Gtk+ bypasses cairo to do the final copy -- the ideal application would just use a push-group for double buffering, in which case we would capture and replay the entire expose event). To enable use of the surface cache whilst replaying use -c: ./cairo-perf-trace -c firefox-talos-gfx
* [meta] Rename cairo_meta_surface_t to cairo_recording_surface_t.M Joonas Pihlaja2009-10-221-2/+2
| | | | | | | The new name is more descriptive than the rather opaque meta surface. Discussed with vigour on the mailing list and #cairo: http://lists.cairographics.org/archives/cairo/2009-July/017571.html
* Add skia backendVladimir Vukicevic2009-08-291-0/+3
| | | | | | | | | Originally written by Vladimir Vukicevic to investigate using Skia for Mozilla, it provides a nice integration with a rather interesting code base. By hooking Skia underneath Cairo it allows us to directly compare code paths... which is interesting. [updated by Chris Wilson]
* [perf] Match directory namesChris Wilson2009-08-291-9/+28
| | | | | | In order to handle 'cairo-perf-trace benchmark', we need to perform the can_run? test on the directory name as opposed to the individual trace names. Make it so.
* [perf] Reset global caches after every traceChris Wilson2009-08-291-0/+5
| | | | | | I'd disabled this to look at cairo-qt performance, then forgot about it. Be clean, cleanup globals -- this should fix the huge performance loss when running in series multiple backends that need separate font caches.
* [perf] Remove cpuset warning for cairo-perf-traceChris Wilson2009-08-291-47/+0
| | | | | | These traces run for much longer than the original synthetic benchmarks and seek to replicate 'real-world' applications, so the warning that the xserver and cairo-perf are not bound to any cpu is false.
* [qt] Fix compilationChris Wilson2009-08-101-1/+1
| | | | | | | Enabling 'FAST CLIP' appears to trigger an infinite loop so disable. Enabling 'FAST FILL' has limited effect on performance, so disable whilst the basic QT surface is improved.
* [perf] Remove the warning about failing to open a directoryChris Wilson2009-07-291-3/+1
| | | | | | | | | The warning is repeated in the error message if we fail to find any traces, and now that we search a path it is likely that some elements do not exist. Thus we annoy the user with irrelevant, non-fatal warnings. Still looking for suggestions for the most appropriate home for the system wide cairo-traces dir...
* [drm] Add an accelerated image surface.Chris Wilson2009-07-231-0/+3
| | | | | | | | | | | | | | | | | Use the DRM interface to h/w accelerate composition on image surfaces. The purpose of the backend is simply to explore what such a hardware interface might look like and what benefits we might expect. The use case that might justify writing such custom backends are embedded devices running a drm compositor like wayland - which would, for example, allow one to write applications that seamlessly integrated accelerated, dynamic, high quality 2D graphics using Cairo with advanced interaction (e.g. smooth animations in the UI) driven by a clutter framework... In this first step we introduce the fundamental wrapping of GEM for intel and radeon chipsets, and, for comparison, gallium. No acceleration, all we do is use buffer objects (that is use the kernel memory manager) to allocate images and simply use the fallback mechanism. This provides a suitable base to start writing chip specific drivers.
* [gl] Enable GL backend for cairo-perf-traceChris Wilson2009-07-221-0/+3
|
* [perf] Search multiple directories for tracesChris Wilson2009-07-201-2/+21
| | | | | | In view of sharing traces between multiple builder, add some system wide directories to the search path. This should be refined to a single canonical location before release.
* [perf] Fix use-after-free when retrieving error line numberChris Wilson2009-07-011-3/+2
| | | | | We find out the status on destroying the script and then attempt to query the defunct script for more info about the error. Wrong.
* [perf] Exclude the xlib-reference target from cairo-perfChris Wilson2009-06-301-1/+2
|
* [perf] Enable trace directory recursion.Chris Wilson2009-06-301-37/+67
| | | | | | I have an idea to categorise traces within their own subdirectories and so for convenience added path walking to cairo-perf-trace. Principally this should allow for forests of symlinks of all types.
* [perf] Enable the null-backend for trace replays.Chris Wilson2009-06-271-1/+1
|
* [perf] Need to version surface typesChris Wilson2009-06-211-0/+8
| | | | | | As cairo-perf-diff will execute the current cairo-perf against historical revisions, any introduced api must be protect in order to compile on old versions.
* [perf] Report line of error during traceChris Wilson2009-06-191-2/+6
| | | | | Query the number of new lines processed so far and report that on hitting an error.
* Import Qt backend by MozillaVladimir Vukicevic2009-06-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Written by Vladimir Vukicevic to enable integration with Qt embedded devices, this backend allows cairo code to target QPainter, and use it as a source for other cairo backends. This imports the sources from mozilla-central: http://mxr.mozilla.org/mozilla-central/find?text=&kind=text&string=cairo-qpainter renames them from cairo-qpainter to cairo-qt, and integrates the patch by Oleg Romashin: https://bugs.freedesktop.org/attachment.cgi?id=18953 And then attempts to restore 'make check' to full functionality. However: - C++ does not play well with the PLT symbol hiding, and leaks into the global namespace. 'make check' fails at check-plt.sh - Qt embeds a GUI into QApplication which it requires to construct any QPainter drawable, i.e. used by the boilerplate to create a cairo-qt surface, and this leaks fonts (cairo-ft-fonts no less) causing assertion failures that all cairo objects are accounted for upon destruction. [Updated by Chris Wilson] Acked-by: Jeff Muizelaar <jeff@infidigm.net> Acked-by: Carl Worth <cworth@cworth.org>
* [perf] Report errors during replaysChris Wilson2009-06-161-1/+10
|
* [perf] Report iteration countChris Wilson2009-06-161-4/+4
| | | | | Show number of discard results by showing the number of statistically valid samples out of total population count.
* Expose _cairo_null_surface_create() via a test surfaceChris Wilson2009-06-151-3/+3
| | | | | | | Using a null surface is a convenient method to measure the overhead of the performance testing framework, so export it although as a test-surface so that it will only be available in development builds and not pollute distributed libraries.
* [boilerplate] Make array of targets const.Chris Wilson2009-06-121-3/+3
| | | | Protect the boilerplate targets from unexpected modifications.