Re: [basex-talk] db:copy

2023-11-16 Thread Ветошкин Владимир
Yes, Result of the server instance:java.vm.compressedOopsMode: 32-bit java.vm.info: mixed mode, sharing java.vm.name: OpenJDK 64-Bit Server VM java.vm.specification.name: Java Virtual Machine Specification java.vm.specification.vendor: Oracle Corporation java.vm.specification.version: 12 java.vm.vendor: Azul Systems, Inc. java.vm.version: 12.0.2+3 Result of the standalone instance:java.vm.compressedOopsMode: 32-bitjava.vm.info: mixed mode, sharingjava.vm.name: OpenJDK 64-Bit Server VMjava.vm.specification.name: Java Virtual Machine Specificationjava.vm.specification.vendor: Oracle Corporationjava.vm.specification.version: 12java.vm.vendor: Azul Systems, Inc.java.vm.version: 12.0.2+3   16.11.2023, 15:40, "Christian Grün" :Are they use different methods to copy databases? Or that jdk bug only? It’s exactly the same; when db:copy is called, the function isn’t aware of whether it has been called by a server or standalone/client instance. Are you sure that both the server and the standalone version of BaseX use the same JRE? You can e.g. check this with the following query: for $p in proc:property-names()[starts-with(., 'java.vm.')]return $p || ': ' || proc:property($p)16.11.2023, 15:00, "Christian Grün" :Hi, this definitely looks like a bug in the JDK context. What happens if you upgrade your JDK to a newer version?Best, Christian  On Thu, Nov 16, 2023 at 12:56 PM Ветошкин Владимир  wrote: Hi everyone. Since I have changed jdk version to 12 (azul) - I get error, when I copy database (db:copy).It's only in basexserver. When I run basex - everything is ok. Error:Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 9.1.2 Java: Azul Systems, Inc., 12.0.2 OS: Linux, amd64 Stack Trace: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile at java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258) at java.base/java.nio.file.Files.copy(Files.java:1297) at org.basex.io.IOFile.copyTo(IOFile.java:319) at org.basex.core.cmd.Copy.copy(Copy.java:83) at org.basex.query.up.primitives.name.DBCopy.apply(DBCopy.java:43) at org.basex.query.up.NameUpdates.apply(NameUpdates.java:58) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:132) at org.basex.query.up.Updates.apply(Updates.java:156) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.iter(QueryProcessor.java:90) at org.basex.core.cmd.AQuery.query(AQuery.java:109) at org.basex.core.cmd.XQuery.run(XQuery.java:22) at org.basex.core.Command.run(Command.java:257) at org.basex.core.Command.execute(Command.java:93) at org.basex.server.ClientListener.run(ClientListener.java:140)-- С уважением,Ветошкин Владимир Владимирович   -- С уважением,Ветошкин Владимир Владимирович   -- С уважением,Ветошкин Владимир Владимирович 

Re: [basex-talk] WG: JAVA Performance Issue under RH8 by using BASEX with NFS system

2023-11-16 Thread Christian Grün
Hi Andre,

It’s probably out of scope to give a reasonable response to your questions
via the public mailing list (feel free to ask for our commercial services),
but here’s a quick shot:

>
>- why is the whole database read even for a "small" query ? (looks
>like a missing index or bad execution plan.. ?)
>
> It may depend a lot on what the query does. Could you give us an example
for a typical “small query”?

>
>- The UNIX related question (maybe it's worth opening a ticket with
>   redhat)
>
> I guess so. I’m sorry I have no in-depth knowledge on why RHL 6 and 8
behaves differently here.

Have you already tried different JDK versions/distributions?

Best,
Christian


Re: [basex-talk] db:copy

2023-11-16 Thread Christian Grün
>
> Are they use different methods to copy databases? Or that jdk bug only?
>

It’s exactly the same; when db:copy is called, the function isn’t aware of
whether it has been called by a server or standalone/client instance.

Are you sure that both the server and the standalone version of BaseX use
the same JRE? You can e.g. check this with the following query:

for $p in proc:property-names()[starts-with(., 'java.vm.')]
return $p || ': ' || proc:property($p)




> 16.11.2023, 15:00, "Christian Grün" :
>
> Hi, this definitely looks like a bug in the JDK context. What happens if
> you upgrade your JDK to a newer version?
> Best, Christian
>
>
> On Thu, Nov 16, 2023 at 12:56 PM Ветошкин Владимир 
> wrote:
>
>
> Hi everyone.
>
> Since I have changed jdk version to 12 (azul) - I get error, when I copy
> database (db:copy).
> It's only in basexserver. When I run basex - everything is ok.
>
> Error:
> Improper use? Potential bug? Your feedback is welcome: Contact:
> basex-talk@mailman.uni-konstanz.de Version: BaseX 9.1.2 Java: Azul
> Systems, Inc., 12.0.2 OS: Linux, amd64 Stack Trace:
> java.lang.NoClassDefFoundError: Could not initialize class
> sun.nio.fs.UnixCopyFile at
> java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258)
> at java.base/java.nio.file.Files.copy(Files.java:1297) at
> org.basex.io.IOFile.copyTo(IOFile.java:319) at
> org.basex.core.cmd.Copy.copy(Copy.java:83) at
> org.basex.query.up.primitives.name.DBCopy.apply(DBCopy.java:43) at
> org.basex.query.up.NameUpdates.apply(NameUpdates.java:58) at
> org.basex.query.up.ContextModifier.apply(ContextModifier.java:132) at
> org.basex.query.up.Updates.apply(Updates.java:156) at
> org.basex.query.QueryContext.iter(QueryContext.java:351) at
> org.basex.query.QueryProcessor.iter(QueryProcessor.java:90) at
> org.basex.core.cmd.AQuery.query(AQuery.java:109) at
> org.basex.core.cmd.XQuery.run(XQuery.java:22) at
> org.basex.core.Command.run(Command.java:257) at
> org.basex.core.Command.execute(Command.java:93) at
> org.basex.server.ClientListener.run(ClientListener.java:140)
> --
> С уважением,
> Ветошкин Владимир Владимирович
>
>
>
>
> --
> С уважением,
> Ветошкин Владимир Владимирович
>
>


Re: [basex-talk] WG: JAVA Performance Issue under RH8 by using BASEX with NFS system

2023-11-16 Thread Gerbatsch, Andre
bounced by the List, re-sent after subscription
--

Hello Christian and team,

I am from IT and helped Michael to analyze and reproduce the problem.
I would like to describe what we found and maybe you have some Ideas what we 
can optimize. Any advice will be helpful 

The questions are:

  *   why is the whole database read even for a "small" query ? (looks like a 
missing index or bad execution plan.. ?)
 *   are there some tricks / best practices to optimize ?
  *   why do we use 4K blocksize performing a seek() before every read even for 
sequential reads from the database file ?
 *   can the blocksize be changed ? does it make sense ?

The UNIX related question (maybe it's worth opening a ticket with redhat)

  *   why does the UNIX kernel enforce nfs reads (slow) for the combination: 
set read lock; seek; read; ... and uses the cache (is fast) if we omit seek() 
even if the file is locked?

Thank you for your comments in advance!
Andre



Below are more details.
We performed a query (wget output about 150K) and saw in the strace the typical 
sequence:

  *   open (..tbl.basex)
  *   set read lock
  *   seek(); read() the whole file (650MB) by 4k blocks, seek() before every 
read (even for sequential read - where the position is already at the right 
place for the next read());
  *   close().

We found that all recent OS (RHEL7,8; debian12) are reproducible bypassing the 
filesystem cache if the database files on a nfs mounted filesystem.
RHEL6 uses the filesystem cache.



=== trace snippets
open(.. tbl.basex); fcntl(f, F_SETLK, {l_type=F_RDLCK}; seek(); read(f, 4k); 
seek(); read(.. 4k); close

 ..
openat(AT_FDCWD, 
"/proj/mpi_la/sb_dev/sbof/tbl.basex", O_RDWR|O_CREAT, 0666) = 51

#-- set read lock on the whole file (l_len=0).
fcntl(51, F_SETLK, {l_type=F_RDLCK, 
l_whence=SEEK_SET, l_start=0, l_len=0}) = 0

#-- lseek(), read(..,4K), lseek(), read(..,4k) -
# reading
..
13:09:30.050965 lseek(51, 0, SEEK_SET) = 0 
<0.63>
13:09:30.051900 read(51, 
"\0\0\0\0\0\0\0\0\0\0\314b\0\0\0\0001\0\1\0\0\0\0\1\0\0\314a\0\0\0\1"..., 4096) 
= 4096 <0.179836>
13:09:30.231893 lseek(51, 4096, SEEK_SET) = 
4096 <0.17>
13:09:30.232818 read(51, 
"\2\0\0\0\0\0\5\274\0\0\0\1\0\0\1\0\t\0004\0\0\0\0\5\0\0\0\2\0\0\1\1"..., 4096) 
= 4096 <0.41>
13:09:30.232923 lseek(51, 8192, SEEK_SET) = 
8192 <0.15>
13:09:30.232988 read(51, 
"\2\0\0@\0\0\n\303\0\0\0\1\0\0\2\0\t\09\0\0\0\0\6\0\0\0\2\0\0\2\1"..., 4096) = 
4096 <0.16>
..
#jump to the end and back..
13:09:30.248343 lseek(51, 192512, SEEK_SET) 
= 192512 <0.15>
13:09:30.248416 read(51, 
"\2\0\0@\0\0\250\n\0\0\0\1\0\0/\0\t\0A\0\0\0\0\25\0\0\0\2\0\0/\1"..., 4096) = 
4096 <0.0
13:09:30.248488 lseek(51, 586047488, 
SEEK_SET) = 586047488 <0.15>
13:09:30.248567 read(51, 
"\31\0j\0\0\0/\377\0\0\0(\0\0/\326\v\0\6\0\0\0 \217\0\0\0\0\0\0/\327"..., 4096) 
= 4096
13:09:30.249898 lseek(51, 196608, SEEK_SET) 
= 196608 <0.16>
13:09:30.250564 read(51, 
"\2\0\0\0\0\0\253\254\0\0\0\1\0\\0\t\08\0\0\0\0\3\0\0\0\2\0\\1"..., 
4096) = 409

close(51)

 test program to repoduce the behavior.
#!/tool/pandora64/bin/python3-latest
# test emulating the bad performance when baseX opens a database for read
#
# both conditions must be true:
# 1. set a read lock on the file
# 2. seek before reading.
#
# without lock or without seek it is fast.
#
# rhel6 - fast (<1s)
# rhel7,8 and debian12 - slow (~10s)
#   nfs -o vers=3,nolock - has no effect
#
# agerbats (Andre Gerbatsch), 11/10/2023
#

import fcntl

BS= 4096
FN= "/proj/sysadmin_scratch/agerbats/tbl.basex"

f = open(FN, "rb", buffering=0)

#-- set a read lock
fcntl.lockf(f, fcntl.LOCK_SH)
f.seek(0,2)
file_length=f.tell()

offset = 0
while  offset < file_length:

#-- seek to the next 4k position (it is semantically a noop)
f.seek(offset)
block=f.read(BS)
offset+= BS

f.close()




--
Andre


Von: Otto, Michael (Layout Analysis) 
Gesendet: Montag, 13. November 2023 18:19
An: Gerbatsch, Andre 
Betreff: WG: [basex-talk] WG: JAVA Performance Issue under RH8 by using BASEX 
with NFS system



Von: Christian Grün 
Gesendet: Montag, 13. November 2023 16:11
An: Otto, Michael (Layout Analysis) 
Cc: basex-talk@mailman.uni-konstanz.de 
Betreff: Re: [basex-talk] WG: JAVA Performance Issue under RH8 by using BASEX 
with NFS system


CAUTION: This email originated outside of the GF organization. Please consider 
the source / sender to ensure the content is safe before clicking on links or 
opening attachments. If you're unsure, please report this email as phishing so 
it can be analyzed.


…difficult to tell what might be the reason; we didn’t get similar reports so 
far. Most of the BaseX caching algorithms rely on the file system, but we don’t 
differ between Windows- and UNIX-based systems.

Does it make a difference if you change another JDK distribution?

Best,
Christian


On Mon, 

Re: [basex-talk] db:copy

2023-11-16 Thread Ветошкин Владимир
Hi, Christian. I can't check it now. Maybe later.I confuse with the fact, that basexserver failes, but basex did not.Are they use different methods to copy databases? Or that jdk bug only? 16.11.2023, 15:00, "Christian Grün" :Hi, this definitely looks like a bug in the JDK context. What happens if you upgrade your JDK to a newer version?Best, Christian  On Thu, Nov 16, 2023 at 12:56 PM Ветошкин Владимир  wrote: Hi everyone. Since I have changed jdk version to 12 (azul) - I get error, when I copy database (db:copy).It's only in basexserver. When I run basex - everything is ok. Error:Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 9.1.2 Java: Azul Systems, Inc., 12.0.2 OS: Linux, amd64 Stack Trace: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile at java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258) at java.base/java.nio.file.Files.copy(Files.java:1297) at org.basex.io.IOFile.copyTo(IOFile.java:319) at org.basex.core.cmd.Copy.copy(Copy.java:83) at org.basex.query.up.primitives.name.DBCopy.apply(DBCopy.java:43) at org.basex.query.up.NameUpdates.apply(NameUpdates.java:58) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:132) at org.basex.query.up.Updates.apply(Updates.java:156) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.iter(QueryProcessor.java:90) at org.basex.core.cmd.AQuery.query(AQuery.java:109) at org.basex.core.cmd.XQuery.run(XQuery.java:22) at org.basex.core.Command.run(Command.java:257) at org.basex.core.Command.execute(Command.java:93) at org.basex.server.ClientListener.run(ClientListener.java:140)-- С уважением,Ветошкин Владимир Владимирович   -- С уважением,Ветошкин Владимир Владимирович 

Re: [basex-talk] db:copy

2023-11-16 Thread Christian Grün
Hi, this definitely looks like a bug in the JDK context. What happens if
you upgrade your JDK to a newer version?
Best, Christian


On Thu, Nov 16, 2023 at 12:56 PM Ветошкин Владимир 
wrote:

>
> Hi everyone.
>
> Since I have changed jdk version to 12 (azul) - I get error, when I copy
> database (db:copy).
> It's only in basexserver. When I run basex - everything is ok.
>
> Error:
> Improper use? Potential bug? Your feedback is welcome: Contact:
> basex-talk@mailman.uni-konstanz.de Version: BaseX 9.1.2 Java: Azul
> Systems, Inc., 12.0.2 OS: Linux, amd64 Stack Trace:
> java.lang.NoClassDefFoundError: Could not initialize class
> sun.nio.fs.UnixCopyFile at
> java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258)
> at java.base/java.nio.file.Files.copy(Files.java:1297) at
> org.basex.io.IOFile.copyTo(IOFile.java:319) at
> org.basex.core.cmd.Copy.copy(Copy.java:83) at
> org.basex.query.up.primitives.name.DBCopy.apply(DBCopy.java:43) at
> org.basex.query.up.NameUpdates.apply(NameUpdates.java:58) at
> org.basex.query.up.ContextModifier.apply(ContextModifier.java:132) at
> org.basex.query.up.Updates.apply(Updates.java:156) at
> org.basex.query.QueryContext.iter(QueryContext.java:351) at
> org.basex.query.QueryProcessor.iter(QueryProcessor.java:90) at
> org.basex.core.cmd.AQuery.query(AQuery.java:109) at
> org.basex.core.cmd.XQuery.run(XQuery.java:22) at
> org.basex.core.Command.run(Command.java:257) at
> org.basex.core.Command.execute(Command.java:93) at
> org.basex.server.ClientListener.run(ClientListener.java:140)
> --
> С уважением,
> Ветошкин Владимир Владимирович
>
>


[basex-talk] db:copy

2023-11-16 Thread Ветошкин Владимир
 Hi everyone. Since I have changed jdk version to 12 (azul) - I get error, when I copy database (db:copy).It's only in basexserver. When I run basex - everything is ok. Error:Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 9.1.2 Java: Azul Systems, Inc., 12.0.2 OS: Linux, amd64 Stack Trace: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile at java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258) at java.base/java.nio.file.Files.copy(Files.java:1297) at org.basex.io.IOFile.copyTo(IOFile.java:319) at org.basex.core.cmd.Copy.copy(Copy.java:83) at org.basex.query.up.primitives.name.DBCopy.apply(DBCopy.java:43) at org.basex.query.up.NameUpdates.apply(NameUpdates.java:58) at org.basex.query.up.ContextModifier.apply(ContextModifier.java:132) at org.basex.query.up.Updates.apply(Updates.java:156) at org.basex.query.QueryContext.iter(QueryContext.java:351) at org.basex.query.QueryProcessor.iter(QueryProcessor.java:90) at org.basex.core.cmd.AQuery.query(AQuery.java:109) at org.basex.core.cmd.XQuery.run(XQuery.java:22) at org.basex.core.Command.run(Command.java:257) at org.basex.core.Command.execute(Command.java:93) at org.basex.server.ClientListener.run(ClientListener.java:140)-- С уважением,Ветошкин Владимир Владимирович