public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/28277] New: ftell slow with wide characters
@ 2021-08-27  3:57 infor at rudhar dot com
  0 siblings, 0 replies; only message in thread
From: infor at rudhar dot com @ 2021-08-27  3:57 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28277

            Bug ID: 28277
           Summary: ftell slow with wide characters
           Product: glibc
           Version: 2.34
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: infor at rudhar dot com
  Target Milestone: ---

ftell slow with wide characters

In a wide character stream, ftell gets slower depending on where we are in a 4
kiB block: at the start of it, ftell is about as fast as with a non-wide
stream, around 100 ns in my test. Towards the end of the 4 kiB, it gets some 30
to 40 times slower. This can be problematic in applications that handle lots of
data.

Strangely, this is not affected by changing the stdio buffer size by calling
setvbuf. The change from slow to fast always happens when (bytepos modulo 4096
+ 1) goes from 4096 to 1.

Tested with glibc 2.31 as distributed with Linux Mint 20.1, and with a freshly
compiled 2.34. FreeBSD 12.2 does not have this problem, ftell is always fast
there, like 22 ns.

See also https://rudhar.com/sfreview/siworin/siworin09.htm . Demonstration
program available in https://rudhar.com/sfreview/siworin/src/siworin09.c .

When debugging this, I actually see a loop happening, in iconv/loop.c, for
example lines 309, 322 and 336. I don't see why ftell would need to involve any
looping, or any character conversion: as I see it, all ftell does is return the
current value of a stdio-internal counter, so it should be extremely fast.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-27  3:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  3:57 [Bug stdio/28277] New: ftell slow with wide characters infor at rudhar dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).