summaryrefslogtreecommitdiff
path: root/src/include/portability
Commit message (Collapse)AuthorAgeFilesLines
* instr_time: Represent time as an int64 on all platformsAndres Freund2023-01-201-76/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now we used struct timespec for instr_time on all platforms but windows. Using struct timespec causes a fair bit of memory (struct timeval is 16 bytes) and runtime overhead (much more complicated additions). Instead we can convert the time to nanoseconds in INSTR_TIME_SET_CURRENT(), making the remaining operations cheaper. Representing time as int64 nanoseconds provides sufficient range, ~292 years relative to a starting point (depending on clock source, relative to the unix epoch or the system's boot time). That'd not be sufficient for calendar time stored on disk, but is plenty for runtime interval time measurement. On windows instr_time already is represented as cycles. It might make sense to represent time as cycles on other platforms as well, as using cycle acquisition instructions like rdtsc directly can reduce the overhead of time acquisition substantially. This could be done in a fairly localized manner as the code stands after this commit. Because the windows and non-windows paths are now more similar, use a common set of macros. To make that possible, most of the use of LARGE_INTEGER had to be removed, which looks nicer anyway. To avoid users of the API relying on the integer representation, we wrap the 64bit integer inside struct struct instr_time. Author: Andres Freund <andres@anarazel.de> Author: Lukas Fittl <lukas@fittl.com> Author: David Geier <geidav.pg@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20230113195547.k4nlrmawpijqwlsa@awork3.anarazel.de
* Update copyright for 2023Bruce Momjian2023-01-022-2/+2
| | | | Backpatch-through: 11
* Fix obsolete comments in instr_time.h.Thomas Munro2022-08-091-4/+3
| | | | | | | | | Commit 623cc673 removed gettimeofday(), and commits 24c3ce8f and 495ed0ef removed support for very old Windows releases with low accuracy timers, but references to those things were left behind in comments. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/295419.1659918447%40sss.pgh.pa.us
* Remove configure probe for clock_gettime.Thomas Munro2022-08-051-68/+0
| | | | | | | | | | | | | | clock_gettime() is in SUSv2 and all targeted Unix systems have it. Remove a chunk of fallback code for old Unix is no longer reachable on modern systems, and untested as of the retirement of build farm animal prairiedog. There is no need to retain a HAVE_CLOCK_GETTIME macro here, because it is already used in a context with Unix and Windows code paths. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
* Update copyright for 2022Bruce Momjian2022-01-072-2/+2
| | | | Backpatch-through: 10
* Fix another portability bug in recent pgbench commit.Thomas Munro2021-03-101-28/+0
| | | | | | | | | | | | | | Commit 547f04e7 produced errors on AIX/xlc while building plpython. The new code appears to be incompatible with the hack installed by commit a11cf433. Without access to an AIX system to check, my guess is that _POSIX_C_SOURCE may be required for <time.h> to declare the things the header needs to see, but plpython.h undefines it. For now, to unbreak build farm animal hoverfly, just move the new pg_time_usec_t support into pgbench.c. Perhaps later we could figure out what to rearrange to put it back into a header for wider use. Discussion: https://postgr.es/m/CA%2BhUKG%2BP%2BjcD%3Dx9%2BagyTdWtjpOT64MYiGic%2Bcbu_TD8CV%3D6A3w%40mail.gmail.com
* pgbench: Improve time logic.Thomas Munro2021-03-101-0/+28
| | | | | | | | | | | Instead of instr_time (struct timespec) and the INSTR_XXX macros, introduce pg_time_usec_t and use integer arithmetic. Don't include the connection time in TPS unless using -C mode, but report it separately. Author: Fabien COELHO <coelho@cri.ensmp.fr> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Discussion: https://postgr.es/m/20200227180100.zyvjwzcpiokfsqm2%40alap3.anarazel.de
* Update copyright for 2021Bruce Momjian2021-01-022-2/+2
| | | | Backpatch-through: 9.5
* Update copyrights for 2020Bruce Momjian2020-01-012-2/+2
| | | | Backpatch-through: update all files in master, backpatch legal files through 9.4
* Update copyright for 2019Bruce Momjian2019-01-022-2/+2
| | | | Backpatch-through: certain files through 9.4
* instr_time.h: add INSTR_TIME_SET_CURRENT_LAZYAlvaro Herrera2018-11-211-0/+8
| | | | | | | | Sets the timestamp to current if not already set. Will acquire more callers momentarily. Author: Fabien Coelho Discussion: https://postgr.es/m/alpine.DEB.2.21.1808111104320.1705@lancre
* Update copyright for 2018Bruce Momjian2018-01-022-2/+2
| | | | Backpatch-through: certain files through 9.3
* Phase 2 of pgindent updates.Tom Lane2017-06-212-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change pg_bsd_indent to follow upstream rules for placement of comments to the right of code, and remove pgindent hack that caused comments following #endif to not obey the general rule. Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using the published version of pg_bsd_indent, but a hacked-up version that tried to minimize the amount of movement of comments to the right of code. The situation of interest is where such a comment has to be moved to the right of its default placement at column 33 because there's code there. BSD indent has always moved right in units of tab stops in such cases --- but in the previous incarnation, indent was working in 8-space tab stops, while now it knows we use 4-space tabs. So the net result is that in about half the cases, such comments are placed one tab stop left of before. This is better all around: it leaves more room on the line for comment text, and it means that in such cases the comment uniformly starts at the next 4-space tab stop after the code, rather than sometimes one and sometimes two tabs after. Also, ensure that comments following #endif are indented the same as comments following other preprocessor commands such as #else. That inconsistency turns out to have been self-inflicted damage from a poorly-thought-through post-indent "fixup" in pgindent. This patch is much less interesting than the first round of indent changes, but also bulkier, so I thought it best to separate the effects. Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
* Update copyright via script for 2017Bruce Momjian2017-01-032-2/+2
|
* Use clock_gettime(), if available, in instr_time measurements.Tom Lane2017-01-021-4/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The advantage of clock_gettime() is that the API allows the result to be precise to nanoseconds, not just microseconds as in gettimeofday(). Now that it's routinely possible to do tens of plan node executions in 1us, we really need more precision than gettimeofday() can offer for EXPLAIN ANALYZE to accumulate statistics with. Some research shows that clock_gettime() is available on pretty nearly every modern Unix-ish platform, and as far as I have been able to test, it has about the same execution time as gettimeofday(), so there's no loss in switching over. (By the same token, this doesn't do anything to fix the fact that we really wish clock readings were faster. But there's enough win here to justify changing anyway.) A small side benefit is that on most platforms, we can use CLOCK_MONOTONIC instead of CLOCK_REALTIME and thereby render EXPLAIN impervious to concurrent resets of the system clock. (This means that code must not assume that the contents of struct instr_time have any well-defined interpretation as timestamps, but really that was true before.) Some platforms offer nonstandard clock IDs that might be of interest. This patch knows we should use CLOCK_MONOTONIC_RAW on macOS, because it provides more precision and is faster to read than their CLOCK_MONOTONIC. If there turn out to be many more cases where we need special rules, it might be appropriate to handle the selection of clock ID in configure, but for the moment that doesn't seem worth the trouble. Discussion: https://postgr.es/m/31856.1400021891@sss.pgh.pa.us
* Update copyright for 2016Bruce Momjian2016-01-022-2/+2
| | | | Backpatch certain files through 9.1
* Use mmap MAP_NOSYNC option to limit shared memory writesBruce Momjian2015-03-211-0/+8
| | | | | | | mmap() is rarely used for shared memory, but when it is, this option is useful, particularly on the BSDs. Patch by Sean Chittenden
* Update copyright for 2015Bruce Momjian2015-01-062-2/+2
| | | | Backpatch certain files through 9.0
* pgindent run for 9.4Bruce Momjian2014-05-061-2/+2
| | | | | This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
* Update copyright for 2014Bruce Momjian2014-01-072-2/+2
| | | | | Update all files in head, and files COPYRIGHT and legal.sgml in all back branches.
* Allow dynamic allocation of shared memory segments.Robert Haas2013-10-091-0/+40
| | | | | Patch by myself and Amit Kapila. Design help from Noah Misch. Review by Andres Freund.
* Update copyrights for 2013Bruce Momjian2013-01-011-1/+1
| | | | | Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
* Update copyright notices for year 2012.Bruce Momjian2012-01-011-1/+1
|
* Stamp copyrights for year 2011.Bruce Momjian2011-01-011-1/+1
|
* Remove cvs keywords from all files.Magnus Hagander2010-09-201-1/+1
|
* Support inlining various small performance-critical functions on non-GCCTom Lane2010-02-131-2/+2
| | | | | | | | | compilers, by applying a configure check to see if the compiler will accept an unreferenced "static inline foo ..." function without warnings. It is believed that such warnings are the only reason not to declare inlined functions in headers, if the compiler understands "inline" at all. Kurt Harriman
* Update copyright for the year 2010.Bruce Momjian2010-01-021-2/+2
|
* 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian2009-06-111-6/+4
| | | | provided by Andrew.
* Update copyright for 2009.Bruce Momjian2009-01-011-2/+2
|
* Add support for tracking call counts and elapsed runtime for user-definedTom Lane2008-05-151-3/+20
| | | | | | | | | | functions. Note that because this patch changes FmgrInfo, any external C functions you might be testing with 8.4 will need to be recompiled. Patch by Martin Pihlak, some editorialization by me (principally, removing tracking of getrusage() numbers)
* Move the "instr_time" typedef and associated macros into a new headerTom Lane2008-05-141-0/+139
file portability/instr_time.h, and add a couple more macros to eliminate some abstraction leakage we formerly had. Also update psql to use this header instead of its own copy of nearly the same code. This commit in itself is just code cleanup and shouldn't change anything. It lays some groundwork for the upcoming function-stats patch, though.